--- a/jdk/make/copy/Copy-java.base.gmk Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/copy/Copy-java.base.gmk Thu Oct 30 13:56:09 2014 -0700
@@ -48,22 +48,6 @@
################################################################################
-CALENDARS_SRC := $(JDK_TOPDIR)/src/java.base/share/conf
-
-$(LIB_DST_DIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
- $(call install-file)
-
-BASE_CONF_FILES += $(LIB_DST_DIR)/calendars.properties
-
-$(LIB_DST_DIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties
- $(MKDIR) -p $(@D)
- $(RM) $@
- $(CP) $< $@
-
-BASE_CONF_FILES += $(LIB_DST_DIR)/hijrah-config-umalqura.properties
-
-################################################################################
-
ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf
--- a/jdk/make/copy/Copy-java.desktop.gmk Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/copy/Copy-java.desktop.gmk Thu Oct 30 13:56:09 2014 -0700
@@ -67,8 +67,11 @@
FREETYPE_TARGET_LIB := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/$(call SHARED_LIBRARY,freetype).6
endif
+ # We can't use $(install-file) in this rule because it preserves symbolic links and
+ # libfreetype.so is usually a symbolic link to something like libfreetype.so.6 on Unix.
$(FREETYPE_TARGET_LIB): $(FREETYPE_BUNDLE_LIB_PATH)/$(call SHARED_LIBRARY,freetype)
- $(install-file)
+ $(MKDIR) -p $(@D)
+ $(CP) $< $@
ifeq ($(OPENJDK_BUILD_OS), windows)
$(CHMOD) +rx $@
endif
--- a/jdk/make/data/tzdata/VERSION Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/VERSION Thu Oct 30 13:56:09 2014 -0700
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014g
+tzdata2014i
--- a/jdk/make/data/tzdata/africa Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/africa Thu Oct 30 13:56:09 2014 -0700
@@ -133,23 +133,13 @@
# See Africa/Lagos.
# Botswana
-# From Paul Eggert (2013-02-21):
-# Milne says they were regulated by the Cape Town Signal in 1899;
-# assume they switched to 2:00 when Cape Town did.
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Gaborone 1:43:40 - LMT 1885
- 1:30 - SAST 1903 Mar
- 2:00 - CAT 1943 Sep 19 2:00
- 2:00 1:00 CAST 1944 Mar 19 2:00
- 2:00 - CAT
+# See Africa/Maputo.
# Burkina Faso
# See Africa/Abidjan.
# Burundi
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Bujumbura 1:57:28 - LMT 1890
- 2:00 - CAT
+# See Africa/Maputo.
# Cameroon
# See Africa/Lagos.
@@ -184,10 +174,7 @@
3:00 - EAT
# Democratic Republic of the Congo
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Lubumbashi 1:49:52 - LMT 1897 Nov 9
- 2:00 - CAT
-# The above is for the eastern part; see Africa/Lagos for the western part.
+# See Africa/Lagos for the western part and Africa/Maputo for the eastern.
# Republic of the Congo
# See Africa/Lagos.
@@ -339,7 +326,7 @@
# Egypt is to change back to Daylight system on May 15
# http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx
-# From Gunther Vermier (2015-05-13):
+# From Gunther Vermier (2014-05-13):
# our Egypt office confirms that the change will be at 15 May "midnight" (24:00)
# From Imed Chihi (2014-06-04):
@@ -489,11 +476,7 @@
3:00 - EAT
# Lesotho
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Maseru 1:50:00 - LMT 1903 Mar
- 2:00 - SAST 1943 Sep 19 2:00
- 2:00 1:00 SAST 1944 Mar 19 2:00
- 2:00 - SAST
+# See Africa/Johannesburg.
# Liberia
# From Paul Eggert (2006-03-22):
@@ -575,9 +558,7 @@
3:00 - EAT
# Malawi
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Blantyre 2:20:00 - LMT 1903 Mar
- 2:00 - CAT
+# See Africa/Maputo.
# Mali
# Mauritania
@@ -987,6 +968,13 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Maputo 2:10:20 - LMT 1903 Mar
2:00 - CAT
+Link Africa/Maputo Africa/Blantyre # Malawi
+Link Africa/Maputo Africa/Bujumbura # Burundi
+Link Africa/Maputo Africa/Gaborone # Botswana
+Link Africa/Maputo Africa/Harare # Zimbabwe
+Link Africa/Maputo Africa/Kigali # Rwanda
+Link Africa/Maputo Africa/Lubumbashi # E Dem. Rep. of Congo
+Link Africa/Maputo Africa/Lusaka # Zambia
# Namibia
# The 1994-04-03 transition is from Shanks & Pottenger.
@@ -1054,9 +1042,7 @@
# Tromelin - inhabited until at least 1958
# Rwanda
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Kigali 2:00:16 - LMT 1935 Jun
- 2:00 - CAT
+# See Africa/Maputo.
# St Helena
# See Africa/Abidjan.
@@ -1100,6 +1086,9 @@
Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8
1:30 - SAST 1903 Mar
2:00 SA SAST
+Link Africa/Johannesburg Africa/Maseru # Lesotho
+Link Africa/Johannesburg Africa/Mbabane # Swaziland
+#
# Marion and Prince Edward Is
# scientific station since 1947
# no information
@@ -1127,9 +1116,7 @@
Link Africa/Khartoum Africa/Juba
# Swaziland
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Mbabane 2:04:24 - LMT 1903 Mar
- 2:00 - SAST
+# See Africa/Johannesburg.
# Tanzania
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1250,11 +1237,5 @@
3:00 - EAT
# Zambia
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Lusaka 1:53:08 - LMT 1903 Mar
- 2:00 - CAT
-
# Zimbabwe
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Africa/Harare 2:04:12 - LMT 1903 Mar
- 2:00 - CAT
+# See Africa/Maputo.
--- a/jdk/make/data/tzdata/asia Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/asia Thu Oct 30 13:56:09 2014 -0700
@@ -70,10 +70,11 @@
# 3:30 IRST IRDT Iran
# 4:00 GST Gulf*
# 5:30 IST India
-# 7:00 ICT Indochina*
+# 7:00 ICT Indochina, most times and locations*
# 7:00 WIB west Indonesia (Waktu Indonesia Barat)
# 8:00 WITA central Indonesia (Waktu Indonesia Tengah)
# 8:00 CST China
+# 8:00 IDT Indochina, 1943-45, 1947-55, 1960-75 (some locations)*
# 8:00 JWST Western Standard Time (Japan, 1896/1937)*
# 9:00 JCST Central Standard Time (Japan, 1896/1937)
# 9:00 WIT east Indonesia (Waktu Indonesia Timur)
@@ -294,12 +295,8 @@
6:30 - MMT # Myanmar Time
# Cambodia
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jun 9
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
- 7:00 - ICT
+# See Asia/Bangkok.
+
# China
@@ -916,6 +913,10 @@
# Indonesia
#
+# From Paul Eggert (2014-09-06):
+# The 1876 Report of the Secretary of the [US] Navy, p 306 says that Batavia
+# civil time was 7:07:12.5; round to even for Jakarta.
+#
# From Gwillim Law (2001-05-28), overriding Shanks & Pottenger:
# http://www.sumatera-inc.com/go_to_invest/about_indonesia.asp#standtime
# says that Indonesia's time zones changed on 1988-01-01. Looking at some
@@ -1733,12 +1734,8 @@
3:00 - AST
# Laos
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Vientiane 6:50:24 - LMT 1906 Jun 9 # or Viangchan
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
- 7:00 - ICT
+# See Asia/Bangkok.
+
# Lebanon
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
@@ -2751,6 +2748,8 @@
Zone Asia/Bangkok 6:42:04 - LMT 1880
6:42:04 - BMT 1920 Apr # Bangkok Mean Time
7:00 - ICT
+Link Asia/Bangkok Asia/Phnom_Penh # Cambodia
+Link Asia/Bangkok Asia/Vientiane # Laos
# Turkmenistan
# From Shanks & Pottenger.
@@ -2788,22 +2787,65 @@
# Vietnam
-# From Paul Eggert (2013-02-21):
+# From Paul Eggert (2014-10-04):
# Milne gives 7:16:56 for the meridian of Saigon in 1899, as being
# used in Lower Laos, Cambodia, and Annam. But this is quite a ways
# from Saigon's location. For now, ignore this and stick with Shanks
-# and Pottenger.
+# and Pottenger for LMT before 1906.
# From Arthur David Olson (2008-03-18):
# The English-language name of Vietnam's most populous city is "Ho Chi Minh
# City"; use Ho_Chi_Minh below to avoid a name of more than 14 characters.
-# From Shanks & Pottenger:
+# From Paul Eggert (2014-10-21) after a heads-up from Trần Ngọc Quân:
+# Trần Tiến Bình's authoritative book "Lịch Việt Nam: thế kỷ XX-XXI (1901-2100)"
+# (Nhà xuất bản Văn Hoá - Thông Tin, Hanoi, 2005), pp 49-50,
+# is quoted verbatim in:
+# http://www.thoigian.com.vn/?mPage=P80D01
+# is translated by Brian Inglis in:
+# http://mm.icann.org/pipermail/tz/2014-October/021654.html
+# and is the basis for the information below.
+#
+# The 1906 transition was effective July 1 and standardized Indochina to
+# Phù Liễn Observatory, legally 104 deg. 17'17" east of Paris.
+# It's unclear whether this meant legal Paris Mean Time (00:09:21) or
+# the Paris Meridian (2 deg. 20'14.03" E); the former yields 07:06:30.1333...
+# and the latter 07:06:29.333... so either way it rounds to 07:06:30,
+# which is used below even though the modern-day Phù Liễn Observatory
+# is closer to 07:06:31. Abbreviate Phù Liễn Mean Time as PLMT.
+#
+# The following transitions occurred in Indochina in general (before 1954)
+# and in South Vietnam in particular (after 1954):
+# To 07:00 on 1911-05-01.
+# To 08:00 on 1942-12-31 at 23:00.
+# To 09:00 in 1945-03-14 at 23:00.
+# To 07:00 on 1945-09-02 in Vietnam.
+# To 08:00 on 1947-04-01 in French-controlled Indochina.
+# To 07:00 on 1955-07-01 in South Vietnam.
+# To 08:00 on 1959-12-31 at 23:00 in South Vietnam.
+# To 07:00 on 1975-06-13 in South Vietnam.
+#
+# Trần cites the following sources; it's unclear which supplied the info above.
+#
+# Hoàng Xuân Hãn: "Lịch và lịch Việt Nam". Tập san Khoa học Xã hội,
+# No. 9, Paris, February 1982.
+#
+# Lê Thành Lân: "Lịch và niên biểu lịch sử hai mươi thế kỷ (0001-2010)",
+# NXB Thống kê, Hanoi, 2000.
+#
+# Lê Thành Lân: "Lịch hai thế kỷ (1802-2010) và các lịch vĩnh cửu",
+# NXB Thuận Hoá, Huế, 1995.
+
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9
- 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
- 7:00 - ICT 1912 May
- 8:00 - ICT 1931 May
+Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1
+ 7:06:30 - PLMT 1911 May 1
+ 7:00 - ICT 1942 Dec 31 23:00
+ 8:00 - IDT 1945 Mar 14 23:00
+ 9:00 - JST 1945 Sep 2
+ 7:00 - ICT 1947 Apr 1
+ 8:00 - IDT 1955 Jul 1
+ 7:00 - ICT 1959 Dec 31 23:00
+ 8:00 - IDT 1975 Jun 13
7:00 - ICT
# Yemen
--- a/jdk/make/data/tzdata/australasia Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/australasia Thu Oct 30 13:56:09 2014 -0700
@@ -354,20 +354,27 @@
# Fiji will end DST on 2014-01-19 02:00:
# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx
-# From Paul Eggert (2014-01-10):
-# For now, guess that Fiji springs forward the Sunday before the fourth
-# Monday in October, and springs back the penultimate Sunday in January.
-# This is ad hoc, but matches recent practice.
+# From Ken Rylander (2014-10-20):
+# DST will start Nov. 2 this year.
+# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx
+
+# From Paul Eggert (2014-10-20):
+# For now, guess DST from 02:00 the first Sunday in November to
+# 03:00 the first Sunday on or after January 18. Although ad hoc, it
+# matches this year's plan and seems more likely to match future
+# practice than guessing no DST.
# 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>=21 2:00 1:00 S
+Rule Fiji 2010 2013 - Oct Sun>=21 2:00 1:00 S
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 -
-Rule Fiji 2014 max - Jan Sun>=18 2:00 0 -
+Rule Fiji 2014 only - Jan Sun>=18 2:00 0 -
+Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S
+Rule Fiji 2015 max - Jan Sun>=18 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva
12:00 Fiji FJ%sT # Fiji Time
@@ -542,6 +549,30 @@
Zone Pacific/Port_Moresby 9:48:40 - LMT 1880
9:48:32 - PMMT 1895 # Port Moresby Mean Time
10:00 - PGT # Papua New Guinea Time
+#
+# From Paul Eggert (2014-10-13):
+# Base the Bougainville entry on the Arawa-Kieta region, which appears to have
+# the most people even though it was devastated in the Bougainville Civil War.
+#
+# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates
+# are apparently rough guesswork from the starts of military campaigns.
+# The World War II entries below are instead based on Arawa-Kieta.
+# The Japanese occupied Kieta in July 1942,
+# according to the Pacific War Online Encyclopedia
+# http://pwencycl.kgbudge.com/B/o/Bougainville.htm
+# and seem to have controlled it until their 1945-08-21 surrender.
+#
+# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11
+# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time";
+# abbreviate this as BST. See:
+# http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/
+#
+Zone Pacific/Bougainville 10:22:16 - LMT 1880
+ 9:48:32 - PMMT 1895
+ 10:00 - PGT 1942 Jul
+ 9:00 - JST 1945 Aug 21
+ 10:00 - PGT 2014 Dec 28 2:00
+ 11:00 - BST
# Pitcairn
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -826,6 +857,7 @@
# 10:00 AEST AEDT Eastern Australia
# 10:00 ChST Chamorro
# 10:30 LHST LHDT Lord Howe*
+# 11:00 BST Bougainville*
# 11:30 NZMT NZST New Zealand through 1945
# 12:00 NZST NZDT New Zealand 1946-present
# 12:15 CHAST Chatham through 1945*
--- a/jdk/make/data/tzdata/europe Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/europe Thu Oct 30 13:56:09 2014 -0700
@@ -91,10 +91,11 @@
# 0:00 WET WEST WEMT Western Europe
# 0:19:32.13 AMT NST Amsterdam, Netherlands Summer (1835-1937)*
# 0:20 NET NEST Netherlands (1937-1940)*
+# 1:00 BST British Standard (1968-1971)
# 1:00 CET CEST CEMT Central Europe
# 1:00:14 SET Swedish (1879-1899)*
# 2:00 EET EEST Eastern Europe
-# 3:00 FET Further-eastern Europe*
+# 3:00 FET Further-eastern Europe (2011-2014)*
# 3:00 MSK MSD MSM* Moscow
# From Peter Ilieve (1994-12-04),
@@ -746,6 +747,13 @@
# http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html
# http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/
# http://news.tut.by/society/250578.html
+#
+# From Alexander Bokovoy (2014-10-09):
+# Belarussian government decided against changing to winter time....
+# http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html
+# From Paul Eggert (2014-10-08):
+# Hence Belarus can share time zone abbreviations with Moscow again.
+#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Minsk 1:50:16 - LMT 1880
1:50 - MMT 1924 May 2 # Minsk Mean Time
@@ -758,7 +766,8 @@
2:00 - EET 1992 Mar 29 0:00s
2:00 1:00 EEST 1992 Sep 27 0:00s
2:00 Russia EE%sT 2011 Mar 27 2:00s
- 3:00 - FET
+ 3:00 - FET 2014 Oct 26 1:00s
+ 3:00 - MSK
# Belgium
#
@@ -2524,7 +2533,7 @@
# The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus
# realigning itself with KRAT.
-Zone Asia/Novokuznetsk 5:48:48 - NMT 1920 Jan 6
+Zone Asia/Novokuznetsk 5:48:48 - LMT 1924 May 1
6:00 - KRAT 1930 Jun 21 # Krasnoyarsk Time
7:00 Russia KRA%sT 1991 Mar 31 2:00s
6:00 Russia KRA%sT 1992 Jan 19 2:00s
--- a/jdk/make/data/tzdata/northamerica Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/northamerica Thu Oct 30 13:56:09 2014 -0700
@@ -300,6 +300,12 @@
# time zone, but we do go by the Eastern time zone because so many people work
# in Columbus."
+# From Paul Eggert (2014-09-06):
+# Monthly Notices of the Royal Astronomical Society 44, 4 (1884-02-08), 208
+# says that New York City Hall time was 3 minutes 58.4 seconds fast of
+# Eastern time (i.e., -4:56:01.6) just before the 1883 switch. Round to the
+# nearest second.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER
Rule NYC 1920 only - Mar lastSun 2:00 1:00 D
Rule NYC 1920 only - Oct lastSun 2:00 0 S
@@ -1118,17 +1124,16 @@
# An amendment to the Interpretation Act was registered on February 19/2007....
# http://action.attavik.ca/home/justice-gn/attach/2007/gaz02part2.pdf
-# From Paul Eggert (2006-04-25):
+# From Paul Eggert (2014-10-18):
# H. David Matthews and Mary Vincent's map
# "It's about TIME", _Canadian Geographic_ (September-October 1998)
-# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp
+# http://www.canadiangeographic.ca/Magazine/SO98/alacarte.asp
# contains detailed boundaries for regions observing nonstandard
# time and daylight saving time arrangements in Canada circa 1998.
#
-# INMS, the Institute for National Measurement Standards in Ottawa, has
-# information about standard and daylight saving time zones in Canada.
-# http://inms-ienm.nrc-cnrc.gc.ca/en/time_services/daylight_saving_e.php
-# (updated periodically).
+# National Research Council Canada maintains info about time zones and DST.
+# http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html
+# http://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5
# Its unofficial information is often taken from Matthews and Vincent.
# From Paul Eggert (2006-06-27):
@@ -1993,10 +1998,7 @@
# [Also see <http://www.nunatsiaq.com/nunavut/nvt10309_06.html> (2001-03-09).]
# From Gwillim Law (2005-05-21):
-# According to maps at
-# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SWE.jpg
-# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SSE.jpg
-# (both dated 2003), and
+# According to ...
# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp
# (from a 1998 Canadian Geographic article), the de facto and de jure time
# for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year
@@ -2005,9 +2007,11 @@
# predates the creation of Nunavut, it probably goes back many years....
# The Inuktitut name of Coral Harbour is Sallit, but it's rarely used.
#
-# From Paul Eggert (2005-07-26):
+# From Paul Eggert (2014-10-17):
# For lack of better information, assume that Southampton Island observed
-# daylight saving only during wartime.
+# daylight saving only during wartime. Gwillim Law's email also
+# mentioned maps now maintained by National Research Council Canada;
+# see above for an up-to-date link.
# From Chris Walton (2007-03-01):
# ... the community of Resolute (located on Cornwallis Island in
@@ -3008,10 +3012,21 @@
# 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.
+#
+# Shanks & Pottenger give April 28 for the 1974 spring-forward transition, but
+# Lance Neita writes that Prime Minister Michael Manley decreed it January 5.
+# Assume Neita meant Jan 6 02:00, the same as the US. Neita also writes that
+# Manley's supporters associated this act with Manley's nickname "Joshua"
+# (recall that in the Bible the sun stood still at Joshua's request),
+# and with the Rod of Correction which Manley said he had received from
+# Haile Selassie, Emperor of Ethiopia. See:
+# Neita L. The politician in all of us. Jamaica Observer 2014-09-20
+# http://www.jamaicaobserver.com/columns/The-politician-in-all-of-us_17573647
+#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
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 - EST 1974
-5:00 US E%sT 1984
-5:00 - EST
--- a/jdk/make/data/tzdata/zone.tab Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/data/tzdata/zone.tab Thu Oct 30 13:56:09 2014 -0700
@@ -330,7 +330,8 @@
PF -1732-14934 Pacific/Tahiti Society Islands
PF -0900-13930 Pacific/Marquesas Marquesas Islands
PF -2308-13457 Pacific/Gambier Gambier Islands
-PG -0930+14710 Pacific/Port_Moresby
+PG -0930+14710 Pacific/Port_Moresby most locations
+PG -0613+15534 Pacific/Bougainville Bougainville
PH +1435+12100 Asia/Manila
PK +2452+06703 Asia/Karachi
PL +5215+02100 Europe/Warsaw
--- a/jdk/make/mapfiles/libjava/mapfile-vers Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/mapfiles/libjava/mapfile-vers Thu Oct 30 13:56:09 2014 -0700
@@ -75,6 +75,7 @@
Java_java_io_FileDescriptor_initIDs;
Java_java_io_FileDescriptor_sync;
+ Java_java_io_FileDescriptor_getAppend;
Java_java_io_FileInputStream_available;
Java_java_io_FileInputStream_close0;
Java_java_io_FileInputStream_initIDs;
--- a/jdk/make/profile-includes.txt Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/make/profile-includes.txt Thu Oct 30 13:56:09 2014 -0700
@@ -54,14 +54,12 @@
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm.diz \
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
- calendars.properties \
classlist \
ext/localedata.jar \
ext/meta-index \
ext/sunec.jar \
ext/sunjce_provider.jar \
ext/sunpkcs11.jar \
- hijrah-config-umalqura.properties \
jce.jar \
jsse.jar \
logging.properties \
--- a/jdk/src/java.base/share/classes/java/io/File.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/io/File.java Thu Oct 30 13:56:09 2014 -0700
@@ -1588,7 +1588,7 @@
/**
* A convenience method to set the owner's read permission for this abstract
* pathname. On some platforms it may be possible to start the Java virtual
- * machine with special privileges that allow it to read files that that are
+ * machine with special privileges that allow it to read files that are
* marked as unreadable.
*
* <p>An invocation of this method of the form <tt>file.setReadable(arg)</tt>
--- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java Thu Oct 30 13:56:09 2014 -0700
@@ -26,6 +26,8 @@
package java.io;
import java.nio.channels.FileChannel;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaIOFileDescriptorAccess;
import sun.nio.ch.FileChannelImpl;
@@ -53,16 +55,17 @@
class FileOutputStream extends OutputStream
{
/**
+ * Access to FileDescriptor internals.
+ */
+ private static final JavaIOFileDescriptorAccess fdAccess =
+ SharedSecrets.getJavaIOFileDescriptorAccess();
+
+ /**
* The system dependent file descriptor.
*/
private final FileDescriptor fd;
/**
- * True if the file is opened for append.
- */
- private final boolean append;
-
- /**
* The associated channel, initialized lazily.
*/
private FileChannel channel;
@@ -207,7 +210,6 @@
}
this.fd = new FileDescriptor();
fd.attach(this);
- this.append = append;
this.path = name;
open(name, append);
@@ -245,7 +247,6 @@
security.checkWrite(fdObj);
}
this.fd = fdObj;
- this.append = false;
this.path = null;
fd.attach(this);
@@ -287,7 +288,7 @@
* @exception IOException if an I/O error occurs.
*/
public void write(int b) throws IOException {
- write(b, append);
+ write(b, fdAccess.getAppend(fd));
}
/**
@@ -310,7 +311,7 @@
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
- writeBytes(b, 0, b.length, append);
+ writeBytes(b, 0, b.length, fdAccess.getAppend(fd));
}
/**
@@ -323,7 +324,7 @@
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
- writeBytes(b, off, len, append);
+ writeBytes(b, off, len, fdAccess.getAppend(fd));
}
/**
@@ -395,7 +396,7 @@
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, path, false, true, append, this);
+ channel = FileChannelImpl.open(fd, path, false, true, this);
}
return channel;
}
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java Thu Oct 30 13:56:09 2014 -0700
@@ -44,6 +44,10 @@
super(type, chooseDelegatingForm(target));
}
+ protected DelegatingMethodHandle(MethodType type, LambdaForm form) {
+ super(type, form);
+ }
+
/** Define this to extract the delegated target which supplies the invocation behavior. */
abstract protected MethodHandle getTarget();
@@ -88,14 +92,31 @@
return makeReinvokerForm(target, MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, NF_getTarget);
}
+ static LambdaForm makeReinvokerForm(MethodHandle target,
+ int whichCache,
+ Object constraint,
+ NamedFunction getTargetFn) {
+ String debugString;
+ switch(whichCache) {
+ case MethodTypeForm.LF_REBIND: debugString = "BMH.reinvoke"; break;
+ case MethodTypeForm.LF_DELEGATE: debugString = "MH.delegate"; break;
+ default: debugString = "MH.reinvoke"; break;
+ }
+ // No pre-action needed.
+ return makeReinvokerForm(target, whichCache, constraint, debugString, true, getTargetFn, null);
+ }
/** Create a LF which simply reinvokes a target of the given basic type. */
static LambdaForm makeReinvokerForm(MethodHandle target,
int whichCache,
Object constraint,
- NamedFunction getTargetFn) {
+ String debugString,
+ boolean forceInline,
+ NamedFunction getTargetFn,
+ NamedFunction preActionFn) {
MethodType mtype = target.type().basicType();
boolean customized = (whichCache < 0 ||
mtype.parameterSlotCount() > MethodType.MAX_MH_INVOKER_ARITY);
+ boolean hasPreAction = (preActionFn != null);
LambdaForm form;
if (!customized) {
form = mtype.form().cachedLambdaForm(whichCache);
@@ -105,12 +126,16 @@
final int ARG_BASE = 1;
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
int nameCursor = ARG_LIMIT;
+ final int PRE_ACTION = hasPreAction ? nameCursor++ : -1;
final int NEXT_MH = customized ? -1 : nameCursor++;
final int REINVOKE = nameCursor++;
LambdaForm.Name[] names = LambdaForm.arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
assert(names.length == nameCursor);
names[THIS_DMH] = names[THIS_DMH].withConstraint(constraint);
Object[] targetArgs;
+ if (hasPreAction) {
+ names[PRE_ACTION] = new LambdaForm.Name(preActionFn, names[THIS_DMH]);
+ }
if (customized) {
targetArgs = Arrays.copyOfRange(names, ARG_BASE, ARG_LIMIT, Object[].class);
names[REINVOKE] = new LambdaForm.Name(target, targetArgs); // the invoker is the target itself
@@ -120,20 +145,14 @@
targetArgs[0] = names[NEXT_MH]; // overwrite this MH with next MH
names[REINVOKE] = new LambdaForm.Name(mtype, targetArgs);
}
- String debugString;
- switch(whichCache) {
- case MethodTypeForm.LF_REBIND: debugString = "BMH.reinvoke"; break;
- case MethodTypeForm.LF_DELEGATE: debugString = "MH.delegate"; break;
- default: debugString = "MH.reinvoke"; break;
- }
- form = new LambdaForm(debugString, ARG_LIMIT, names);
+ form = new LambdaForm(debugString, ARG_LIMIT, names, forceInline);
if (!customized) {
form = mtype.form().setCachedLambdaForm(whichCache, form);
}
return form;
}
- private static final NamedFunction NF_getTarget;
+ static final NamedFunction NF_getTarget;
static {
try {
NF_getTarget = new NamedFunction(DelegatingMethodHandle.class
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Thu Oct 30 13:56:09 2014 -0700
@@ -628,8 +628,13 @@
// Mark this method as a compiled LambdaForm
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
- // Force inlining of this invoker method.
- mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
+ if (lambdaForm.forceInline) {
+ // Force inlining of this invoker method.
+ mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
+ } else {
+ mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
+ }
+
// iterate over the form's names, generating bytecode instructions for each
// start iterating at the first name following the arguments
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Thu Oct 30 13:56:09 2014 -0700
@@ -119,6 +119,7 @@
class LambdaForm {
final int arity;
final int result;
+ final boolean forceInline;
@Stable final Name[] names;
final String debugName;
MemberName vmentry; // low-level behavior, or null if not yet prepared
@@ -243,11 +244,16 @@
LambdaForm(String debugName,
int arity, Name[] names, int result) {
+ this(debugName, arity, names, result, true);
+ }
+ LambdaForm(String debugName,
+ int arity, Name[] names, int result, boolean forceInline) {
assert(namesOK(arity, names));
this.arity = arity;
this.result = fixResult(result, names);
this.names = names.clone();
this.debugName = fixDebugName(debugName);
+ this.forceInline = forceInline;
int maxOutArity = normalize();
if (maxOutArity > MethodType.MAX_MH_INVOKER_ARITY) {
// Cannot use LF interpreter on very high arity expressions.
@@ -255,17 +261,23 @@
compileToBytecode();
}
}
-
LambdaForm(String debugName,
int arity, Name[] names) {
- this(debugName,
- arity, names, LAST_RESULT);
+ this(debugName, arity, names, LAST_RESULT, true);
}
-
+ LambdaForm(String debugName,
+ int arity, Name[] names, boolean forceInline) {
+ this(debugName, arity, names, LAST_RESULT, forceInline);
+ }
LambdaForm(String debugName,
Name[] formals, Name[] temps, Name result) {
this(debugName,
- formals.length, buildNames(formals, temps, result), LAST_RESULT);
+ formals.length, buildNames(formals, temps, result), LAST_RESULT, true);
+ }
+ LambdaForm(String debugName,
+ Name[] formals, Name[] temps, Name result, boolean forceInline) {
+ this(debugName,
+ formals.length, buildNames(formals, temps, result), LAST_RESULT, forceInline);
}
private static Name[] buildNames(Name[] formals, Name[] temps, Name result) {
@@ -279,6 +291,10 @@
}
private LambdaForm(String sig) {
+ this(sig, true);
+ }
+
+ private LambdaForm(String sig, boolean forceInline) {
// Make a blank lambda form, which returns a constant zero or null.
// It is used as a template for managing the invocation of similar forms that are non-empty.
// Called only from getPreparedForm.
@@ -287,6 +303,7 @@
this.result = (signatureReturn(sig) == V_TYPE ? -1 : arity);
this.names = buildEmptyNames(arity, sig);
this.debugName = "LF.zero";
+ this.forceInline = forceInline;
assert(nameRefsAreLegal());
assert(isEmpty());
assert(sig.equals(basicTypeSignature())) : sig + " != " + basicTypeSignature();
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Thu Oct 30 13:56:09 2014 -0700
@@ -1438,10 +1438,9 @@
/*non-public*/
void updateForm(LambdaForm newForm) {
if (form == newForm) return;
- assert(this instanceof DirectMethodHandle && this.internalMemberName().isStatic());
- // ISSUE: Should we have a memory fence here?
+ newForm.prepare(); // as in MethodHandle.<init>
UNSAFE.putObject(this, FORM_OFFSET, newForm);
- this.form.prepare(); // as in MethodHandle.<init>
+ UNSAFE.fullFence();
}
private static final long FORM_OFFSET;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.function.Function;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
@@ -713,10 +714,11 @@
LambdaForm form = makeGuardWithTestForm(basicType);
BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
BoundMethodHandle mh;
+
try {
mh = (BoundMethodHandle)
data.constructor().invokeBasic(type, form,
- (Object) test, (Object) target, (Object) fallback);
+ (Object) test, (Object) profile(target), (Object) profile(fallback));
} catch (Throwable ex) {
throw uncaughtException(ex);
}
@@ -724,6 +726,129 @@
return mh;
}
+
+ static
+ MethodHandle profile(MethodHandle target) {
+ if (DONT_INLINE_THRESHOLD >= 0) {
+ return makeBlockInlningWrapper(target);
+ } else {
+ return target;
+ }
+ }
+
+ /**
+ * Block inlining during JIT-compilation of a target method handle if it hasn't been invoked enough times.
+ * Corresponding LambdaForm has @DontInline when compiled into bytecode.
+ */
+ static
+ MethodHandle makeBlockInlningWrapper(MethodHandle target) {
+ LambdaForm lform = PRODUCE_BLOCK_INLINING_FORM.apply(target);
+ return new CountingWrapper(target, lform,
+ PRODUCE_BLOCK_INLINING_FORM, PRODUCE_REINVOKER_FORM,
+ DONT_INLINE_THRESHOLD);
+ }
+
+ /** Constructs reinvoker lambda form which block inlining during JIT-compilation for a particular method handle */
+ private static final Function<MethodHandle, LambdaForm> PRODUCE_BLOCK_INLINING_FORM = new Function<MethodHandle, LambdaForm>() {
+ @Override
+ public LambdaForm apply(MethodHandle target) {
+ return DelegatingMethodHandle.makeReinvokerForm(target,
+ MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, "reinvoker.dontInline", false,
+ DelegatingMethodHandle.NF_getTarget, CountingWrapper.NF_maybeStopCounting);
+ }
+ };
+
+ /** Constructs simple reinvoker lambda form for a particular method handle */
+ private static final Function<MethodHandle, LambdaForm> PRODUCE_REINVOKER_FORM = new Function<MethodHandle, LambdaForm>() {
+ @Override
+ public LambdaForm apply(MethodHandle target) {
+ return DelegatingMethodHandle.makeReinvokerForm(target,
+ MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, DelegatingMethodHandle.NF_getTarget);
+ }
+ };
+
+ /**
+ * Counting method handle. It has 2 states: counting and non-counting.
+ * It is in counting state for the first n invocations and then transitions to non-counting state.
+ * Behavior in counting and non-counting states is determined by lambda forms produced by
+ * countingFormProducer & nonCountingFormProducer respectively.
+ */
+ static class CountingWrapper extends DelegatingMethodHandle {
+ private final MethodHandle target;
+ private int count;
+ private Function<MethodHandle, LambdaForm> countingFormProducer;
+ private Function<MethodHandle, LambdaForm> nonCountingFormProducer;
+ private volatile boolean isCounting;
+
+ private CountingWrapper(MethodHandle target, LambdaForm lform,
+ Function<MethodHandle, LambdaForm> countingFromProducer,
+ Function<MethodHandle, LambdaForm> nonCountingFormProducer,
+ int count) {
+ super(target.type(), lform);
+ this.target = target;
+ this.count = count;
+ this.countingFormProducer = countingFromProducer;
+ this.nonCountingFormProducer = nonCountingFormProducer;
+ this.isCounting = (count > 0);
+ }
+
+ @Hidden
+ @Override
+ protected MethodHandle getTarget() {
+ return target;
+ }
+
+ @Override
+ public MethodHandle asTypeUncached(MethodType newType) {
+ MethodHandle newTarget = target.asType(newType);
+ MethodHandle wrapper;
+ if (isCounting) {
+ LambdaForm lform;
+ lform = countingFormProducer.apply(target);
+ wrapper = new CountingWrapper(newTarget, lform, countingFormProducer, nonCountingFormProducer, DONT_INLINE_THRESHOLD);
+ } else {
+ wrapper = newTarget; // no need for a counting wrapper anymore
+ }
+ return (asTypeCache = wrapper);
+ }
+
+ boolean countDown() {
+ if (count <= 0) {
+ // Try to limit number of updates. MethodHandle.updateForm() doesn't guarantee LF update visibility.
+ if (isCounting) {
+ isCounting = false;
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ --count;
+ return false;
+ }
+ }
+
+ @Hidden
+ static void maybeStopCounting(Object o1) {
+ CountingWrapper wrapper = (CountingWrapper) o1;
+ if (wrapper.countDown()) {
+ // Reached invocation threshold. Replace counting behavior with a non-counting one.
+ LambdaForm lform = wrapper.nonCountingFormProducer.apply(wrapper.target);
+ lform.compileToBytecode(); // speed up warmup by avoiding LF interpretation again after transition
+ wrapper.updateForm(lform);
+ }
+ }
+
+ static final NamedFunction NF_maybeStopCounting;
+ static {
+ Class<?> THIS_CLASS = CountingWrapper.class;
+ try {
+ NF_maybeStopCounting = new NamedFunction(THIS_CLASS.getDeclaredMethod("maybeStopCounting", Object.class));
+ } catch (ReflectiveOperationException ex) {
+ throw newInternalError(ex);
+ }
+ }
+ }
+
static
LambdaForm makeGuardWithTestForm(MethodType basicType) {
LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_GWT);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Thu Oct 30 13:56:09 2014 -0700
@@ -47,10 +47,11 @@
static final boolean TRACE_METHOD_LINKAGE;
static final boolean USE_LAMBDA_FORM_EDITOR;
static final int COMPILE_THRESHOLD;
+ static final int DONT_INLINE_THRESHOLD;
static final int PROFILE_LEVEL;
static {
- final Object[] values = { false, false, false, false, false, null, null };
+ final Object[] values = new Object[8];
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
@@ -59,7 +60,8 @@
values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE");
values[4] = Boolean.getBoolean("java.lang.invoke.MethodHandle.USE_LF_EDITOR");
values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 30);
- values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
+ values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30);
+ values[7] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0);
return null;
}
});
@@ -69,7 +71,8 @@
TRACE_METHOD_LINKAGE = (Boolean) values[3];
USE_LAMBDA_FORM_EDITOR = (Boolean) values[4];
COMPILE_THRESHOLD = (Integer) values[5];
- PROFILE_LEVEL = (Integer) values[6];
+ DONT_INLINE_THRESHOLD = (Integer) values[6];
+ PROFILE_LEVEL = (Integer) values[7];
}
/** Tell if any of the debugging switches are turned on.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java Thu Oct 30 13:56:09 2014 -0700
@@ -63,24 +63,25 @@
final @Stable LambdaForm[] lambdaForms;
// Indexes into lambdaForms:
static final int
- LF_INVVIRTUAL = 0, // DMH invokeVirtual
- LF_INVSTATIC = 1,
- LF_INVSPECIAL = 2,
- LF_NEWINVSPECIAL = 3,
- LF_INVINTERFACE = 4,
- LF_INVSTATIC_INIT = 5, // DMH invokeStatic with <clinit> barrier
- LF_INTERPRET = 6, // LF interpreter
- LF_REBIND = 7, // BoundMethodHandle
- LF_DELEGATE = 8, // DelegatingMethodHandle
- LF_EX_LINKER = 9, // invokeExact_MT (for invokehandle)
- LF_EX_INVOKER = 10, // MHs.invokeExact
- LF_GEN_LINKER = 11, // generic invoke_MT (for invokehandle)
- LF_GEN_INVOKER = 12, // generic MHs.invoke
- LF_CS_LINKER = 13, // linkToCallSite_CS
- LF_MH_LINKER = 14, // linkToCallSite_MH
- LF_GWC = 15, // guardWithCatch (catchException)
- LF_GWT = 16, // guardWithTest
- LF_LIMIT = 17;
+ LF_INVVIRTUAL = 0, // DMH invokeVirtual
+ LF_INVSTATIC = 1,
+ LF_INVSPECIAL = 2,
+ LF_NEWINVSPECIAL = 3,
+ LF_INVINTERFACE = 4,
+ LF_INVSTATIC_INIT = 5, // DMH invokeStatic with <clinit> barrier
+ LF_INTERPRET = 6, // LF interpreter
+ LF_REBIND = 7, // BoundMethodHandle
+ LF_DELEGATE = 8, // DelegatingMethodHandle
+ LF_DELEGATE_BLOCK_INLINING = 9, // Counting DelegatingMethodHandle w/ @DontInline
+ LF_EX_LINKER = 10, // invokeExact_MT (for invokehandle)
+ LF_EX_INVOKER = 11, // MHs.invokeExact
+ LF_GEN_LINKER = 12, // generic invoke_MT (for invokehandle)
+ LF_GEN_INVOKER = 13, // generic MHs.invoke
+ LF_CS_LINKER = 14, // linkToCallSite_CS
+ LF_MH_LINKER = 15, // linkToCallSite_MH
+ LF_GWC = 16, // guardWithCatch (catchException)
+ LF_GWT = 17, // guardWithTest
+ LF_LIMIT = 18;
/** Return the type corresponding uniquely (1-1) to this MT-form.
* It might have any primitive returns or arguments, but will have no references except Object.
--- a/jdk/src/java.base/share/classes/java/nio/Buffer.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/Buffer.java Thu Oct 30 13:56:09 2014 -0700
@@ -239,7 +239,7 @@
* @throws IllegalArgumentException
* If the preconditions on <tt>newPosition</tt> do not hold
*/
- public final Buffer position(int newPosition) {
+ public Buffer position(int newPosition) {
if ((newPosition > limit) || (newPosition < 0))
throw new IllegalArgumentException();
position = newPosition;
@@ -270,7 +270,7 @@
* @throws IllegalArgumentException
* If the preconditions on <tt>newLimit</tt> do not hold
*/
- public final Buffer limit(int newLimit) {
+ public Buffer limit(int newLimit) {
if ((newLimit > capacity) || (newLimit < 0))
throw new IllegalArgumentException();
limit = newLimit;
@@ -284,7 +284,7 @@
*
* @return This buffer
*/
- public final Buffer mark() {
+ public Buffer mark() {
mark = position;
return this;
}
@@ -300,7 +300,7 @@
* @throws InvalidMarkException
* If the mark has not been set
*/
- public final Buffer reset() {
+ public Buffer reset() {
int m = mark;
if (m < 0)
throw new InvalidMarkException();
@@ -325,7 +325,7 @@
*
* @return This buffer
*/
- public final Buffer clear() {
+ public Buffer clear() {
position = 0;
limit = capacity;
mark = -1;
@@ -353,7 +353,7 @@
*
* @return This buffer
*/
- public final Buffer flip() {
+ public Buffer flip() {
limit = position;
position = 0;
mark = -1;
@@ -375,7 +375,7 @@
*
* @return This buffer
*/
- public final Buffer rewind() {
+ public Buffer rewind() {
position = 0;
mark = -1;
return this;
--- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java Thu Oct 30 13:56:09 2014 -0700
@@ -208,4 +208,76 @@
private native boolean isLoaded0(long address, long length, int pageCount);
private native void load0(long address, long length);
private native void force0(FileDescriptor fd, long address, long length);
+
+ // -- Covariant return type overrides
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer position(int newPosition) {
+ super.position(newPosition);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer limit(int newLimit) {
+ super.limit(newLimit);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer mark() {
+ super.mark();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer reset() {
+ super.reset();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer clear() {
+ super.clear();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer flip() {
+ super.flip();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public final MappedByteBuffer rewind() {
+ super.rewind();
+ return this;
+ }
}
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template Thu Oct 30 13:56:09 2014 -0700
@@ -1025,6 +1025,106 @@
return offset;
}
+ // -- Covariant return type overrides
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer position(int newPosition) {
+ super.position(newPosition);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer limit(int newLimit) {
+ super.limit(newLimit);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer mark() {
+ super.mark();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer reset() {
+ super.reset();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer clear() {
+ super.clear();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer flip() {
+ super.flip();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.9
+ */
+ @Override
+ public
+#if[!byte]
+ final
+#end[!byte]
+ $Type$Buffer rewind() {
+ super.rewind();
+ return this;
+ }
+
/**
* Compacts this buffer <i>(optional operation)</i>.
*
--- a/jdk/src/java.base/share/classes/java/nio/file/FileStore.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileStore.java Thu Oct 30 13:56:09 2014 -0700
@@ -208,7 +208,7 @@
* @param attribute
* the attribute to read
- * @return the attribute value; {@code null} may be a valid for some
+ * @return the attribute value; {@code null} may be valid for some
* attributes
*
* @throws UnsupportedOperationException
--- a/jdk/src/java.base/share/classes/java/nio/file/attribute/package-info.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/nio/file/attribute/package-info.java Thu Oct 30 13:56:09 2014 -0700
@@ -51,7 +51,7 @@
* <p> An attribute view provides a read-only or updatable view of the non-opaque
* values, or <em>metadata</em>, associated with objects in a file system.
* The {@link java.nio.file.attribute.FileAttributeView} interface is
- * extended by several other interfaces that views to specific sets of file
+ * extended by several other interfaces that provide views to specific sets of file
* attributes. {@code FileAttributeViews} are selected by invoking the {@link
* java.nio.file.Files#getFileAttributeView} method with a
* <em>type-token</em> to identify the required view. Views can also be identified
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Thu Oct 30 13:56:09 2014 -0700
@@ -61,13 +61,14 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.security.AccessController;
-import java.security.PrivilegedActionException;
+import java.security.PrivilegedAction;
import java.time.Clock;
import java.time.DateTimeException;
import java.time.Instant;
@@ -145,29 +146,8 @@
* property resource that defines the {@code ID}, the {@code calendar type},
* the start of the calendar, the alignment with the
* ISO calendar, and the length of each month for a range of years.
- * The variants are identified in the {@code calendars.properties} file.
- * The new properties are prefixed with {@code "calendars.hijrah."}:
- * <table cellpadding="2" border="0" summary="Configuration of Hijrah Calendar Variants">
- * <thead>
- * <tr class="tableSubHeadingColor">
- * <th class="colFirst" align="left">Property Name</th>
- * <th class="colFirst" align="left">Property value</th>
- * <th class="colLast" align="left">Description </th>
- * </tr>
- * </thead>
- * <tbody>
- * <tr class="altColor">
- * <td>calendars.hijrah.{ID}</td>
- * <td>The property resource defining the {@code {ID}} variant</td>
- * <td>The property resource is located with the {@code calendars.properties} file</td>
- * </tr>
- * <tr class="rowColor">
- * <td>calendars.hijrah.{ID}.type</td>
- * <td>The calendar type</td>
- * <td>LDML defines the calendar type names</td>
- * </tr>
- * </tbody>
- * </table>
+ * The variants are loaded by HijrahChronology as a resource from
+ * hijrah-config-<calendar type>.properties.
* <p>
* The Hijrah property resource is a set of properties that describe the calendar.
* The syntax is defined by {@code java.util.Properties#load(Reader)}.
@@ -279,91 +259,41 @@
* Computed by {@link #createEpochMonths}.
*/
private transient int maxYearLength;
- /**
- * A reference to the properties stored in
- * ${java.home}/lib/calendars.properties
- */
- private final transient static Properties calendarProperties;
/**
- * Prefix of property names for Hijrah calendar variants.
+ * Prefix of resource names for Hijrah calendar variants.
*/
- private static final String PROP_PREFIX = "calendar.hijrah.";
- /**
- * Suffix of property names containing the calendar type of a variant.
- */
- private static final String PROP_TYPE_SUFFIX = ".type";
+ private static final String RESOURCE_PREFIX = "hijrah-config-";
/**
- * Static initialization of the predefined calendars found in the
- * lib/calendars.properties file.
+ * Suffix of resource names for Hijrah calendar variants.
+ */
+ private static final String RESOURCE_SUFFIX = ".properties";
+
+ /**
+ * Static initialization of the built-in calendars.
+ * The data is not loaded until it is used.
*/
static {
- try {
- calendarProperties = sun.util.calendar.BaseCalendar.getCalendarProperties();
- } catch (IOException ioe) {
- throw new InternalError("Can't initialize lib/calendars.properties", ioe);
- }
-
- try {
- INSTANCE = new HijrahChronology("Hijrah-umalqura");
- // Register it by its aliases
- AbstractChronology.registerChrono(INSTANCE, "Hijrah");
- AbstractChronology.registerChrono(INSTANCE, "islamic");
- } catch (DateTimeException ex) {
- // Absence of Hijrah calendar is fatal to initializing this class.
- PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono");
- logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex);
- throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause());
- }
- registerVariants();
+ INSTANCE = new HijrahChronology("Hijrah-umalqura", "islamic-umalqura");
+ // Register it by its aliases
+ AbstractChronology.registerChrono(INSTANCE, "Hijrah");
+ AbstractChronology.registerChrono(INSTANCE, "islamic");
}
/**
- * For each Hijrah variant listed, create the HijrahChronology and register it.
- * Exceptions during initialization are logged but otherwise ignored.
+ * Create a HijrahChronology for the named variant and type.
+ *
+ * @param id the id of the calendar
+ * @param calType the typeId of the calendar
+ * @throws IllegalArgumentException if the id or typeId is empty
*/
- private static void registerVariants() {
- for (String name : calendarProperties.stringPropertyNames()) {
- if (name.startsWith(PROP_PREFIX)) {
- String id = name.substring(PROP_PREFIX.length());
- if (id.indexOf('.') >= 0) {
- continue; // no name or not a simple name of a calendar
- }
- if (id.equals(INSTANCE.getId())) {
- continue; // do not duplicate the default
- }
- try {
- // Create and register the variant
- HijrahChronology chrono = new HijrahChronology(id);
- AbstractChronology.registerChrono(chrono);
- } catch (DateTimeException ex) {
- // Log error and continue
- PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono");
- logger.severe("Unable to initialize Hijrah calendar: " + id, ex);
- }
- }
- }
- }
-
- /**
- * Create a HijrahChronology for the named variant.
- * The resource and calendar type are retrieved from properties
- * in the {@code calendars.properties}.
- * The property names are {@code "calendar.hijrah." + id}
- * and {@code "calendar.hijrah." + id + ".type"}
- * @param id the id of the calendar
- * @throws DateTimeException if the calendar type is missing from the properties file.
- * @throws IllegalArgumentException if the id is empty
- */
- private HijrahChronology(String id) throws DateTimeException {
+ private HijrahChronology(String id, String calType) {
if (id.isEmpty()) {
throw new IllegalArgumentException("calendar id is empty");
}
- String propName = PROP_PREFIX + id + PROP_TYPE_SUFFIX;
- String calType = calendarProperties.getProperty(propName);
- if (calType == null || calType.isEmpty()) {
- throw new DateTimeException("calendarType is missing or empty for: " + propName);
+ if (calType.isEmpty()) {
+ throw new IllegalArgumentException("calendar typeId is empty");
}
this.typeId = id;
this.calendarType = calType;
@@ -866,30 +796,26 @@
/**
* Return the configuration properties from the resource.
* <p>
- * The default location of the variant configuration resource is:
+ * The location of the variant configuration resource is:
* <pre>
- * "$java.home/lib/" + resource-name
+ * "/java/time/chrono/hijrah-config-" + calendarType + ".properties"
* </pre>
*
- * @param resource the name of the calendar property resource
+ * @param calendarType the calendarType of the calendar variant
* @return a Properties containing the properties read from the resource.
* @throws Exception if access to the property resource fails
*/
- private static Properties readConfigProperties(final String resource) throws Exception {
- try {
- return AccessController
- .doPrivileged((java.security.PrivilegedExceptionAction<Properties>)
- () -> {
- String libDir = System.getProperty("java.home") + File.separator + "lib";
- File file = new File(libDir, resource);
- Properties props = new Properties();
- try (InputStream is = new FileInputStream(file)) {
- props.load(is);
- }
- return props;
- });
- } catch (PrivilegedActionException pax) {
- throw pax.getException();
+ private Properties readConfigProperties(final String calendarType) throws Exception {
+ String resourceName = RESOURCE_PREFIX + calendarType + RESOURCE_SUFFIX;
+ PrivilegedAction<InputStream> getResourceAction = () -> HijrahChronology.class.getResourceAsStream(resourceName);
+ FilePermission perm = new FilePermission("<<ALL FILES>>", "read");
+ try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm)) {
+ if (is == null) {
+ throw new RuntimeException("Hijrah calendar resource not found: /java/time/chrono/" + resourceName);
+ }
+ Properties props = new Properties();
+ props.load(is);
+ return props;
}
}
@@ -906,9 +832,7 @@
*/
private void loadCalendarData() {
try {
- String resourceName = calendarProperties.getProperty(PROP_PREFIX + typeId);
- Objects.requireNonNull(resourceName, "Resource missing for calendar: " + PROP_PREFIX + typeId);
- Properties props = readConfigProperties(resourceName);
+ Properties props = readConfigProperties(calendarType);
Map<Integer, int[]> years = new HashMap<>();
int minYear = Integer.MAX_VALUE;
@@ -937,7 +861,7 @@
default:
try {
// Everything else is either a year or invalid
- int year = Integer.valueOf(key);
+ int year = Integer.parseInt(key);
int[] months = parseMonths((String) entry.getValue());
years.put(year, months);
maxYear = Math.max(maxYear, year);
@@ -1045,7 +969,7 @@
}
for (int i = 0; i < 12; i++) {
try {
- months[i] = Integer.valueOf(numbers[i]);
+ months[i] = Integer.parseInt(numbers[i]);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("bad key: " + numbers[i]);
}
@@ -1067,9 +991,9 @@
throw new IllegalArgumentException("date must be yyyy-MM-dd");
}
int[] ymd = new int[3];
- ymd[0] = Integer.valueOf(string.substring(0, 4));
- ymd[1] = Integer.valueOf(string.substring(5, 7));
- ymd[2] = Integer.valueOf(string.substring(8, 10));
+ ymd[0] = Integer.parseInt(string, 0, 4, 10);
+ ymd[1] = Integer.parseInt(string, 5, 7, 10);
+ ymd[2] = Integer.parseInt(string, 8, 10, 10);
return ymd;
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("date must be yyyy-MM-dd", ex);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/time/chrono/hijrah-config-islamic-umalqura.properties Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,369 @@
+# 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.
+#
+# This properties file defines a Hijrah calendar variant.
+#
+# Fields:
+#
+# <version> ::= 'version' '=' <version string>
+# <id> ::= 'id' '=' <id string>
+# <type> ::= 'type' '=' <type string>
+# <iso-start> ::= 'iso-start' '=' <start date in the ISO calendar>
+# <year> ::= <yyyy> '=' <nn nn nn nn nn nn nn nn nn nn nn nn>
+#
+# version ... (Required)
+#
+# id ... (Required)
+# Identifies the Java Chronology
+#
+# type ... (Required)
+# Identifies the type of calendar in the standard calendar ID scheme
+# iso-start ... (Required)
+# Specifies the corresponding ISO date to the first Hijrah day
+# in the defined range of dates
+#
+# year ... (Required)
+# Number of days for each month of a Hijrah year
+# * Each line defines a year. The years must be in chronological
+# order and no gap is allowed.
+# * Each line is in the form indicated above. <yyyy> is a Hijrah year and
+# nn is the number of days for a month listed in the order of the months.
+# * Each year must have 12 months.
+# * Each month should be 29 or 30 days long.
+# * There must be one or more space characters between the months.
+#
+
+# Version of this definition
+version=1.8.0_1
+
+# Java chronology ID
+id=Hijrah-umalqura
+
+# Standard calendar type specification
+type=islamic-umalqura
+
+# defines the corresponding ISO date to the earliest Hijrah date
+iso-start=1882-11-12
+
+# 1 2 3 4 5 6 7 8 9 10 11 12
+1300=30 29 30 29 30 29 30 29 30 29 30 29
+1301=30 30 29 30 29 30 29 30 29 30 29 29
+1302=30 30 30 29 30 30 29 29 30 29 29 30
+1303=29 30 30 29 30 30 29 30 29 30 29 29
+1304=29 30 30 29 30 30 30 29 30 29 30 29
+1305=29 29 30 30 29 30 30 29 30 30 29 29
+1306=30 29 30 29 30 29 30 29 30 30 29 30
+1307=29 30 29 30 29 30 29 30 29 30 29 30
+1308=29 30 30 29 30 29 30 29 30 29 29 30
+1309=29 30 30 30 30 29 29 30 29 29 30 29
+1310=30 29 30 30 30 29 30 29 30 29 29 30
+1311=29 30 29 30 30 30 29 30 29 30 29 29
+1312=30 29 30 29 30 30 29 30 30 29 30 29
+1313=29 30 29 30 29 30 29 30 30 30 29 29
+1314=30 30 29 30 29 29 30 29 30 30 29 30
+1315=29 30 30 29 30 29 29 30 29 30 29 30
+1316=29 30 30 30 29 30 29 29 30 29 30 29
+1317=30 29 30 30 29 30 29 30 29 30 29 29
+1318=30 29 30 30 29 30 30 29 30 29 30 29
+1319=29 30 29 30 30 29 30 29 30 30 29 30
+1320=29 30 29 29 30 29 30 29 30 30 30 29
+1321=30 29 30 29 29 30 29 29 30 30 30 30
+1322=29 30 29 30 29 29 29 30 29 30 30 30
+1323=29 30 30 29 30 29 29 29 30 29 30 30
+1324=29 30 30 29 30 29 30 29 29 30 29 30
+1325=30 29 30 29 30 30 29 30 29 30 29 30
+1326=29 29 30 29 30 30 29 30 29 30 30 29
+1327=30 29 29 30 29 30 29 30 30 29 30 30
+1328=29 30 29 29 30 29 29 30 30 30 29 30
+1329=30 29 30 29 29 30 29 29 30 30 29 30
+1330=30 30 29 30 29 29 30 29 29 30 30 29
+1331=30 30 29 30 30 29 29 30 29 30 29 30
+1332=29 30 29 30 30 29 30 29 30 30 29 29
+1333=30 29 29 30 30 29 30 30 29 30 30 29
+1334=29 29 30 29 30 29 30 30 30 29 30 29
+1335=30 29 30 29 29 30 29 30 30 29 30 30
+1336=29 30 29 30 29 29 30 29 30 29 30 30
+1337=30 29 30 29 30 29 29 30 29 30 29 30
+1338=29 30 30 29 30 30 29 29 30 29 30 29
+1339=30 29 30 29 30 30 30 29 30 29 29 30
+1340=29 29 30 29 30 30 30 30 29 30 29 29
+1341=30 29 29 30 29 30 30 30 29 30 30 29
+1342=29 29 30 29 30 29 30 30 29 30 30 29
+1343=30 29 29 30 29 30 29 30 29 30 30 29
+1344=30 29 30 29 30 30 29 29 30 29 30 29
+1345=30 29 30 30 30 29 30 29 29 30 29 29
+1346=30 29 30 30 30 30 29 30 29 29 30 29
+1347=29 30 29 30 30 30 29 30 30 29 29 30
+1348=29 29 30 29 30 30 29 30 30 30 29 29
+1349=30 29 29 30 29 30 30 29 30 30 29 30
+1350=29 30 29 30 29 30 29 29 30 30 29 30
+1351=30 29 30 29 30 29 30 29 29 30 29 30
+1352=30 29 30 30 29 30 29 30 29 29 30 29
+1353=30 29 30 30 30 29 30 29 29 30 29 30
+1354=29 30 29 30 30 29 30 30 29 30 29 29
+1355=30 29 29 30 30 29 30 30 29 30 30 29
+1356=29 30 29 30 29 30 29 30 29 30 30 30
+1357=29 29 30 29 30 29 29 30 29 30 30 30
+1358=29 30 29 30 29 30 29 29 30 29 30 30
+1359=29 30 30 29 30 29 30 29 29 29 30 30
+1360=29 30 30 30 29 30 29 30 29 29 30 29
+1361=30 29 30 30 29 30 30 29 29 30 29 30
+1362=29 30 29 30 29 30 30 29 30 29 30 29
+1363=30 29 30 29 30 29 30 29 30 29 30 30
+1364=29 30 29 30 29 29 30 29 30 29 30 30
+1365=30 30 29 29 30 29 29 30 29 30 29 30
+1366=30 30 29 30 29 30 29 29 30 29 30 29
+1367=30 30 29 30 30 29 30 29 29 30 29 30
+1368=29 30 29 30 30 30 29 29 30 29 30 29
+1369=30 29 30 29 30 30 29 30 29 30 30 29
+1370=30 29 29 30 29 30 29 30 29 30 30 30
+1371=29 30 29 29 30 29 30 29 30 29 30 30
+1372=30 29 29 30 29 30 29 29 30 29 30 30
+1373=30 29 30 29 30 29 30 29 29 30 29 30
+1374=30 29 30 30 29 30 29 30 29 29 30 29
+1375=30 29 30 30 29 30 30 29 30 29 30 29
+1376=29 30 29 30 29 30 30 30 29 30 29 30
+1377=29 29 30 29 29 30 30 30 29 30 30 29
+1378=30 29 29 29 30 29 30 30 29 30 30 30
+1379=29 30 29 29 29 30 29 30 30 29 30 30
+1380=29 30 29 30 29 30 29 30 29 30 29 30
+1381=29 30 29 30 30 29 30 29 30 29 29 30
+1382=29 30 29 30 30 29 30 30 29 30 29 29
+1383=30 29 29 30 30 30 29 30 30 29 30 29
+1384=29 30 29 29 30 30 29 30 30 30 29 30
+1385=29 29 30 29 29 30 30 29 30 30 30 29
+1386=30 29 29 30 29 29 30 30 29 30 30 29
+1387=30 29 30 29 30 29 30 29 30 29 30 29
+1388=30 30 29 30 29 30 29 30 29 30 29 29
+1389=30 30 29 30 30 29 30 30 29 29 30 29
+1390=29 30 29 30 30 30 29 30 29 30 29 30
+1391=29 29 30 29 30 30 29 30 30 29 30 29
+1392=30 29 29 30 29 30 29 30 30 29 30 30
+1393=29 30 29 29 30 29 30 29 30 29 30 30
+1394=30 29 30 29 29 30 29 30 29 30 29 30
+1395=30 29 30 30 29 30 29 29 30 29 29 30
+1396=30 29 30 30 29 30 30 29 29 30 29 29
+1397=30 29 30 30 29 30 30 30 29 29 29 30
+1398=29 30 29 30 30 29 30 30 29 30 29 29
+1399=30 29 30 29 30 29 30 30 29 30 29 30
+1400=30 29 30 29 29 30 29 30 29 30 29 30
+1401=30 30 29 30 29 29 30 29 29 30 29 30
+1402=30 30 30 29 30 29 29 30 29 29 30 29
+1403=30 30 30 29 30 30 29 29 30 29 29 30
+1404=29 30 30 29 30 30 29 30 29 30 29 29
+1405=30 29 30 29 30 30 30 29 30 29 29 30
+1406=30 29 29 30 29 30 30 29 30 29 30 30
+1407=29 30 29 29 30 29 30 29 30 29 30 30
+1408=30 29 30 29 30 29 29 30 29 29 30 30
+1409=30 30 29 30 29 30 29 29 30 29 29 30
+1410=30 30 29 30 30 29 30 29 29 30 29 29
+1411=30 30 29 30 30 29 30 30 29 29 30 29
+1412=30 29 30 29 30 29 30 30 30 29 29 30
+1413=29 30 29 29 30 29 30 30 30 29 30 29
+1414=30 29 30 29 29 30 29 30 30 29 30 30
+1415=29 30 29 30 29 29 30 29 30 29 30 30
+1416=30 29 30 29 30 29 29 30 29 30 29 30
+1417=30 29 30 30 29 29 30 29 30 29 30 29
+1418=30 29 30 30 29 30 29 30 29 30 29 30
+1419=29 30 29 30 29 30 29 30 30 30 29 29
+1420=29 30 29 29 30 29 30 30 30 30 29 30
+1421=29 29 30 29 29 29 30 30 30 30 29 30
+1422=30 29 29 30 29 29 29 30 30 30 29 30
+1423=30 29 30 29 30 29 29 30 29 30 29 30
+1424=30 29 30 30 29 30 29 29 30 29 30 29
+1425=30 29 30 30 29 30 29 30 30 29 30 29
+1426=29 30 29 30 29 30 30 29 30 30 29 30
+1427=29 29 30 29 30 29 30 30 29 30 30 29
+1428=30 29 29 30 29 29 30 30 30 29 30 30
+1429=29 30 29 29 30 29 29 30 30 29 30 30
+1430=29 30 30 29 29 30 29 30 29 30 29 30
+1431=29 30 30 29 30 29 30 29 30 29 29 30
+1432=29 30 30 30 29 30 29 30 29 30 29 29
+1433=30 29 30 30 29 30 30 29 30 29 30 29
+1434=29 30 29 30 29 30 30 29 30 30 29 29
+1435=30 29 30 29 30 29 30 29 30 30 29 30
+1436=29 30 29 30 29 30 29 30 29 30 29 30
+1437=30 29 30 30 29 29 30 29 30 29 29 30
+1438=30 29 30 30 30 29 29 30 29 29 30 29
+1439=30 29 30 30 30 29 30 29 30 29 29 30
+1440=29 30 29 30 30 30 29 30 29 30 29 29
+1441=30 29 30 29 30 30 29 30 30 29 30 29
+1442=29 30 29 30 29 30 29 30 30 29 30 29
+1443=30 29 30 29 30 29 30 29 30 29 30 30
+1444=29 30 29 30 30 29 29 30 29 30 29 30
+1445=29 30 30 30 29 30 29 29 30 29 29 30
+1446=29 30 30 30 29 30 30 29 29 30 29 29
+1447=30 29 30 30 30 29 30 29 30 29 30 29
+1448=29 30 29 30 30 29 30 30 29 30 29 30
+1449=29 29 30 29 30 29 30 30 29 30 30 29
+1450=30 29 30 29 29 30 29 30 29 30 30 29
+1451=30 30 30 29 29 30 29 29 30 30 29 30
+1452=30 29 30 30 29 29 30 29 29 30 29 30
+1453=30 29 30 30 29 30 29 30 29 29 30 29
+1454=30 29 30 30 29 30 30 29 30 29 30 29
+1455=29 30 29 30 30 29 30 29 30 30 29 30
+1456=29 29 30 29 30 29 30 29 30 30 30 29
+1457=30 29 29 30 29 29 30 29 30 30 30 30
+1458=29 30 29 29 30 29 29 30 29 30 30 30
+1459=29 30 30 29 29 30 29 29 30 29 30 30
+1460=29 30 30 29 30 29 30 29 29 30 29 30
+1461=29 30 30 29 30 29 30 29 30 30 29 29
+1462=30 29 30 29 30 30 29 30 29 30 30 29
+1463=29 30 29 30 29 30 29 30 30 30 29 30
+1464=29 30 29 29 30 29 29 30 30 30 29 30
+1465=30 29 30 29 29 30 29 29 30 30 29 30
+1466=30 30 29 30 29 29 29 30 29 30 30 29
+1467=30 30 29 30 30 29 29 30 29 30 29 30
+1468=29 30 29 30 30 29 30 29 30 29 30 29
+1469=29 30 29 30 30 29 30 30 29 30 29 30
+1470=29 29 30 29 30 30 29 30 30 29 30 29
+1471=30 29 29 30 29 30 29 30 30 29 30 30
+1472=29 30 29 29 30 29 30 29 30 30 29 30
+1473=29 30 29 30 30 29 29 30 29 30 29 30
+1474=29 30 30 29 30 30 29 29 30 29 30 29
+1475=29 30 30 29 30 30 30 29 29 30 29 29
+1476=30 29 30 29 30 30 30 29 30 29 30 29
+1477=29 30 29 29 30 30 30 30 29 30 29 30
+1478=29 29 30 29 30 29 30 30 29 30 30 29
+1479=30 29 29 30 29 30 29 30 29 30 30 29
+1480=30 29 30 29 30 29 30 29 30 29 30 29
+1481=30 29 30 30 29 30 29 30 29 30 29 29
+1482=30 29 30 30 30 30 29 30 29 29 30 29
+1483=29 30 29 30 30 30 29 30 30 29 29 30
+1484=29 29 30 29 30 30 30 29 30 29 30 29
+1485=30 29 29 30 29 30 30 29 30 30 29 30
+1486=29 30 29 29 30 29 30 29 30 30 29 30
+1487=30 29 30 29 30 29 29 30 29 30 29 30
+1488=30 29 30 30 29 30 29 29 30 29 30 29
+1489=30 29 30 30 30 29 30 29 29 30 29 30
+1490=29 30 29 30 30 29 30 30 29 29 30 29
+1491=30 29 29 30 30 29 30 30 29 30 29 30
+1492=29 30 29 29 30 30 29 30 29 30 30 29
+1493=30 29 30 29 30 29 29 30 29 30 30 30
+1494=29 30 29 30 29 30 29 29 29 30 30 30
+1495=29 30 30 29 30 29 29 30 29 29 30 30
+1496=29 30 30 30 29 30 29 29 30 29 29 30
+1497=30 29 30 30 29 30 29 30 29 30 29 30
+1498=29 30 29 30 29 30 30 29 30 29 30 29
+1499=30 29 30 29 29 30 30 29 30 29 30 30
+1500=29 30 29 30 29 29 30 29 30 29 30 30
+1501=30 29 30 29 30 29 29 29 30 29 30 30
+1502=30 30 29 30 29 30 29 29 29 30 30 29
+1503=30 30 29 30 30 29 30 29 29 29 30 30
+1504=29 30 29 30 30 30 29 29 30 29 30 29
+1505=30 29 30 29 30 30 29 30 29 30 30 29
+1506=29 30 29 29 30 30 29 30 30 29 30 30
+1507=29 29 30 29 29 30 30 29 30 29 30 30
+1508=30 29 29 30 29 30 29 29 30 29 30 30
+1509=30 29 30 29 30 29 30 29 29 30 29 30
+1510=30 29 30 30 29 30 29 30 29 29 30 29
+1511=30 29 30 30 29 30 30 29 30 29 29 30
+1512=29 30 29 30 29 30 30 30 29 30 29 30
+1513=29 29 29 30 29 30 30 30 29 30 30 29
+1514=30 29 29 29 30 29 30 30 29 30 30 30
+1515=29 29 30 29 29 30 29 30 30 29 30 30
+1516=29 30 29 30 29 29 30 29 30 29 30 30
+1517=29 30 29 30 29 30 30 29 29 30 29 30
+1518=29 30 29 30 30 29 30 30 29 30 29 29
+1519=30 29 29 30 30 30 29 30 30 29 30 29
+1520=29 30 29 29 30 30 30 29 30 30 29 30
+1521=29 29 29 30 29 30 30 29 30 30 29 30
+1522=30 29 29 29 30 29 30 30 29 30 30 29
+1523=30 29 30 29 30 29 30 29 29 30 30 29
+1524=30 30 29 30 29 30 29 30 29 29 30 29
+1525=30 30 29 30 30 29 30 29 30 29 29 30
+1526=29 30 29 30 30 30 29 30 29 30 29 29
+1527=30 29 30 29 30 30 29 30 30 29 30 29
+1528=30 29 29 30 29 30 29 30 30 29 30 30
+1529=29 30 29 29 30 29 30 29 30 29 30 30
+1530=29 30 30 29 29 30 29 30 29 29 30 30
+1531=29 30 30 30 29 29 30 29 30 29 29 30
+1532=29 30 30 30 29 30 30 29 29 29 30 29
+1533=30 29 30 30 30 29 30 29 30 29 29 30
+1534=29 30 29 30 30 29 30 30 29 29 30 29
+1535=30 29 30 29 30 29 30 30 29 30 29 30
+1536=29 30 29 30 29 30 29 30 29 30 29 30
+1537=30 29 30 30 29 29 30 29 29 30 29 30
+1538=30 30 29 30 30 29 29 30 29 29 30 29
+1539=30 30 30 29 30 30 29 29 30 29 29 30
+1540=29 30 30 29 30 30 29 30 29 29 30 29
+1541=30 29 30 29 30 30 30 29 30 29 29 30
+1542=29 30 29 30 29 30 30 29 30 29 30 30
+1543=29 30 29 29 30 29 30 29 30 29 30 30
+1544=30 29 30 29 29 30 29 30 29 30 29 30
+1545=30 30 29 30 29 29 30 29 30 29 29 30
+1546=30 30 29 30 29 30 29 30 29 30 29 29
+1547=30 30 29 30 30 29 30 29 30 29 30 29
+1548=30 29 29 30 30 29 30 30 29 30 29 30
+1549=29 30 29 29 30 29 30 30 30 29 30 29
+1550=30 29 30 29 29 29 30 30 30 29 30 30
+1551=29 30 29 29 30 29 29 30 30 29 30 30
+1552=30 29 30 29 29 30 29 29 30 30 29 30
+1553=30 29 30 29 30 29 30 29 30 29 30 29
+1554=30 29 30 29 30 30 29 30 29 30 29 30
+1555=29 29 30 29 30 30 29 30 30 29 30 29
+1556=30 29 29 30 29 30 29 30 30 30 29 30
+1557=29 30 29 29 29 30 29 30 30 30 30 29
+1558=30 29 30 29 29 29 30 29 30 30 30 29
+1559=30 30 29 29 30 29 29 30 30 29 30 29
+1560=30 30 29 30 29 30 29 30 29 30 29 30
+1561=29 30 30 29 30 29 30 30 29 29 30 29
+1562=29 30 30 29 30 29 30 30 30 29 29 30
+1563=29 30 29 29 30 29 30 30 30 29 30 29
+1564=30 29 30 29 29 30 29 30 30 30 29 30
+1565=29 30 29 30 29 29 30 29 30 30 29 30
+1566=30 29 30 29 30 29 29 30 29 30 29 30
+1567=30 29 30 30 29 30 29 30 29 29 30 29
+1568=30 29 30 30 30 29 30 29 30 29 29 29
+1569=30 29 30 30 30 29 30 30 29 30 29 29
+1570=29 30 29 30 30 29 30 30 30 29 29 30
+1571=29 29 30 29 30 30 29 30 30 29 30 29
+1572=30 29 29 30 29 30 29 30 30 29 30 29
+1573=30 29 30 30 29 30 29 29 30 29 30 29
+1574=30 30 29 30 30 29 30 29 29 30 29 29
+1575=30 30 30 29 30 30 29 30 29 29 29 30
+1576=29 30 30 29 30 30 30 29 30 29 29 29
+1577=30 29 30 30 29 30 30 29 30 29 30 29
+1578=29 30 29 30 29 30 30 29 30 30 29 30
+1579=29 30 29 30 29 29 30 30 29 30 29 30
+1580=29 30 30 29 30 29 29 30 29 30 29 30
+1581=30 30 29 30 29 30 29 29 30 29 30 29
+1582=30 30 29 30 30 29 30 29 30 29 29 29
+1583=30 30 29 30 30 30 29 30 29 30 29 29
+1584=29 30 30 29 30 30 29 30 30 29 30 29
+1585=29 30 29 30 29 30 29 30 30 29 30 30
+1586=29 29 30 29 30 29 29 30 30 30 29 30
+1587=29 30 30 29 29 29 30 29 30 29 30 30
+1588=30 29 30 30 29 29 29 30 29 30 29 30
+1589=30 29 30 30 29 30 29 29 30 29 30 29
+1590=30 29 30 30 30 29 29 30 29 30 29 30
+1591=29 30 29 30 30 29 30 29 30 29 30 29
+1592=30 29 30 29 30 29 30 29 30 30 30 29
+1593=30 29 29 30 29 29 30 29 30 30 30 29
+1594=30 30 29 29 30 29 29 29 30 30 30 30
+1595=29 30 29 30 29 29 30 29 29 30 30 30
+1596=29 30 30 29 30 29 29 30 29 30 29 30
+1597=29 30 30 29 30 29 30 29 30 29 30 29
+1598=30 29 30 29 30 30 29 30 29 30 30 29
+1599=29 30 29 30 29 30 29 30 30 30 29 30
+1600=29 29 30 29 30 29 29 30 30 30 29 30
--- a/jdk/src/java.base/share/classes/java/util/Collection.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Collection.java Thu Oct 30 13:56:09 2014 -0700
@@ -518,7 +518,7 @@
* <p>The default implementation should be overridden by subclasses that
* can return a more efficient spliterator. In order to
* preserve expected laziness behavior for the {@link #stream()} and
- * {@link #parallelStream()}} methods, spliterators should either have the
+ * {@link #parallelStream()} methods, spliterators should either have the
* characteristic of {@code IMMUTABLE} or {@code CONCURRENT}, or be
* <em><a href="Spliterator.html#binding">late-binding</a></em>.
* If none of these is practical, the overriding class should describe the
--- a/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java Thu Oct 30 13:56:09 2014 -0700
@@ -97,8 +97,7 @@
*
* This implementation uses
* sun.util.calendar.LocalGregorianCalendar to perform most of the
- * calendar calculations. LocalGregorianCalendar is configurable
- * and reads <JRE_HOME>/lib/calendars.properties at the start-up.
+ * calendar calculations.
*/
/**
--- a/jdk/src/java.base/share/classes/sun/misc/JavaIOFileDescriptorAccess.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/misc/JavaIOFileDescriptorAccess.java Thu Oct 30 13:56:09 2014 -0700
@@ -33,6 +33,8 @@
public interface JavaIOFileDescriptorAccess {
public void set(FileDescriptor obj, int fd);
public int get(FileDescriptor fd);
+ public void setAppend(FileDescriptor obj, boolean append);
+ public boolean getAppend(FileDescriptor obj);
// Only valid on Windows
public void setHandle(FileDescriptor obj, long handle);
--- a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -44,6 +44,8 @@
import java.util.List;
import sun.misc.Cleaner;
+import sun.misc.JavaIOFileDescriptorAccess;
+import sun.misc.SharedSecrets;
import sun.security.action.GetPropertyAction;
public class FileChannelImpl
@@ -52,6 +54,10 @@
// Memory allocation size for mapping buffers
private static final long allocationGranularity;
+ // Access to FileDispatcher internals
+ private static final JavaIOFileDescriptorAccess fdAccess =
+ SharedSecrets.getJavaIOFileDescriptorAccess();
+
// Used to make native read and write calls
private final FileDispatcher nd;
@@ -61,7 +67,6 @@
// File access mode (immutable)
private final boolean writable;
private final boolean readable;
- private final boolean append;
// Required to prevent finalization of creating stream (immutable)
private final Object parent;
@@ -77,31 +82,23 @@
private final Object positionLock = new Object();
private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
- boolean writable, boolean append, Object parent)
+ boolean writable, Object parent)
{
this.fd = fd;
this.readable = readable;
this.writable = writable;
- this.append = append;
this.parent = parent;
this.path = path;
- this.nd = new FileDispatcherImpl(append);
+ this.nd = new FileDispatcherImpl();
}
- // Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
+ // Used by FileInputStream.getChannel(), FileOutputStream.getChannel
+ // and RandomAccessFile.getChannel()
public static FileChannel open(FileDescriptor fd, String path,
boolean readable, boolean writable,
Object parent)
{
- return new FileChannelImpl(fd, path, readable, writable, false, parent);
- }
-
- // Used by FileOutputStream.getChannel
- public static FileChannel open(FileDescriptor fd, String path,
- boolean readable, boolean writable,
- boolean append, Object parent)
- {
- return new FileChannelImpl(fd, path, readable, writable, append, parent);
+ return new FileChannelImpl(fd, path, readable, writable, parent);
}
private void ensureOpen() throws IOException {
@@ -109,7 +106,6 @@
throw new ClosedChannelException();
}
-
// -- Standard channel operations --
protected void implCloseChannel() throws IOException {
@@ -258,6 +254,7 @@
ti = threads.add();
if (!isOpen())
return 0;
+ boolean append = fdAccess.getAppend(fd);
do {
// in append-mode then position is advanced to end before writing
p = (append) ? nd.size(fd) : position0(fd, -1);
@@ -284,7 +281,7 @@
if (!isOpen())
return null;
do {
- p = position0(fd, newPosition);
+ p = position0(fd, newPosition);
} while ((p == IOStatus.INTERRUPTED) && isOpen());
return this;
} finally {
--- a/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -247,7 +247,7 @@
return null;
thread = NativeThread.current();
for (;;) {
- n = accept0(this.fd, newfd, isaa);
+ n = accept(this.fd, newfd, isaa);
if ((n == IOStatus.INTERRUPTED) && isOpen())
continue;
break;
@@ -410,6 +410,18 @@
return sb.toString();
}
+ /**
+ * Accept a connection on a socket.
+ *
+ * @implNote Wrap native call to allow instrumentation.
+ */
+ private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+ InetSocketAddress[] isaa)
+ throws IOException
+ {
+ return accept0(ssfd, newfd, isaa);
+ }
+
// -- Native methods --
// Accepts a new connection, setting the given file descriptor to refer to
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherBox.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherBox.java Thu Oct 30 13:56:09 2014 -0700
@@ -560,7 +560,7 @@
+ newLen);
hd.encodeBuffer(
- (ByteBuffer)bb.duplicate().position(pos), System.out);
+ bb.duplicate().position(pos), System.out);
} catch (IOException e) { }
}
@@ -790,7 +790,7 @@
// The padding data should be filled with the padding length value.
int[] results = checkPadding(
- (ByteBuffer)bb.duplicate().position(offset + newLen),
+ bb.duplicate().position(offset + newLen),
(byte)(padLen & 0xFF));
if (protocolVersion.v >= ProtocolVersion.TLS10.v) {
if (results[0] != 0) { // padding data has invalid bytes
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EngineInputRecord.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EngineInputRecord.java Thu Oct 30 13:56:09 2014 -0700
@@ -349,8 +349,7 @@
/*
* Copy data out of buffer, it's ready to go.
*/
- ByteBuffer netBB = (ByteBuffer)
- (ByteBuffer.allocate(len).put(buf, 0, len).flip());
+ ByteBuffer netBB = ByteBuffer.allocate(len).put(buf, 0, len).flip();
engine.writer.putOutboundDataSync(netBB);
}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EngineOutputRecord.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/EngineOutputRecord.java Thu Oct 30 13:56:09 2014 -0700
@@ -113,9 +113,7 @@
/*
* Copy data out of buffer, it's ready to go.
*/
- ByteBuffer netBB = (ByteBuffer)
- ByteBuffer.allocate(len).put(buf, off, len).flip();
-
+ ByteBuffer netBB = ByteBuffer.allocate(len).put(buf, off, len).flip();
writer.putOutboundData(netBB);
}
--- a/jdk/src/java.base/share/classes/sun/util/calendar/CalendarSystem.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/util/calendar/CalendarSystem.java Thu Oct 30 13:56:09 2014 -0700
@@ -177,44 +177,6 @@
return (cs == null) ? cal : cs;
}
- /**
- * Returns a {@link Properties} loaded from lib/calendars.properties.
- *
- * @return a {@link Properties} loaded from lib/calendars.properties
- * @throws IOException if an error occurred when reading from the input stream
- * @throws IllegalArgumentException if the input stream contains any malformed
- * Unicode escape sequences
- */
- public static Properties getCalendarProperties() throws IOException {
- Properties calendarProps = null;
- try {
- String homeDir = AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("java.home"));
- final String fname = homeDir + File.separator + "lib" + File.separator
- + "calendars.properties";
- calendarProps = AccessController.doPrivileged(new PrivilegedExceptionAction<Properties>() {
- @Override
- public Properties run() throws IOException {
- Properties props = new Properties();
- try (FileInputStream fis = new FileInputStream(fname)) {
- props.load(fis);
- }
- return props;
- }
- });
- } catch (PrivilegedActionException e) {
- Throwable cause = e.getCause();
- if (cause instanceof IOException) {
- throw (IOException) cause;
- } else if (cause instanceof IllegalArgumentException) {
- throw (IllegalArgumentException) cause;
- }
- // Should not happen
- throw new InternalError(cause);
- }
- return calendarProps;
- }
-
//////////////////////////////// Calendar API //////////////////////////////////
/**
--- a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/java.base/share/conf/calendars.properties Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# Copyright (c) 2005, 2014, 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.
-#
-
-#
-# Hijrah calendars
-#
-calendar.hijrah.Hijrah-umalqura: hijrah-config-umalqura.properties
-calendar.hijrah.Hijrah-umalqura.type: islamic-umalqura
--- a/jdk/src/java.base/share/conf/hijrah-config-umalqura.properties Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,369 +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. 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.
-#
-# This properties file defines a Hijrah calendar variant.
-#
-# Fields:
-#
-# <version> ::= 'version' '=' <version string>
-# <id> ::= 'id' '=' <id string>
-# <type> ::= 'type' '=' <type string>
-# <iso-start> ::= 'iso-start' '=' <start date in the ISO calendar>
-# <year> ::= <yyyy> '=' <nn nn nn nn nn nn nn nn nn nn nn nn>
-#
-# version ... (Required)
-#
-# id ... (Required)
-# Identifies the Java Chronology
-#
-# type ... (Required)
-# Identifies the type of calendar in the standard calendar ID scheme
-# iso-start ... (Required)
-# Specifies the corresponding ISO date to the first Hijrah day
-# in the defined range of dates
-#
-# year ... (Required)
-# Number of days for each month of a Hijrah year
-# * Each line defines a year. The years must be in chronological
-# order and no gap is allowed.
-# * Each line is in the form indicated above. <yyyy> is a Hijrah year and
-# nn is the number of days for a month listed in the order of the months.
-# * Each year must have 12 months.
-# * Each month should be 29 or 30 days long.
-# * There must be one or more space characters between the months.
-#
-
-# Version of this definition
-version=1.8.0_1
-
-# Java chronology ID
-id=Hijrah-umalqura
-
-# Standard calendar type specification
-type=islamic-umalqura
-
-# defines the corresponding ISO date to the earliest Hijrah date
-iso-start=1882-11-12
-
-# 1 2 3 4 5 6 7 8 9 10 11 12
-1300=30 29 30 29 30 29 30 29 30 29 30 29
-1301=30 30 29 30 29 30 29 30 29 30 29 29
-1302=30 30 30 29 30 30 29 29 30 29 29 30
-1303=29 30 30 29 30 30 29 30 29 30 29 29
-1304=29 30 30 29 30 30 30 29 30 29 30 29
-1305=29 29 30 30 29 30 30 29 30 30 29 29
-1306=30 29 30 29 30 29 30 29 30 30 29 30
-1307=29 30 29 30 29 30 29 30 29 30 29 30
-1308=29 30 30 29 30 29 30 29 30 29 29 30
-1309=29 30 30 30 30 29 29 30 29 29 30 29
-1310=30 29 30 30 30 29 30 29 30 29 29 30
-1311=29 30 29 30 30 30 29 30 29 30 29 29
-1312=30 29 30 29 30 30 29 30 30 29 30 29
-1313=29 30 29 30 29 30 29 30 30 30 29 29
-1314=30 30 29 30 29 29 30 29 30 30 29 30
-1315=29 30 30 29 30 29 29 30 29 30 29 30
-1316=29 30 30 30 29 30 29 29 30 29 30 29
-1317=30 29 30 30 29 30 29 30 29 30 29 29
-1318=30 29 30 30 29 30 30 29 30 29 30 29
-1319=29 30 29 30 30 29 30 29 30 30 29 30
-1320=29 30 29 29 30 29 30 29 30 30 30 29
-1321=30 29 30 29 29 30 29 29 30 30 30 30
-1322=29 30 29 30 29 29 29 30 29 30 30 30
-1323=29 30 30 29 30 29 29 29 30 29 30 30
-1324=29 30 30 29 30 29 30 29 29 30 29 30
-1325=30 29 30 29 30 30 29 30 29 30 29 30
-1326=29 29 30 29 30 30 29 30 29 30 30 29
-1327=30 29 29 30 29 30 29 30 30 29 30 30
-1328=29 30 29 29 30 29 29 30 30 30 29 30
-1329=30 29 30 29 29 30 29 29 30 30 29 30
-1330=30 30 29 30 29 29 30 29 29 30 30 29
-1331=30 30 29 30 30 29 29 30 29 30 29 30
-1332=29 30 29 30 30 29 30 29 30 30 29 29
-1333=30 29 29 30 30 29 30 30 29 30 30 29
-1334=29 29 30 29 30 29 30 30 30 29 30 29
-1335=30 29 30 29 29 30 29 30 30 29 30 30
-1336=29 30 29 30 29 29 30 29 30 29 30 30
-1337=30 29 30 29 30 29 29 30 29 30 29 30
-1338=29 30 30 29 30 30 29 29 30 29 30 29
-1339=30 29 30 29 30 30 30 29 30 29 29 30
-1340=29 29 30 29 30 30 30 30 29 30 29 29
-1341=30 29 29 30 29 30 30 30 29 30 30 29
-1342=29 29 30 29 30 29 30 30 29 30 30 29
-1343=30 29 29 30 29 30 29 30 29 30 30 29
-1344=30 29 30 29 30 30 29 29 30 29 30 29
-1345=30 29 30 30 30 29 30 29 29 30 29 29
-1346=30 29 30 30 30 30 29 30 29 29 30 29
-1347=29 30 29 30 30 30 29 30 30 29 29 30
-1348=29 29 30 29 30 30 29 30 30 30 29 29
-1349=30 29 29 30 29 30 30 29 30 30 29 30
-1350=29 30 29 30 29 30 29 29 30 30 29 30
-1351=30 29 30 29 30 29 30 29 29 30 29 30
-1352=30 29 30 30 29 30 29 30 29 29 30 29
-1353=30 29 30 30 30 29 30 29 29 30 29 30
-1354=29 30 29 30 30 29 30 30 29 30 29 29
-1355=30 29 29 30 30 29 30 30 29 30 30 29
-1356=29 30 29 30 29 30 29 30 29 30 30 30
-1357=29 29 30 29 30 29 29 30 29 30 30 30
-1358=29 30 29 30 29 30 29 29 30 29 30 30
-1359=29 30 30 29 30 29 30 29 29 29 30 30
-1360=29 30 30 30 29 30 29 30 29 29 30 29
-1361=30 29 30 30 29 30 30 29 29 30 29 30
-1362=29 30 29 30 29 30 30 29 30 29 30 29
-1363=30 29 30 29 30 29 30 29 30 29 30 30
-1364=29 30 29 30 29 29 30 29 30 29 30 30
-1365=30 30 29 29 30 29 29 30 29 30 29 30
-1366=30 30 29 30 29 30 29 29 30 29 30 29
-1367=30 30 29 30 30 29 30 29 29 30 29 30
-1368=29 30 29 30 30 30 29 29 30 29 30 29
-1369=30 29 30 29 30 30 29 30 29 30 30 29
-1370=30 29 29 30 29 30 29 30 29 30 30 30
-1371=29 30 29 29 30 29 30 29 30 29 30 30
-1372=30 29 29 30 29 30 29 29 30 29 30 30
-1373=30 29 30 29 30 29 30 29 29 30 29 30
-1374=30 29 30 30 29 30 29 30 29 29 30 29
-1375=30 29 30 30 29 30 30 29 30 29 30 29
-1376=29 30 29 30 29 30 30 30 29 30 29 30
-1377=29 29 30 29 29 30 30 30 29 30 30 29
-1378=30 29 29 29 30 29 30 30 29 30 30 30
-1379=29 30 29 29 29 30 29 30 30 29 30 30
-1380=29 30 29 30 29 30 29 30 29 30 29 30
-1381=29 30 29 30 30 29 30 29 30 29 29 30
-1382=29 30 29 30 30 29 30 30 29 30 29 29
-1383=30 29 29 30 30 30 29 30 30 29 30 29
-1384=29 30 29 29 30 30 29 30 30 30 29 30
-1385=29 29 30 29 29 30 30 29 30 30 30 29
-1386=30 29 29 30 29 29 30 30 29 30 30 29
-1387=30 29 30 29 30 29 30 29 30 29 30 29
-1388=30 30 29 30 29 30 29 30 29 30 29 29
-1389=30 30 29 30 30 29 30 30 29 29 30 29
-1390=29 30 29 30 30 30 29 30 29 30 29 30
-1391=29 29 30 29 30 30 29 30 30 29 30 29
-1392=30 29 29 30 29 30 29 30 30 29 30 30
-1393=29 30 29 29 30 29 30 29 30 29 30 30
-1394=30 29 30 29 29 30 29 30 29 30 29 30
-1395=30 29 30 30 29 30 29 29 30 29 29 30
-1396=30 29 30 30 29 30 30 29 29 30 29 29
-1397=30 29 30 30 29 30 30 30 29 29 29 30
-1398=29 30 29 30 30 29 30 30 29 30 29 29
-1399=30 29 30 29 30 29 30 30 29 30 29 30
-1400=30 29 30 29 29 30 29 30 29 30 29 30
-1401=30 30 29 30 29 29 30 29 29 30 29 30
-1402=30 30 30 29 30 29 29 30 29 29 30 29
-1403=30 30 30 29 30 30 29 29 30 29 29 30
-1404=29 30 30 29 30 30 29 30 29 30 29 29
-1405=30 29 30 29 30 30 30 29 30 29 29 30
-1406=30 29 29 30 29 30 30 29 30 29 30 30
-1407=29 30 29 29 30 29 30 29 30 29 30 30
-1408=30 29 30 29 30 29 29 30 29 29 30 30
-1409=30 30 29 30 29 30 29 29 30 29 29 30
-1410=30 30 29 30 30 29 30 29 29 30 29 29
-1411=30 30 29 30 30 29 30 30 29 29 30 29
-1412=30 29 30 29 30 29 30 30 30 29 29 30
-1413=29 30 29 29 30 29 30 30 30 29 30 29
-1414=30 29 30 29 29 30 29 30 30 29 30 30
-1415=29 30 29 30 29 29 30 29 30 29 30 30
-1416=30 29 30 29 30 29 29 30 29 30 29 30
-1417=30 29 30 30 29 29 30 29 30 29 30 29
-1418=30 29 30 30 29 30 29 30 29 30 29 30
-1419=29 30 29 30 29 30 29 30 30 30 29 29
-1420=29 30 29 29 30 29 30 30 30 30 29 30
-1421=29 29 30 29 29 29 30 30 30 30 29 30
-1422=30 29 29 30 29 29 29 30 30 30 29 30
-1423=30 29 30 29 30 29 29 30 29 30 29 30
-1424=30 29 30 30 29 30 29 29 30 29 30 29
-1425=30 29 30 30 29 30 29 30 30 29 30 29
-1426=29 30 29 30 29 30 30 29 30 30 29 30
-1427=29 29 30 29 30 29 30 30 29 30 30 29
-1428=30 29 29 30 29 29 30 30 30 29 30 30
-1429=29 30 29 29 30 29 29 30 30 29 30 30
-1430=29 30 30 29 29 30 29 30 29 30 29 30
-1431=29 30 30 29 30 29 30 29 30 29 29 30
-1432=29 30 30 30 29 30 29 30 29 30 29 29
-1433=30 29 30 30 29 30 30 29 30 29 30 29
-1434=29 30 29 30 29 30 30 29 30 30 29 29
-1435=30 29 30 29 30 29 30 29 30 30 29 30
-1436=29 30 29 30 29 30 29 30 29 30 29 30
-1437=30 29 30 30 29 29 30 29 30 29 29 30
-1438=30 29 30 30 30 29 29 30 29 29 30 29
-1439=30 29 30 30 30 29 30 29 30 29 29 30
-1440=29 30 29 30 30 30 29 30 29 30 29 29
-1441=30 29 30 29 30 30 29 30 30 29 30 29
-1442=29 30 29 30 29 30 29 30 30 29 30 29
-1443=30 29 30 29 30 29 30 29 30 29 30 30
-1444=29 30 29 30 30 29 29 30 29 30 29 30
-1445=29 30 30 30 29 30 29 29 30 29 29 30
-1446=29 30 30 30 29 30 30 29 29 30 29 29
-1447=30 29 30 30 30 29 30 29 30 29 30 29
-1448=29 30 29 30 30 29 30 30 29 30 29 30
-1449=29 29 30 29 30 29 30 30 29 30 30 29
-1450=30 29 30 29 29 30 29 30 29 30 30 29
-1451=30 30 30 29 29 30 29 29 30 30 29 30
-1452=30 29 30 30 29 29 30 29 29 30 29 30
-1453=30 29 30 30 29 30 29 30 29 29 30 29
-1454=30 29 30 30 29 30 30 29 30 29 30 29
-1455=29 30 29 30 30 29 30 29 30 30 29 30
-1456=29 29 30 29 30 29 30 29 30 30 30 29
-1457=30 29 29 30 29 29 30 29 30 30 30 30
-1458=29 30 29 29 30 29 29 30 29 30 30 30
-1459=29 30 30 29 29 30 29 29 30 29 30 30
-1460=29 30 30 29 30 29 30 29 29 30 29 30
-1461=29 30 30 29 30 29 30 29 30 30 29 29
-1462=30 29 30 29 30 30 29 30 29 30 30 29
-1463=29 30 29 30 29 30 29 30 30 30 29 30
-1464=29 30 29 29 30 29 29 30 30 30 29 30
-1465=30 29 30 29 29 30 29 29 30 30 29 30
-1466=30 30 29 30 29 29 29 30 29 30 30 29
-1467=30 30 29 30 30 29 29 30 29 30 29 30
-1468=29 30 29 30 30 29 30 29 30 29 30 29
-1469=29 30 29 30 30 29 30 30 29 30 29 30
-1470=29 29 30 29 30 30 29 30 30 29 30 29
-1471=30 29 29 30 29 30 29 30 30 29 30 30
-1472=29 30 29 29 30 29 30 29 30 30 29 30
-1473=29 30 29 30 30 29 29 30 29 30 29 30
-1474=29 30 30 29 30 30 29 29 30 29 30 29
-1475=29 30 30 29 30 30 30 29 29 30 29 29
-1476=30 29 30 29 30 30 30 29 30 29 30 29
-1477=29 30 29 29 30 30 30 30 29 30 29 30
-1478=29 29 30 29 30 29 30 30 29 30 30 29
-1479=30 29 29 30 29 30 29 30 29 30 30 29
-1480=30 29 30 29 30 29 30 29 30 29 30 29
-1481=30 29 30 30 29 30 29 30 29 30 29 29
-1482=30 29 30 30 30 30 29 30 29 29 30 29
-1483=29 30 29 30 30 30 29 30 30 29 29 30
-1484=29 29 30 29 30 30 30 29 30 29 30 29
-1485=30 29 29 30 29 30 30 29 30 30 29 30
-1486=29 30 29 29 30 29 30 29 30 30 29 30
-1487=30 29 30 29 30 29 29 30 29 30 29 30
-1488=30 29 30 30 29 30 29 29 30 29 30 29
-1489=30 29 30 30 30 29 30 29 29 30 29 30
-1490=29 30 29 30 30 29 30 30 29 29 30 29
-1491=30 29 29 30 30 29 30 30 29 30 29 30
-1492=29 30 29 29 30 30 29 30 29 30 30 29
-1493=30 29 30 29 30 29 29 30 29 30 30 30
-1494=29 30 29 30 29 30 29 29 29 30 30 30
-1495=29 30 30 29 30 29 29 30 29 29 30 30
-1496=29 30 30 30 29 30 29 29 30 29 29 30
-1497=30 29 30 30 29 30 29 30 29 30 29 30
-1498=29 30 29 30 29 30 30 29 30 29 30 29
-1499=30 29 30 29 29 30 30 29 30 29 30 30
-1500=29 30 29 30 29 29 30 29 30 29 30 30
-1501=30 29 30 29 30 29 29 29 30 29 30 30
-1502=30 30 29 30 29 30 29 29 29 30 30 29
-1503=30 30 29 30 30 29 30 29 29 29 30 30
-1504=29 30 29 30 30 30 29 29 30 29 30 29
-1505=30 29 30 29 30 30 29 30 29 30 30 29
-1506=29 30 29 29 30 30 29 30 30 29 30 30
-1507=29 29 30 29 29 30 30 29 30 29 30 30
-1508=30 29 29 30 29 30 29 29 30 29 30 30
-1509=30 29 30 29 30 29 30 29 29 30 29 30
-1510=30 29 30 30 29 30 29 30 29 29 30 29
-1511=30 29 30 30 29 30 30 29 30 29 29 30
-1512=29 30 29 30 29 30 30 30 29 30 29 30
-1513=29 29 29 30 29 30 30 30 29 30 30 29
-1514=30 29 29 29 30 29 30 30 29 30 30 30
-1515=29 29 30 29 29 30 29 30 30 29 30 30
-1516=29 30 29 30 29 29 30 29 30 29 30 30
-1517=29 30 29 30 29 30 30 29 29 30 29 30
-1518=29 30 29 30 30 29 30 30 29 30 29 29
-1519=30 29 29 30 30 30 29 30 30 29 30 29
-1520=29 30 29 29 30 30 30 29 30 30 29 30
-1521=29 29 29 30 29 30 30 29 30 30 29 30
-1522=30 29 29 29 30 29 30 30 29 30 30 29
-1523=30 29 30 29 30 29 30 29 29 30 30 29
-1524=30 30 29 30 29 30 29 30 29 29 30 29
-1525=30 30 29 30 30 29 30 29 30 29 29 30
-1526=29 30 29 30 30 30 29 30 29 30 29 29
-1527=30 29 30 29 30 30 29 30 30 29 30 29
-1528=30 29 29 30 29 30 29 30 30 29 30 30
-1529=29 30 29 29 30 29 30 29 30 29 30 30
-1530=29 30 30 29 29 30 29 30 29 29 30 30
-1531=29 30 30 30 29 29 30 29 30 29 29 30
-1532=29 30 30 30 29 30 30 29 29 29 30 29
-1533=30 29 30 30 30 29 30 29 30 29 29 30
-1534=29 30 29 30 30 29 30 30 29 29 30 29
-1535=30 29 30 29 30 29 30 30 29 30 29 30
-1536=29 30 29 30 29 30 29 30 29 30 29 30
-1537=30 29 30 30 29 29 30 29 29 30 29 30
-1538=30 30 29 30 30 29 29 30 29 29 30 29
-1539=30 30 30 29 30 30 29 29 30 29 29 30
-1540=29 30 30 29 30 30 29 30 29 29 30 29
-1541=30 29 30 29 30 30 30 29 30 29 29 30
-1542=29 30 29 30 29 30 30 29 30 29 30 30
-1543=29 30 29 29 30 29 30 29 30 29 30 30
-1544=30 29 30 29 29 30 29 30 29 30 29 30
-1545=30 30 29 30 29 29 30 29 30 29 29 30
-1546=30 30 29 30 29 30 29 30 29 30 29 29
-1547=30 30 29 30 30 29 30 29 30 29 30 29
-1548=30 29 29 30 30 29 30 30 29 30 29 30
-1549=29 30 29 29 30 29 30 30 30 29 30 29
-1550=30 29 30 29 29 29 30 30 30 29 30 30
-1551=29 30 29 29 30 29 29 30 30 29 30 30
-1552=30 29 30 29 29 30 29 29 30 30 29 30
-1553=30 29 30 29 30 29 30 29 30 29 30 29
-1554=30 29 30 29 30 30 29 30 29 30 29 30
-1555=29 29 30 29 30 30 29 30 30 29 30 29
-1556=30 29 29 30 29 30 29 30 30 30 29 30
-1557=29 30 29 29 29 30 29 30 30 30 30 29
-1558=30 29 30 29 29 29 30 29 30 30 30 29
-1559=30 30 29 29 30 29 29 30 30 29 30 29
-1560=30 30 29 30 29 30 29 30 29 30 29 30
-1561=29 30 30 29 30 29 30 30 29 29 30 29
-1562=29 30 30 29 30 29 30 30 30 29 29 30
-1563=29 30 29 29 30 29 30 30 30 29 30 29
-1564=30 29 30 29 29 30 29 30 30 30 29 30
-1565=29 30 29 30 29 29 30 29 30 30 29 30
-1566=30 29 30 29 30 29 29 30 29 30 29 30
-1567=30 29 30 30 29 30 29 30 29 29 30 29
-1568=30 29 30 30 30 29 30 29 30 29 29 29
-1569=30 29 30 30 30 29 30 30 29 30 29 29
-1570=29 30 29 30 30 29 30 30 30 29 29 30
-1571=29 29 30 29 30 30 29 30 30 29 30 29
-1572=30 29 29 30 29 30 29 30 30 29 30 29
-1573=30 29 30 30 29 30 29 29 30 29 30 29
-1574=30 30 29 30 30 29 30 29 29 30 29 29
-1575=30 30 30 29 30 30 29 30 29 29 29 30
-1576=29 30 30 29 30 30 30 29 30 29 29 29
-1577=30 29 30 30 29 30 30 29 30 29 30 29
-1578=29 30 29 30 29 30 30 29 30 30 29 30
-1579=29 30 29 30 29 29 30 30 29 30 29 30
-1580=29 30 30 29 30 29 29 30 29 30 29 30
-1581=30 30 29 30 29 30 29 29 30 29 30 29
-1582=30 30 29 30 30 29 30 29 30 29 29 29
-1583=30 30 29 30 30 30 29 30 29 30 29 29
-1584=29 30 30 29 30 30 29 30 30 29 30 29
-1585=29 30 29 30 29 30 29 30 30 29 30 30
-1586=29 29 30 29 30 29 29 30 30 30 29 30
-1587=29 30 30 29 29 29 30 29 30 29 30 30
-1588=30 29 30 30 29 29 29 30 29 30 29 30
-1589=30 29 30 30 29 30 29 29 30 29 30 29
-1590=30 29 30 30 30 29 29 30 29 30 29 30
-1591=29 30 29 30 30 29 30 29 30 29 30 29
-1592=30 29 30 29 30 29 30 29 30 30 30 29
-1593=30 29 29 30 29 29 30 29 30 30 30 29
-1594=30 30 29 29 30 29 29 29 30 30 30 30
-1595=29 30 29 30 29 29 30 29 29 30 30 30
-1596=29 30 30 29 30 29 29 30 29 30 29 30
-1597=29 30 30 29 30 29 30 29 30 29 30 29
-1598=30 29 30 29 30 30 29 30 29 30 30 29
-1599=29 30 29 30 29 30 29 30 30 30 29 30
-1600=29 29 30 29 30 29 29 30 30 30 29 30
--- a/jdk/src/java.base/share/native/libjava/io_util.h Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/share/native/libjava/io_util.h Thu Oct 30 13:56:09 2014 -0700
@@ -28,6 +28,7 @@
extern jfieldID IO_fd_fdID;
extern jfieldID IO_handle_fdID;
+extern jfieldID IO_append_fdID;
#ifdef _ALLBSD_SOURCE
#include <fcntl.h>
--- a/jdk/src/java.base/unix/classes/java/io/FileDescriptor.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/classes/java/io/FileDescriptor.java Thu Oct 30 13:56:09 2014 -0700
@@ -52,15 +52,21 @@
private boolean closed;
/**
+ * true, if file is opened for appending.
+ */
+ private boolean append;
+
+ /**
* Constructs an (invalid) FileDescriptor
* object.
*/
- public /**/ FileDescriptor() {
+ public FileDescriptor() {
fd = -1;
}
- private /* */ FileDescriptor(int fd) {
+ private FileDescriptor(int fd) {
this.fd = fd;
+ this.append = getAppend(fd);
}
/**
@@ -149,6 +155,14 @@
return obj.fd;
}
+ public void setAppend(FileDescriptor obj, boolean append) {
+ obj.append = append;
+ }
+
+ public boolean getAppend(FileDescriptor obj) {
+ return obj.append;
+ }
+
public void setHandle(FileDescriptor obj, long handle) {
throw new UnsupportedOperationException();
}
@@ -160,6 +174,11 @@
);
}
+ /**
+ * Returns true, if the file was opened for appending.
+ */
+ private static native boolean getAppend(int fd);
+
/*
* Package private methods to track referents.
* If multiple streams point to the same FileDescriptor, we cycle
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/FileDispatcherImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/FileDispatcherImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -35,10 +35,6 @@
init();
}
- FileDispatcherImpl(boolean append) {
- /* append is ignored */
- }
-
FileDispatcherImpl() {
}
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -141,7 +141,7 @@
Throwable exc = null;
try {
begin();
- int n = accept0(this.fd, newfd, isaa);
+ int n = accept(this.fd, newfd, isaa);
// spurious wakeup, is this possible?
if (n == IOStatus.UNAVAILABLE) {
@@ -277,7 +277,7 @@
try {
begin();
- int n = accept0(this.fd, newfd, isaa);
+ int n = accept(this.fd, newfd, isaa);
if (n == IOStatus.UNAVAILABLE) {
// need calling context when there is security manager as
@@ -332,6 +332,18 @@
}
}
+ /**
+ * Accept a connection on a socket.
+ *
+ * @implNote Wrap native call to allow instrumentation.
+ */
+ private int accept(FileDescriptor ssfd, FileDescriptor newfd,
+ InetSocketAddress[] isaa)
+ throws IOException
+ {
+ return accept0(ssfd, newfd, isaa);
+ }
+
// -- Native methods --
private static native void initIDs();
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java Thu Oct 30 13:56:09 2014 -0700
@@ -134,7 +134,7 @@
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
- return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null);
+ return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, null);
}
/**
@@ -288,6 +288,7 @@
// create java.io.FileDescriptor
FileDescriptor fdObj = new FileDescriptor();
fdAccess.set(fdObj, fd);
+ fdAccess.setAppend(fdObj, flags.append);
return fdObj;
}
}
--- a/jdk/src/java.base/unix/native/libjava/FileDescriptor_md.c Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/native/libjava/FileDescriptor_md.c Thu Oct 30 13:56:09 2014 -0700
@@ -23,6 +23,9 @@
* questions.
*/
+#include <unistd.h>
+#include <fcntl.h>
+
#include "jvm.h"
#include "io_util_md.h"
@@ -35,6 +38,9 @@
/* field id for jint 'fd' in java.io.FileDescriptor */
jfieldID IO_fd_fdID;
+/* field id for jboolean 'append' in java.io.FileDescriptor */
+jfieldID IO_append_fdID;
+
/**************************************************************
* static methods to store field ID's in initializers
*/
@@ -42,6 +48,7 @@
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I");
+ IO_append_fdID = (*env)->GetFieldID(env, fdClass, "append", "Z");
}
/**************************************************************
@@ -55,3 +62,9 @@
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
}
}
+
+JNIEXPORT jboolean JNICALL
+Java_java_io_FileDescriptor_getAppend(JNIEnv *env, jclass fdClass, jint fd) {
+ int flags = fcntl(fd, F_GETFL);
+ return ((flags & O_APPEND) == 0) ? JNI_FALSE : JNI_TRUE;
+}
--- a/jdk/src/java.base/unix/native/libjava/io_util_md.c Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/unix/native/libjava/io_util_md.c Thu Oct 30 13:56:09 2014 -0700
@@ -107,7 +107,15 @@
#endif
fd = handleOpen(ps, flags, 0666);
if (fd != -1) {
+ jobject fdobj;
+ jboolean append;
SET_FD(this, fd, fid);
+
+ fdobj = (*env)->GetObjectField(env, this, fid);
+ if (fdobj != NULL) {
+ append = (flags & O_APPEND) == 0 ? JNI_FALSE : JNI_TRUE;
+ (*env)->SetBooleanField(env, fdobj, IO_append_fdID, append);
+ }
} else {
throwFileNotFoundException(env, path);
}
--- a/jdk/src/java.base/windows/classes/java/io/FileDescriptor.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/windows/classes/java/io/FileDescriptor.java Thu Oct 30 13:56:09 2014 -0700
@@ -51,6 +51,11 @@
private boolean closed;
/**
+ * true, if file is opened for appending.
+ */
+ private boolean append;
+
+ /**
* Constructs an (invalid) FileDescriptor
* object.
*/
@@ -75,6 +80,14 @@
return obj.fd;
}
+ public void setAppend(FileDescriptor obj, boolean append) {
+ obj.append = append;
+ }
+
+ public boolean getAppend(FileDescriptor obj) {
+ return obj.append;
+ }
+
public void setHandle(FileDescriptor obj, long handle) {
obj.handle = handle;
}
--- a/jdk/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -31,22 +31,14 @@
class FileDispatcherImpl extends FileDispatcher
{
+ private static final JavaIOFileDescriptorAccess fdAccess =
+ SharedSecrets.getJavaIOFileDescriptorAccess();
+
static {
IOUtil.load();
}
- /**
- * Indicates if the dispatcher should first advance the file position
- * to the end of file when writing.
- */
- private final boolean append;
-
- FileDispatcherImpl(boolean append) {
- this.append = append;
- }
-
FileDispatcherImpl() {
- this(false);
}
@Override
@@ -71,7 +63,7 @@
}
int write(FileDescriptor fd, long address, int len) throws IOException {
- return write0(fd, address, len, append);
+ return write0(fd, address, len, fdAccess.getAppend(fd));
}
int pwrite(FileDescriptor fd, long address, int len, long position)
@@ -81,7 +73,7 @@
}
long writev(FileDescriptor fd, long address, int len) throws IOException {
- return writev0(fd, address, len, append);
+ return writev0(fd, address, len, fdAccess.getAppend(fd));
}
int force(FileDescriptor fd, boolean metaData) throws IOException {
@@ -112,8 +104,6 @@
FileDescriptor duplicateForMapping(FileDescriptor fd) throws IOException {
// on Windows we need to keep a handle to the file
- JavaIOFileDescriptorAccess fdAccess =
- SharedSecrets.getJavaIOFileDescriptorAccess();
FileDescriptor result = new FileDescriptor();
long handle = duplicateHandle(fdAccess.getHandle(fd));
fdAccess.setHandle(result, handle);
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsChannelFactory.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsChannelFactory.java Thu Oct 30 13:56:09 2014 -0700
@@ -160,7 +160,7 @@
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
- return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null);
+ return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, null);
}
/**
@@ -339,6 +339,7 @@
// create FileDescriptor and return
FileDescriptor fdObj = new FileDescriptor();
fdAccess.setHandle(fdObj, handle);
+ fdAccess.setAppend(fdObj, flags.append);
return fdObj;
}
}
--- a/jdk/src/java.base/windows/native/libjava/FileDescriptor_md.c Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/windows/native/libjava/FileDescriptor_md.c Thu Oct 30 13:56:09 2014 -0700
@@ -42,6 +42,9 @@
/* field id for jlong 'handle' in java.io.FileDescriptor */
jfieldID IO_handle_fdID;
+/* field id for jboolean 'append' in java.io.FileDescriptor */
+jfieldID IO_append_fdID;
+
/**************************************************************
* static methods to store field IDs in initializers
*/
@@ -50,6 +53,7 @@
Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
CHECK_NULL(IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I"));
CHECK_NULL(IO_handle_fdID = (*env)->GetFieldID(env, fdClass, "handle", "J"));
+ CHECK_NULL(IO_append_fdID = (*env)->GetFieldID(env, fdClass, "append", "Z"));
}
JNIEXPORT jlong JNICALL
--- a/jdk/src/java.base/windows/native/libjava/io_util_md.c Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.base/windows/native/libjava/io_util_md.c Thu Oct 30 13:56:09 2014 -0700
@@ -275,7 +275,15 @@
{
FD h = winFileHandleOpen(env, path, flags);
if (h >= 0) {
+ jobject fdobj;
+ jboolean append;
SET_FD(this, h, fid);
+
+ fdobj = (*env)->GetObjectField(env, this, fid);
+ if (fdobj != NULL) {
+ append = (flags & O_APPEND) == 0 ? JNI_FALSE : JNI_TRUE;
+ (*env)->SetBooleanField(env, fdobj, IO_append_fdID, append);
+ }
}
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java Thu Oct 30 13:56:09 2014 -0700
@@ -62,7 +62,7 @@
if (w <= 0 || h <= 0) return null;
// This could be any kind of icon, so we need to make a buffer for it, draw it and then pass the new image off to appkit.
- final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
final Graphics g = image.getGraphics();
i.paintIcon(null, g, 0, 0);
g.dispose();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java Thu Oct 30 13:56:09 2014 -0700
@@ -129,7 +129,7 @@
};
final BufferedImage image = new BufferedImage(scaledAlertIconSize,
- scaledAlertIconSize, BufferedImage.TYPE_INT_ARGB);
+ scaledAlertIconSize, BufferedImage.TYPE_INT_ARGB_PRE);
final Graphics g = image.getGraphics();
g.drawImage(background, 0, 0,
scaledAlertIconSize, scaledAlertIconSize, null);
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java Thu Oct 30 13:56:09 2014 -0700
@@ -67,11 +67,12 @@
}
static BufferedImage getRadioButtonSizerImage() {
- final BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
+ final BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics g = img.getGraphics();
g.setColor(Color.pink);
g.fillRect(0, 0, 20, 20);
+ g.dispose();
return img;
}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Oct 30 13:56:09 2014 -0700
@@ -676,6 +676,13 @@
@Override // PlatformWindow
public void toFront() {
final long nsWindowPtr = getNSWindowPtr();
+ LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
+ Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
+ if( w != null
+ && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
+ && !lwcToolkit.isApplicationActive()) {
+ lwcToolkit.activateApplicationIgnoringOtherApps();
+ }
updateFocusabilityForAutoRequestFocus(false);
nativePushNSWindowToFront(nsWindowPtr);
updateFocusabilityForAutoRequestFocus(true);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu Oct 30 13:56:09 2014 -0700
@@ -811,6 +811,11 @@
*/
public static native boolean isEmbedded();
+ /*
+ * Activates application ignoring other apps.
+ */
+ public native void activateApplicationIgnoringOtherApps();
+
/************************
* Native methods section
************************/
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m Thu Oct 30 13:56:09 2014 -0700
@@ -606,6 +606,23 @@
return active;
}
+/*
+ * Class: sun_lwawt_macosx_LWCToolkit
+ * Method: activateApplicationIgnoringOtherApps
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_activateApplicationIgnoringOtherApps
+(JNIEnv *env, jclass clazz)
+{
+ JNF_COCOA_ENTER(env);
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+ if(![NSApp isActive]){
+ [NSApp activateIgnoringOtherApps:YES];
+ }
+ }];
+ JNF_COCOA_EXIT(env);
+}
+
/*
* Class: sun_awt_SunToolkit
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/META-INF/services/javax.print.PrintServiceLookup Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,2 @@
+# Provider for Java Print Service
+sun.print.PrintServiceLookupProvider
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/META-INF/services/javax.print.StreamPrintServiceFactory Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,2 @@
+# Provider for Java 2D Stream print services.
+sun.print.PSStreamPrinterFactory
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java Thu Oct 30 13:56:09 2014 -0700
@@ -3696,7 +3696,7 @@
private void writeObject(ObjectOutputStream s) throws IOException {
ObjectOutputStream.PutField f = s.putFields();
f.put("ncomponents", component.size());
- f.put("component", getComponentsSync());
+ f.put("component", component.toArray(EMPTY_ARRAY));
f.put("layoutMgr", layoutMgr);
f.put("dispatcher", dispatcher);
f.put("maxSize", maxSize);
--- a/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java Thu Oct 30 13:56:09 2014 -0700
@@ -48,6 +48,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -1857,7 +1858,13 @@
* returns null.
*/
private static InputStream getStandardProfileInputStream(String fileName) {
- return PCMM.class.getResourceAsStream("profiles/" + fileName);
+ return AccessController.doPrivileged(
+ new PrivilegedAction<InputStream>() {
+ public InputStream run () {
+ return
+ PCMM.class.getResourceAsStream("profiles/" + fileName);
+ }
+ }, null, new FilePermission("<<ALL FILES>>", "read"));
}
/**
--- a/jdk/src/java.desktop/share/classes/javax/swing/BorderFactory.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/BorderFactory.java Thu Oct 30 13:56:09 2014 -0700
@@ -35,7 +35,7 @@
* possible, this factory will hand out references to shared
* <code>Border</code> instances.
* For further information and examples see
- * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.htmll">How
+ * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How
to Use Borders</a>,
* a section in <em>The Java Tutorial</em>.
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Thu Oct 30 13:56:09 2014 -0700
@@ -126,7 +126,7 @@
* that includes double buffering and support for borders.
* For more information see <a
* href="http://www.oracle.com/technetwork/java/painting-140037.html#swing">Painting</a> and
- * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.htmll">How
+ * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How
* to Use Borders</a>,
* both of which are sections in <em>The Java Tutorial</em>.
* </ul>
--- a/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java Thu Oct 30 13:56:09 2014 -0700
@@ -1141,14 +1141,15 @@
/**
* Sets an image to be displayed in the titlebar of this internal frame (usually
* in the top-left corner).
+ * Some look and feels might not support displaying an icon in the titlebar.
+ *
* This image is not the <code>desktopIcon</code> object, which
* is the image displayed in the <code>JDesktop</code> when
* this internal frame is iconified.
*
* Passing <code>null</code> to this function is valid,
- * but the look and feel
- * can choose the
- * appropriate behavior for that situation, such as displaying no icon
+ * but the look and feel can choose the appropriate behavior
+ * for that situation, such as displaying no icon
* or a default icon for the look and feel.
*
* @param icon the <code>Icon</code> to display in the title bar
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java Thu Oct 30 13:56:09 2014 -0700
@@ -325,24 +325,38 @@
}
/**
- * A non-{@code null} border, or non-zero insets, isn't supported, to prevent the geometry
- * of this component from becoming complex enough to inhibit
- * subclassing of {@code LayerUI} class. To create a {@code JLayer} with a border,
- * add it to a {@code JPanel} that has a border.
- * <p>Note: If {@code border} is non-{@code null}, this
- * method will throw an exception as borders are not supported on
- * a {@code JLayer}.
+ * Delegates its functionality to the {@code getView().setBorder(Border)} method,
+ * if the view component is an instance of {@code javax.swing.JComponent},
+ * otherwise this method is a no-op.
*
- * @param border the {@code Border} to set
- * @exception IllegalArgumentException this method is not supported
+ * @param border the border to be rendered for the {@code view} component
+ * @see #getView()
+ * @see javax.swing.JComponent#setBorder(Border)
*/
public void setBorder(Border border) {
- if (border != null) {
- throw new IllegalArgumentException("JLayer.setBorder() not supported");
+ if (view instanceof JComponent) {
+ ((JComponent)view).setBorder(border);
}
}
/**
+ * Delegates its functionality to the {@code getView().getBorder()} method,
+ * if the view component is an instance of {@code javax.swing.JComponent},
+ * otherwise returns {@code null}.
+ *
+ * @return the border object for the {@code view} component
+ * @see #getView()
+ * @see #setBorder
+ * @see javax.swing.JComponent#getBorder()
+ */
+ public Border getBorder() {
+ if (view instanceof JComponent) {
+ return ((JComponent) view).getBorder();
+ }
+ return null;
+ }
+
+ /**
* This method is not supported by {@code JLayer}
* and always throws {@code UnsupportedOperationException}
*
--- a/jdk/src/java.desktop/share/classes/javax/swing/border/Border.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/border/Border.java Thu Oct 30 13:56:09 2014 -0700
@@ -33,7 +33,7 @@
* Interface describing an object capable of rendering a border
* around the edges of a swing component.
* For examples of using borders see
- * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.htmll">How to Use Borders</a>,
+ * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How to Use Borders</a>,
* a section in <em>The Java Tutorial.</em>
* <p>
* In the Swing component set, borders supercede Insets as the
--- a/jdk/src/java.desktop/share/classes/javax/swing/border/package.html Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/border/package.html Thu Oct 30 13:56:09 2014 -0700
@@ -40,10 +40,10 @@
Most of the Swing API is <em>not</em> thread safe.
For details, see
<a
-href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
-target="_top">Threads and Swing</a>,
+href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html"
+target="_top">Concurrency in Swing</a>,
a section in
-<em><a href="http://java.sun.com/docs/books/tutorial/"
+<em><a href="http://docs.oracle.com/javase/tutorial/"
target="_top">The Java Tutorial</a></em>.
@@ -51,7 +51,7 @@
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
- <li><a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html"
+ <li><a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html"
target="_top">How to Use Borders</a>,
a section in <em>The Java Tutorial</em>
</ul>
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java Thu Oct 30 13:56:09 2014 -0700
@@ -33,7 +33,8 @@
import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
-
+import java.util.Enumeration;
+import java.util.HashSet;
/**
* RadioButtonUI implementation for BasicRadioButtonUI
@@ -53,6 +54,8 @@
private final static String propertyPrefix = "RadioButton" + ".";
+ private KeyListener keyListener = null;
+
// ********************************
// Create PLAF
// ********************************
@@ -74,6 +77,7 @@
return radioButtonUI;
}
+ @Override
protected String getPropertyPrefix() {
return propertyPrefix;
}
@@ -81,7 +85,8 @@
// ********************************
// Install PLAF
// ********************************
- protected void installDefaults(AbstractButton b){
+ @Override
+ protected void installDefaults(AbstractButton b) {
super.installDefaults(b);
if(!defaults_initialized) {
icon = UIManager.getIcon(getPropertyPrefix() + "icon");
@@ -92,7 +97,8 @@
// ********************************
// Uninstall PLAF
// ********************************
- protected void uninstallDefaults(AbstractButton b){
+ @Override
+ protected void uninstallDefaults(AbstractButton b) {
super.uninstallDefaults(b);
defaults_initialized = false;
}
@@ -106,6 +112,65 @@
return icon;
}
+ // ********************************
+ // Install Listeners
+ // ********************************
+ @Override
+ protected void installListeners(AbstractButton button) {
+ super.installListeners(button);
+
+ // Only for JRadioButton
+ if (!(button instanceof JRadioButton))
+ return;
+
+ keyListener = createKeyListener();
+ button.addKeyListener(keyListener);
+
+ // Need to get traversal key event
+ button.setFocusTraversalKeysEnabled(false);
+
+ // Map actions to the arrow keys
+ button.getActionMap().put("Previous", new SelectPreviousBtn());
+ button.getActionMap().put("Next", new SelectNextBtn());
+
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke("UP"), "Previous");
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke("DOWN"), "Next");
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke("LEFT"), "Previous");
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ put(KeyStroke.getKeyStroke("RIGHT"), "Next");
+ }
+
+ // ********************************
+ // UnInstall Listeners
+ // ********************************
+ @Override
+ protected void uninstallListeners(AbstractButton button) {
+ super.uninstallListeners(button);
+
+ // Only for JRadioButton
+ if (!(button instanceof JRadioButton))
+ return;
+
+ // Unmap actions from the arrow keys
+ button.getActionMap().remove("Previous");
+ button.getActionMap().remove("Next");
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+ .remove(KeyStroke.getKeyStroke("UP"));
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+ .remove(KeyStroke.getKeyStroke("DOWN"));
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+ .remove(KeyStroke.getKeyStroke("LEFT"));
+ button.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+ .remove(KeyStroke.getKeyStroke("RIGHT"));
+
+ if (keyListener != null) {
+ button.removeKeyListener(keyListener);
+ keyListener = null;
+ }
+ }
/* These Dimensions/Rectangles are allocated once for all
* RadioButtonUI.paint() calls. Re-using rectangles
@@ -121,6 +186,7 @@
/**
* paint the radio button
*/
+ @Override
public synchronized void paint(Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
@@ -217,7 +283,7 @@
* @param textRect bounds
* @param size the size of radio button
*/
- protected void paintFocus(Graphics g, Rectangle textRect, Dimension size){
+ protected void paintFocus(Graphics g, Rectangle textRect, Dimension size) {
}
@@ -235,6 +301,7 @@
/**
* The preferred size of the radio button
*/
+ @Override
public Dimension getPreferredSize(JComponent c) {
if(c.getComponentCount() > 0) {
return null;
@@ -280,4 +347,262 @@
height += prefInsets.top + prefInsets.bottom;
return new Dimension(width, height);
}
+
+ /////////////////////////// Private functions ////////////////////////
+ /**
+ * Creates the key listener to handle tab navigation in JRadioButton Group.
+ */
+ private KeyListener createKeyListener() {
+ if (keyListener == null) {
+ keyListener = new KeyHandler();
+ }
+ return keyListener;
+ }
+
+
+ private boolean isValidRadioButtonObj(Object obj) {
+ return ((obj instanceof JRadioButton) &&
+ ((JRadioButton) obj).isVisible() &&
+ ((JRadioButton) obj).isEnabled());
+ }
+
+ /**
+ * Select radio button based on "Previous" or "Next" operation
+ *
+ * @param event, the event object.
+ * @param next, indicate if it's next one
+ */
+ private void selectRadioButton(ActionEvent event, boolean next) {
+ // Get the source of the event.
+ Object eventSrc = event.getSource();
+
+ // Check whether the source is JRadioButton, it so, whether it is visible
+ if (!isValidRadioButtonObj(eventSrc))
+ return;
+
+ ButtonGroupInfo btnGroupInfo = new ButtonGroupInfo((JRadioButton)eventSrc);
+ btnGroupInfo.selectNewButton(next);
+ }
+
+ /////////////////////////// Inner Classes ////////////////////////
+ @SuppressWarnings("serial")
+ private class SelectPreviousBtn extends AbstractAction {
+ public SelectPreviousBtn() {
+ super("Previous");
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ BasicRadioButtonUI.this.selectRadioButton(e, false);
+ }
+ }
+
+ @SuppressWarnings("serial")
+ private class SelectNextBtn extends AbstractAction{
+ public SelectNextBtn() {
+ super("Next");
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ BasicRadioButtonUI.this.selectRadioButton(e, true);
+ }
+ }
+
+ /**
+ * ButtonGroupInfo, used to get related info in button group
+ * for given radio button
+ */
+ private class ButtonGroupInfo {
+
+ JRadioButton activeBtn = null;
+
+ JRadioButton firstBtn = null;
+ JRadioButton lastBtn = null;
+
+ JRadioButton previousBtn = null;
+ JRadioButton nextBtn = null;
+
+ HashSet<JRadioButton> btnsInGroup = null;
+
+ boolean srcFound = false;
+ public ButtonGroupInfo(JRadioButton btn) {
+ activeBtn = btn;
+ btnsInGroup = new HashSet<JRadioButton>();
+ }
+
+ // Check if given object is in the button group
+ boolean containsInGroup(Object obj){
+ return btnsInGroup.contains(obj);
+ }
+
+ // Check if the next object to gain focus belongs
+ // to the button group or not
+ Component getFocusTransferBaseComponent(boolean next){
+ Component focusBaseComp = activeBtn;
+ Window container = SwingUtilities.getWindowAncestor(activeBtn);
+ if (container != null) {
+ FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
+ Component comp = next ? policy.getComponentAfter(container, activeBtn)
+ : policy.getComponentBefore(container, activeBtn);
+
+ // If next component in the button group, use last/first button as base focus
+ // otherwise, use the activeBtn as the base focus
+ if (containsInGroup(comp)) {
+ focusBaseComp = next ? lastBtn : firstBtn;
+ }
+ }
+
+ return focusBaseComp;
+ }
+
+ boolean getButtonGroupInfo() {
+ if (activeBtn == null)
+ return false;
+
+ btnsInGroup.clear();
+
+ // Get the button model from the source.
+ ButtonModel model = activeBtn.getModel();
+ if (!(model instanceof DefaultButtonModel))
+ return false;
+
+ // If the button model is DefaultButtonModel, and use it, otherwise return.
+ DefaultButtonModel bm = (DefaultButtonModel) model;
+
+ // get the ButtonGroup of the button from the button model
+ ButtonGroup group = bm.getGroup();
+ if (group == null)
+ return false;
+
+ // Get all the buttons in the group
+ Enumeration<AbstractButton> e = group.getElements();
+ if (e == null)
+ return false;
+
+ while (e.hasMoreElements()) {
+ AbstractButton curElement = e.nextElement();
+ if (!isValidRadioButtonObj(curElement))
+ continue;
+
+ btnsInGroup.add((JRadioButton) curElement);
+
+ // If firstBtn is not set yet, curElement is that first button
+ if (null == firstBtn)
+ firstBtn = (JRadioButton) curElement;
+
+ if (activeBtn == curElement)
+ srcFound = true;
+ else if (!srcFound) {
+ // The source has not been yet found and the current element
+ // is the last previousBtn
+ previousBtn = (JRadioButton) curElement;
+ } else if (nextBtn == null) {
+ // The source has been found and the current element
+ // is the next valid button of the list
+ nextBtn = (JRadioButton) curElement;
+ }
+
+ // Set new last "valid" JRadioButton of the list
+ lastBtn = (JRadioButton) curElement;
+ }
+
+ return true;
+ }
+
+ /**
+ * Find the new radio button that focus needs to be
+ * moved to in the group, select the button
+ *
+ * @param next, indicate if it's arrow up/left or down/right
+ */
+ void selectNewButton(boolean next) {
+ if (!getButtonGroupInfo())
+ return;
+
+ if (srcFound) {
+ JRadioButton newSelectedBtn = null;
+ if (next) {
+ // Select Next button. Cycle to the first button if the source
+ // button is the last of the group.
+ newSelectedBtn = (null == nextBtn) ? firstBtn : nextBtn;
+ } else {
+ // Select previous button. Cycle to the last button if the source
+ // button is the first button of the group.
+ newSelectedBtn = (null == previousBtn) ? lastBtn : previousBtn;
+ }
+ if (newSelectedBtn != null &&
+ (newSelectedBtn != activeBtn)) {
+ newSelectedBtn.requestFocusInWindow();
+ newSelectedBtn.setSelected(true);
+ }
+ }
+ }
+
+ /**
+ * Find the button group the passed in JRadioButton belongs to, and
+ * move focus to next component of the last button in the group
+ * or previous component of first button
+ *
+ * @param next, indicate if jump to next component or previous
+ */
+ void jumpToNextComponent(boolean next) {
+ if (!getButtonGroupInfo()){
+ // In case the button does not belong to any group, it needs
+ // to be treated as a component
+ if (activeBtn != null){
+ lastBtn = activeBtn;
+ firstBtn = activeBtn;
+ }
+ else
+ return;
+ }
+
+ // Update the component we will use as base to transfer
+ // focus from
+ JComponent compTransferFocusFrom = activeBtn;
+
+ // If next component in the parent window is not in
+ // the button group, current active button will be
+ // base, otherwise, the base will be first or last
+ // button in the button group
+ Component focusBase = getFocusTransferBaseComponent(next);
+ if (focusBase != null){
+ if (next) {
+ KeyboardFocusManager.
+ getCurrentKeyboardFocusManager().focusNextComponent(focusBase);
+ } else {
+ KeyboardFocusManager.
+ getCurrentKeyboardFocusManager().focusPreviousComponent(focusBase);
+ }
+ }
+ }
+ }
+
+ /**
+ * Radiobutton KeyListener
+ */
+ private class KeyHandler implements KeyListener {
+
+ // This listener checks if the key event is a KeyEvent.VK_TAB
+ // or shift + KeyEvent.VK_TAB event on a radio button, consume the event
+ // if so and move the focus to next/previous component
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_TAB) {
+ // Get the source of the event.
+ Object eventSrc = e.getSource();
+
+ // Check whether the source is a visible and enabled JRadioButton
+ if (isValidRadioButtonObj(eventSrc)) {
+ e.consume();
+ ButtonGroupInfo btnGroupInfo = new ButtonGroupInfo((JRadioButton)eventSrc);
+ btnGroupInfo.jumpToNextComponent(!e.isShiftDown());
+ }
+ }
+ }
+
+ public void keyReleased(KeyEvent e) {
+ }
+
+ public void keyTyped(KeyEvent e) {
+ }
+ }
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java Thu Oct 30 13:56:09 2014 -0700
@@ -3249,6 +3249,7 @@
}
}
tabScroller.tabPanel.setPreferredSize(new Dimension(totalWidth, totalHeight));
+ tabScroller.tabPanel.invalidate();
}
}
@@ -3622,6 +3623,7 @@
setFocusIndex(tabPane.getSelectedIndex(), false);
if (scrollableTabLayoutEnabled()) {
+ ensureCurrentLayout();
int index = tabPane.getSelectedIndex();
if (index < rects.length && index != -1) {
tabScroller.tabPanel.scrollRectToVisible(
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java Thu Oct 30 13:56:09 2014 -0700
@@ -1400,8 +1400,13 @@
Element parent = elem.getParentElement();
if (parent != null) {
+ // If we are going to insert the string into the body
+ // section, it is necessary to set the corrsponding flag.
+ if (HTML.Tag.BODY.name.equals(parent.getName())) {
+ insertInBody = true;
+ }
int offset = elem.getEndOffset();
- if (offset > getLength()) {
+ if (offset > (getLength() + 1)) {
offset--;
}
else if (elem.isLeaf() && getText(offset - 1, 1).
@@ -1409,6 +1414,10 @@
offset--;
}
insertHTML(parent, offset, htmlText, false);
+ // Cleanup the flag, if any.
+ if (insertInBody) {
+ insertInBody = false;
+ }
}
}
}
@@ -1847,6 +1856,11 @@
private static char[] NEWLINE;
/**
+ * Indicates that direct insertion to body section takes place.
+ */
+ private boolean insertInBody = false;
+
+ /**
* I18N property key.
*
* @see AbstractDocument#I18NProperty
@@ -2610,7 +2624,9 @@
// Assume content should be added.
foundInsertTag(false);
foundInsertTag = true;
- inParagraph = impliedP = true;
+ // If content is added directly to the body, it should
+ // be wrapped by p-implied.
+ inParagraph = impliedP = !insertInBody;
}
if (data.length >= 1) {
addContent(data, 0, data.length);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLBlitLoops.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLBlitLoops.java Thu Oct 30 13:56:09 2014 -0700
@@ -47,7 +47,7 @@
import static sun.java2d.pipe.BufferedOpCodes.*;
import java.lang.annotation.Native;
-class OGLBlitLoops {
+final class OGLBlitLoops {
static void register() {
Blit blitIntArgbPreToSurface =
@@ -56,7 +56,9 @@
Blit blitIntArgbPreToTexture =
new OGLSwToTextureBlit(SurfaceType.IntArgbPre,
OGLSurfaceData.PF_INT_ARGB_PRE);
-
+ TransformBlit transformBlitIntArgbPreToSurface =
+ new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre,
+ OGLSurfaceData.PF_INT_ARGB_PRE);
GraphicsPrimitive[] primitives = {
// surface->surface ops
new OGLSurfaceToSurfaceBlit(),
@@ -100,7 +102,7 @@
CompositeType.AnyAlpha,
blitIntArgbPreToSurface),
- new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLSurface),
+ new OGLAnyCompositeBlit(),
new OGLSwToSurfaceScale(SurfaceType.IntRgb,
OGLSurfaceData.PF_INT_RGB),
@@ -145,8 +147,9 @@
OGLSurfaceData.PF_BYTE_GRAY),
new OGLSwToSurfaceTransform(SurfaceType.UshortGray,
OGLSurfaceData.PF_USHORT_GRAY),
- new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre,
- OGLSurfaceData.PF_INT_ARGB_PRE),
+ transformBlitIntArgbPreToSurface,
+
+ new OGLGeneralTransformedBlit(transformBlitIntArgbPreToSurface),
// texture->surface ops
new OGLTextureToSurfaceBlit(),
@@ -178,9 +181,6 @@
new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture,
CompositeType.SrcNoEa,
blitIntArgbPreToTexture),
-
- new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLTexture),
-
};
GraphicsPrimitiveMgr.register(primitives);
}
@@ -781,11 +781,11 @@
* This general Blit implementation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->OpenGLSurface/Texture loop to get the intermediate
- * (premultiplied) surface down to OpenGL.
+ * (premultiplied) surface down to OpenGL using simple blit.
*/
class OGLGeneralBlit extends Blit {
- private Blit performop;
+ private final Blit performop;
private WeakReference<SurfaceData> srcTmp;
OGLGeneralBlit(SurfaceType dstType,
@@ -826,12 +826,56 @@
}
}
-class OGLAnyCompositeBlit extends Blit {
+/**
+ * This general TransformedBlit implementation converts any source surface to an
+ * intermediate IntArgbPre surface, and then uses the more specific
+ * IntArgbPre->OpenGLSurface/Texture loop to get the intermediate
+ * (premultiplied) surface down to OpenGL using simple transformBlit.
+ */
+final class OGLGeneralTransformedBlit extends TransformBlit {
+
+ private final TransformBlit performop;
+ private WeakReference<SurfaceData> srcTmp;
+
+ OGLGeneralTransformedBlit(final TransformBlit performop) {
+ super(SurfaceType.Any, CompositeType.AnyAlpha,
+ OGLSurfaceData.OpenGLSurface);
+ this.performop = performop;
+ }
+
+ @Override
+ public synchronized void Transform(SurfaceData src, SurfaceData dst,
+ Composite comp, Region clip,
+ AffineTransform at, int hint, int srcx,
+ int srcy, int dstx, int dsty, int width,
+ int height){
+ Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),
+ CompositeType.SrcNoEa,
+ SurfaceType.IntArgbPre);
+ // use cached intermediate surface, if available
+ final SurfaceData cachedSrc = srcTmp != null ? srcTmp.get() : null;
+ // convert source to IntArgbPre
+ src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc,
+ BufferedImage.TYPE_INT_ARGB_PRE);
+
+ // transform IntArgbPre intermediate surface to OpenGL surface
+ performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty,
+ width, height);
+
+ if (src != cachedSrc) {
+ // cache the intermediate surface
+ srcTmp = new WeakReference<>(src);
+ }
+ }
+}
+
+final class OGLAnyCompositeBlit extends Blit {
private WeakReference<SurfaceData> dstTmp;
- public OGLAnyCompositeBlit(SurfaceType dstType) {
- super(SurfaceType.Any, CompositeType.Any, dstType);
+ OGLAnyCompositeBlit() {
+ super(SurfaceType.Any, CompositeType.Any, OGLSurfaceData.OpenGLSurface);
}
+
public synchronized void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int sx, int sy, int dx, int dy,
@@ -848,15 +892,15 @@
cachedDst = dstTmp.get();
}
- // convert source to IntArgbPre
+ // convert destination to IntArgbPre
SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h,
cachedDst, BufferedImage.TYPE_INT_ARGB_PRE);
+ Region bufferClip =
+ clip == null ? null : clip.getTranslatedRegion(-dx, -dy);
Blit performop = Blit.getFromCache(src.getSurfaceType(),
CompositeType.Any, dstBuffer.getSurfaceType());
-
- performop.Blit(src, dstBuffer, comp, clip,
- sx, sy, 0, 0, w, h);
+ performop.Blit(src, dstBuffer, comp, bufferClip, sx, sy, 0, 0, w, h);
if (dstBuffer != cachedDst) {
// cache the intermediate surface
--- a/jdk/src/java.desktop/unix/classes/META-INF/services/javax.print.PrintServiceLookup Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Provider for Java Print Service
-sun.print.UnixPrintServiceLookup
--- a/jdk/src/java.desktop/unix/classes/META-INF/services/javax.print.StreamPrintServiceFactory Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Provider for Java 2D Stream print services.
-sun.print.PSStreamPrinterFactory
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java Thu Oct 30 13:56:09 2014 -0700
@@ -595,8 +595,13 @@
return isNetWMName("Mutter") || isNetWMName("GNOME Shell");
}
+ static int awtWMNonReparenting = -1;
static boolean isNonReparentingWM() {
- return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.CWM_WM);
+ if (awtWMNonReparenting == -1) {
+ awtWMNonReparenting = (XToolkit.getEnv("_JAVA_AWT_WM_NONREPARENTING") != null) ? 1 : 0;
+ }
+ return (awtWMNonReparenting == 1 || XWM.getWMID() == XWM.COMPIZ_WM
+ || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.CWM_WM);
}
/*
--- a/jdk/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java Thu Oct 30 13:56:09 2014 -0700
@@ -324,8 +324,8 @@
* reported, exec lpstat -d which has all the Apple
* special behaviour for this built in.
*/
- if (UnixPrintServiceLookup.isMac()) {
- printerInfo[0] = UnixPrintServiceLookup.
+ if (PrintServiceLookupProvider.isMac()) {
+ printerInfo[0] = PrintServiceLookupProvider.
getDefaultPrinterNameSysV();
printerInfo[1] = null;
return printerInfo.clone();
--- a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Thu Oct 30 13:56:09 2014 -0700
@@ -1047,7 +1047,7 @@
setting like collation. Therefore, we temporarily exclude
Linux.
*/
- if (!UnixPrintServiceLookup.isLinux()) {
+ if (!PrintServiceLookupProvider.isLinux()) {
catList.add(SheetCollate.class);
}
}
@@ -1641,7 +1641,7 @@
* Mac is using printer-info IPP attribute for its human-readable printer
* name and is also the identifier used in NSPrintInfo:setPrinter.
*/
- if (UnixPrintServiceLookup.isMac()) {
+ if (PrintServiceLookupProvider.isMac()) {
PrintServiceAttributeSet psaSet = this.getAttributes();
if (psaSet != null) {
PrinterInfo pName = (PrinterInfo)psaSet.get(PrinterInfo.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,964 @@
+/*
+ * Copyright (c) 2000, 2014, 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.
+ */
+
+package sun.print;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Vector;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import javax.print.DocFlavor;
+import javax.print.MultiDocPrintService;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.PrintRequestAttribute;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.PrinterName;
+import javax.print.attribute.standard.PrinterURI;
+import java.io.File;
+import java.io.FileReader;
+import java.net.URL;
+import java.nio.file.Files;
+
+/*
+ * Remind: This class uses solaris commands. We also need a linux
+ * version
+ */
+public class PrintServiceLookupProvider extends PrintServiceLookup
+ implements BackgroundServiceLookup, Runnable {
+
+ /* Remind: the current implementation is static, as its assumed
+ * its preferable to minimize creation of PrintService instances.
+ * Later we should add logic to add/remove services on the fly which
+ * will take a hit of needing to regather the list of services.
+ */
+ private String defaultPrinter;
+ private PrintService defaultPrintService;
+ private PrintService[] printServices; /* includes the default printer */
+ private Vector<BackgroundLookupListener> lookupListeners = null;
+ private static String debugPrefix = "PrintServiceLookupProvider>> ";
+ private static boolean pollServices = true;
+ private static final int DEFAULT_MINREFRESH = 120; // 2 minutes
+ private static int minRefreshTime = DEFAULT_MINREFRESH;
+
+
+ static String osname;
+
+ // List of commands used to deal with the printer queues on AIX
+ String[] lpNameComAix = {
+ "/usr/bin/lsallq",
+ "/usr/bin/lpstat -W -p|/usr/bin/expand|/usr/bin/cut -f1 -d' '",
+ "/usr/bin/lpstat -W -d|/usr/bin/expand|/usr/bin/cut -f1 -d' '",
+ "/usr/bin/lpstat -W -v"
+ };
+ private static final int aix_lsallq = 0;
+ private static final int aix_lpstat_p = 1;
+ private static final int aix_lpstat_d = 2;
+ private static final int aix_lpstat_v = 3;
+ private static int aix_defaultPrinterEnumeration = aix_lsallq;
+
+ static {
+ /* The system property "sun.java2d.print.polling"
+ * can be used to force the printing code to poll or not poll
+ * for PrintServices.
+ */
+ String pollStr = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("sun.java2d.print.polling"));
+
+ if (pollStr != null) {
+ if (pollStr.equalsIgnoreCase("true")) {
+ pollServices = true;
+ } else if (pollStr.equalsIgnoreCase("false")) {
+ pollServices = false;
+ }
+ }
+
+ /* The system property "sun.java2d.print.minRefreshTime"
+ * can be used to specify minimum refresh time (in seconds)
+ * for polling PrintServices. The default is 120.
+ */
+ String refreshTimeStr = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction(
+ "sun.java2d.print.minRefreshTime"));
+
+ if (refreshTimeStr != null) {
+ try {
+ minRefreshTime = (new Integer(refreshTimeStr)).intValue();
+ } catch (NumberFormatException e) {
+ }
+ if (minRefreshTime < DEFAULT_MINREFRESH) {
+ minRefreshTime = DEFAULT_MINREFRESH;
+ }
+ }
+
+ osname = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("os.name"));
+
+ /* The system property "sun.java2d.print.aix.lpstat"
+ * can be used to force the usage of 'lpstat -p' to enumerate all
+ * printer queues. By default we use 'lsallq', because 'lpstat -p' can
+ * take lots of time if thousands of printers are attached to a server.
+ */
+ if (isAIX()) {
+ String aixPrinterEnumerator = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("sun.java2d.print.aix.lpstat"));
+
+ if (aixPrinterEnumerator != null) {
+ if (aixPrinterEnumerator.equalsIgnoreCase("lpstat")) {
+ aix_defaultPrinterEnumeration = aix_lpstat_p;
+ } else if (aixPrinterEnumerator.equalsIgnoreCase("lsallq")) {
+ aix_defaultPrinterEnumeration = aix_lsallq;
+ }
+ }
+ }
+ }
+
+ static boolean isMac() {
+ return osname.startsWith("Mac");
+ }
+
+ static boolean isSysV() {
+ return osname.equals("SunOS");
+ }
+
+ static boolean isLinux() {
+ return (osname.equals("Linux"));
+ }
+
+ static boolean isBSD() {
+ return (osname.equals("Linux") ||
+ osname.contains("OS X"));
+ }
+
+ static boolean isAIX() {
+ return osname.equals("AIX");
+ }
+
+ static final int UNINITIALIZED = -1;
+ static final int BSD_LPD = 0;
+ static final int BSD_LPD_NG = 1;
+
+ static int cmdIndex = UNINITIALIZED;
+
+ String[] lpcFirstCom = {
+ "/usr/sbin/lpc status | grep : | sed -ne '1,1 s/://p'",
+ "/usr/sbin/lpc status | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
+ };
+
+ String[] lpcAllCom = {
+ "/usr/sbin/lpc status all | grep : | sed -e 's/://'",
+ "/usr/sbin/lpc status all | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}' | sort"
+ };
+
+ String[] lpcNameCom = {
+ "| grep : | sed -ne 's/://p'",
+ "| grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
+ };
+
+
+ static int getBSDCommandIndex() {
+ String command = "/usr/sbin/lpc status all";
+ String[] names = execCmd(command);
+
+ if ((names == null) || (names.length == 0)) {
+ return BSD_LPD_NG;
+ }
+
+ for (int i=0; i<names.length; i++) {
+ if (names[i].indexOf('@') != -1) {
+ return BSD_LPD_NG;
+ }
+ }
+
+ return BSD_LPD;
+ }
+
+
+ public PrintServiceLookupProvider() {
+ // start the printer listener thread
+ if (pollServices) {
+ PrinterChangeListener thr = new PrinterChangeListener();
+ thr.setDaemon(true);
+ thr.start();
+ IPPPrintService.debug_println(debugPrefix+"polling turned on");
+ }
+ }
+
+ /* Want the PrintService which is default print service to have
+ * equality of reference with the equivalent in list of print services
+ * This isn't required by the API and there's a risk doing this will
+ * lead people to assume its guaranteed.
+ */
+ public synchronized PrintService[] getPrintServices() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+
+ if (printServices == null || !pollServices) {
+ refreshServices();
+ }
+ if (printServices == null) {
+ return new PrintService[0];
+ } else {
+ return printServices.clone();
+ }
+ }
+
+ private int addPrintServiceToList(ArrayList<PrintService> printerList, PrintService ps) {
+ int index = printerList.indexOf(ps);
+ // Check if PrintService with same name is already in the list.
+ if (CUPSPrinter.isCupsRunning() && index != -1) {
+ // Bug in Linux: Duplicate entry of a remote printer
+ // and treats it as local printer but it is returning wrong
+ // information when queried using IPP. Workaround is to remove it.
+ // Even CUPS ignores these entries as shown in lpstat or using
+ // their web configuration.
+ PrinterURI uri = ps.getAttribute(PrinterURI.class);
+ if (uri.getURI().getHost().equals("localhost")) {
+ IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps);
+ return index; // Do not add this.
+ }
+ PrintService oldPS = printerList.get(index);
+ uri = oldPS.getAttribute(PrinterURI.class);
+ if (uri.getURI().getHost().equals("localhost")) {
+ IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS);
+ printerList.remove(oldPS);
+ } else {
+ return index;
+ }
+ }
+ printerList.add(ps);
+ return (printerList.size() - 1);
+ }
+
+
+ // refreshes "printServices"
+ public synchronized void refreshServices() {
+ /* excludes the default printer */
+ String[] printers = null; // array of printer names
+ String[] printerURIs = null; //array of printer URIs
+
+ try {
+ getDefaultPrintService();
+ } catch (Throwable t) {
+ IPPPrintService.debug_println(debugPrefix+
+ "Exception getting default printer : " + t);
+ }
+ if (CUPSPrinter.isCupsRunning()) {
+ try {
+ printerURIs = CUPSPrinter.getAllPrinters();
+ IPPPrintService.debug_println("CUPS URIs = " + printerURIs);
+ if (printerURIs != null) {
+ for (int p = 0; p < printerURIs.length; p++) {
+ IPPPrintService.debug_println("URI="+printerURIs[p]);
+ }
+ }
+ } catch (Throwable t) {
+ IPPPrintService.debug_println(debugPrefix+
+ "Exception getting all CUPS printers : " + t);
+ }
+ if ((printerURIs != null) && (printerURIs.length > 0)) {
+ printers = new String[printerURIs.length];
+ for (int i=0; i<printerURIs.length; i++) {
+ int lastIndex = printerURIs[i].lastIndexOf("/");
+ printers[i] = printerURIs[i].substring(lastIndex+1);
+ }
+ }
+ } else {
+ if (isMac() || isSysV()) {
+ printers = getAllPrinterNamesSysV();
+ } else if (isAIX()) {
+ printers = getAllPrinterNamesAIX();
+ } else { //BSD
+ printers = getAllPrinterNamesBSD();
+ }
+ }
+
+ if (printers == null) {
+ if (defaultPrintService != null) {
+ printServices = new PrintService[1];
+ printServices[0] = defaultPrintService;
+ } else {
+ printServices = null;
+ }
+ return;
+ }
+
+ ArrayList<PrintService> printerList = new ArrayList<>();
+ int defaultIndex = -1;
+ for (int p=0; p<printers.length; p++) {
+ if (printers[p] == null) {
+ continue;
+ }
+ if ((defaultPrintService != null)
+ && printers[p].equals(getPrinterDestName(defaultPrintService))) {
+ defaultIndex = addPrintServiceToList(printerList, defaultPrintService);
+ } else {
+ if (printServices == null) {
+ IPPPrintService.debug_println(debugPrefix+
+ "total# of printers = "+printers.length);
+
+ if (CUPSPrinter.isCupsRunning()) {
+ try {
+ addPrintServiceToList(printerList,
+ new IPPPrintService(printers[p],
+ printerURIs[p],
+ true));
+ } catch (Exception e) {
+ IPPPrintService.debug_println(debugPrefix+
+ " getAllPrinters Exception "+
+ e);
+
+ }
+ } else {
+ printerList.add(new UnixPrintService(printers[p]));
+ }
+ } else {
+ int j;
+ for (j=0; j<printServices.length; j++) {
+ if (printServices[j] != null) {
+ if (printers[p].equals(getPrinterDestName(printServices[j]))) {
+ printerList.add(printServices[j]);
+ printServices[j] = null;
+ break;
+ }
+ }
+ }
+
+ if (j == printServices.length) { // not found?
+ if (CUPSPrinter.isCupsRunning()) {
+ try {
+ addPrintServiceToList(printerList,
+ new IPPPrintService(printers[p],
+ printerURIs[p],
+ true));
+ } catch (Exception e) {
+ IPPPrintService.debug_println(debugPrefix+
+ " getAllPrinters Exception "+
+ e);
+
+ }
+ } else {
+ printerList.add(new UnixPrintService(printers[p]));
+ }
+ }
+ }
+ }
+ }
+
+ // Look for deleted services and invalidate these
+ if (printServices != null) {
+ for (int j=0; j < printServices.length; j++) {
+ if ((printServices[j] instanceof UnixPrintService) &&
+ (!printServices[j].equals(defaultPrintService))) {
+ ((UnixPrintService)printServices[j]).invalidateService();
+ }
+ }
+ }
+
+ //if defaultService is not found in printerList
+ if (defaultIndex == -1 && defaultPrintService != null) {
+ defaultIndex = addPrintServiceToList(printerList, defaultPrintService);
+ }
+
+ printServices = printerList.toArray(new PrintService[] {});
+
+ // swap default with the first in the list
+ if (defaultIndex > 0) {
+ PrintService saveService = printServices[0];
+ printServices[0] = printServices[defaultIndex];
+ printServices[defaultIndex] = saveService;
+ }
+ }
+
+ private boolean matchesAttributes(PrintService service,
+ PrintServiceAttributeSet attributes) {
+
+ Attribute [] attrs = attributes.toArray();
+ for (int i=0; i<attrs.length; i++) {
+ @SuppressWarnings("unchecked")
+ Attribute serviceAttr
+ = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
+ if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* This checks for validity of the printer name before passing as
+ * parameter to a shell command.
+ */
+ private boolean checkPrinterName(String s) {
+ char c;
+
+ for (int i=0; i < s.length(); i++) {
+ c = s.charAt(i);
+ if (Character.isLetterOrDigit(c) ||
+ c == '-' || c == '_' || c == '.' || c == '/') {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * Gets the printer name compatible with the list of printers returned by
+ * the system when we query default or all the available printers.
+ */
+ private String getPrinterDestName(PrintService ps) {
+ if (isMac()) {
+ return ((IPPPrintService)ps).getDest();
+ }
+ return ps.getName();
+ }
+
+ /* On a network with many (hundreds) of network printers, it
+ * can save several seconds if you know all you want is a particular
+ * printer, to ask for that printer rather than retrieving all printers.
+ */
+ private PrintService getServiceByName(PrinterName nameAttr) {
+ String name = nameAttr.getValue();
+ if (name == null || name.equals("") || !checkPrinterName(name)) {
+ return null;
+ }
+ /* check if all printers are already available */
+ if (printServices != null) {
+ for (PrintService printService : printServices) {
+ PrinterName printerName = printService.getAttribute(PrinterName.class);
+ if (printerName.getValue().equals(name)) {
+ return printService;
+ }
+ }
+ }
+ /* take CUPS into account first */
+ if (CUPSPrinter.isCupsRunning()) {
+ try {
+ return new IPPPrintService(name,
+ new URL("http://"+
+ CUPSPrinter.getServer()+":"+
+ CUPSPrinter.getPort()+"/"+
+ name));
+ } catch (Exception e) {
+ IPPPrintService.debug_println(debugPrefix+
+ " getServiceByName Exception "+
+ e);
+ }
+ }
+ /* fallback if nothing not having a printer at this point */
+ PrintService printer = null;
+ if (isMac() || isSysV()) {
+ printer = getNamedPrinterNameSysV(name);
+ } else if (isAIX()) {
+ printer = getNamedPrinterNameAIX(name);
+ } else {
+ printer = getNamedPrinterNameBSD(name);
+ }
+ return printer;
+ }
+
+ private PrintService[]
+ getPrintServices(PrintServiceAttributeSet serviceSet) {
+
+ if (serviceSet == null || serviceSet.isEmpty()) {
+ return getPrintServices();
+ }
+
+ /* Typically expect that if a service attribute is specified that
+ * its a printer name and there ought to be only one match.
+ * Directly retrieve that service and confirm
+ * that it meets the other requirements.
+ * If printer name isn't mentioned then go a slow path checking
+ * all printers if they meet the reqiremements.
+ */
+ PrintService[] services;
+ PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
+ PrintService defService;
+ if (name != null && (defService = getDefaultPrintService()) != null) {
+ /* To avoid execing a unix command see if the client is asking
+ * for the default printer by name, since we already have that
+ * initialised.
+ */
+
+ PrinterName defName = defService.getAttribute(PrinterName.class);
+
+ if (defName != null && name.equals(defName)) {
+ if (matchesAttributes(defService, serviceSet)) {
+ services = new PrintService[1];
+ services[0] = defService;
+ return services;
+ } else {
+ return new PrintService[0];
+ }
+ } else {
+ /* Its not the default service */
+ PrintService service = getServiceByName(name);
+ if (service != null &&
+ matchesAttributes(service, serviceSet)) {
+ services = new PrintService[1];
+ services[0] = service;
+ return services;
+ } else {
+ return new PrintService[0];
+ }
+ }
+ } else {
+ /* specified service attributes don't include a name.*/
+ Vector<PrintService> matchedServices = new Vector<>();
+ services = getPrintServices();
+ for (int i = 0; i< services.length; i++) {
+ if (matchesAttributes(services[i], serviceSet)) {
+ matchedServices.add(services[i]);
+ }
+ }
+ services = new PrintService[matchedServices.size()];
+ for (int i = 0; i< services.length; i++) {
+ services[i] = matchedServices.elementAt(i);
+ }
+ return services;
+ }
+ }
+
+ /*
+ * If service attributes are specified then there must be additional
+ * filtering.
+ */
+ public PrintService[] getPrintServices(DocFlavor flavor,
+ AttributeSet attributes) {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+ PrintRequestAttributeSet requestSet = null;
+ PrintServiceAttributeSet serviceSet = null;
+
+ if (attributes != null && !attributes.isEmpty()) {
+
+ requestSet = new HashPrintRequestAttributeSet();
+ serviceSet = new HashPrintServiceAttributeSet();
+
+ Attribute[] attrs = attributes.toArray();
+ for (int i=0; i<attrs.length; i++) {
+ if (attrs[i] instanceof PrintRequestAttribute) {
+ requestSet.add(attrs[i]);
+ } else if (attrs[i] instanceof PrintServiceAttribute) {
+ serviceSet.add(attrs[i]);
+ }
+ }
+ }
+
+ PrintService[] services = getPrintServices(serviceSet);
+ if (services.length == 0) {
+ return services;
+ }
+
+ if (CUPSPrinter.isCupsRunning()) {
+ ArrayList<PrintService> matchingServices = new ArrayList<>();
+ for (int i=0; i<services.length; i++) {
+ try {
+ if (services[i].
+ getUnsupportedAttributes(flavor, requestSet) == null) {
+ matchingServices.add(services[i]);
+ }
+ } catch (IllegalArgumentException e) {
+ }
+ }
+ services = new PrintService[matchingServices.size()];
+ return matchingServices.toArray(services);
+
+ } else {
+ // We only need to compare 1 PrintService because all
+ // UnixPrintServices are the same anyway. We will not use
+ // default PrintService because it might be null.
+ PrintService service = services[0];
+ if ((flavor == null ||
+ service.isDocFlavorSupported(flavor)) &&
+ service.getUnsupportedAttributes(flavor, requestSet) == null)
+ {
+ return services;
+ } else {
+ return new PrintService[0];
+ }
+ }
+ }
+
+ /*
+ * return empty array as don't support multi docs
+ */
+ public MultiDocPrintService[]
+ getMultiDocPrintServices(DocFlavor[] flavors,
+ AttributeSet attributes) {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+ return new MultiDocPrintService[0];
+ }
+
+
+ public synchronized PrintService getDefaultPrintService() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+
+ // clear defaultPrintService
+ defaultPrintService = null;
+ String psuri = null;
+
+ IPPPrintService.debug_println("isRunning ? "+
+ (CUPSPrinter.isCupsRunning()));
+ if (CUPSPrinter.isCupsRunning()) {
+ String[] printerInfo = CUPSPrinter.getDefaultPrinter();
+ if (printerInfo != null && printerInfo.length >= 2) {
+ defaultPrinter = printerInfo[0];
+ psuri = printerInfo[1];
+ }
+ } else {
+ if (isMac() || isSysV()) {
+ defaultPrinter = getDefaultPrinterNameSysV();
+ } else if (isAIX()) {
+ defaultPrinter = getDefaultPrinterNameAIX();
+ } else {
+ defaultPrinter = getDefaultPrinterNameBSD();
+ }
+ }
+ if (defaultPrinter == null) {
+ return null;
+ }
+ defaultPrintService = null;
+ if (printServices != null) {
+ for (int j=0; j<printServices.length; j++) {
+ if (defaultPrinter.equals(getPrinterDestName(printServices[j]))) {
+ defaultPrintService = printServices[j];
+ break;
+ }
+ }
+ }
+ if (defaultPrintService == null) {
+ if (CUPSPrinter.isCupsRunning()) {
+ try {
+ PrintService defaultPS;
+ if ((psuri != null) && !psuri.startsWith("file")) {
+ defaultPS = new IPPPrintService(defaultPrinter,
+ psuri, true);
+ } else {
+ defaultPS = new IPPPrintService(defaultPrinter,
+ new URL("http://"+
+ CUPSPrinter.getServer()+":"+
+ CUPSPrinter.getPort()+"/"+
+ defaultPrinter));
+ }
+ defaultPrintService = defaultPS;
+ } catch (Exception e) {
+ }
+ } else {
+ defaultPrintService = new UnixPrintService(defaultPrinter);
+ }
+ }
+
+ return defaultPrintService;
+ }
+
+ public synchronized void
+ getServicesInbackground(BackgroundLookupListener listener) {
+ if (printServices != null) {
+ listener.notifyServices(printServices);
+ } else {
+ if (lookupListeners == null) {
+ lookupListeners = new Vector<>();
+ lookupListeners.add(listener);
+ Thread lookupThread = new Thread(this);
+ lookupThread.start();
+ } else {
+ lookupListeners.add(listener);
+ }
+ }
+ }
+
+ /* This method isn't used in most cases because we rely on code in
+ * javax.print.PrintServiceLookup. This is needed just for the cases
+ * where those interfaces are by-passed.
+ */
+ private PrintService[] copyOf(PrintService[] inArr) {
+ if (inArr == null || inArr.length == 0) {
+ return inArr;
+ } else {
+ PrintService []outArr = new PrintService[inArr.length];
+ System.arraycopy(inArr, 0, outArr, 0, inArr.length);
+ return outArr;
+ }
+ }
+
+ public void run() {
+ PrintService[] services = getPrintServices();
+ synchronized (this) {
+ BackgroundLookupListener listener;
+ for (int i=0; i<lookupListeners.size(); i++) {
+ listener = lookupListeners.elementAt(i);
+ listener.notifyServices(copyOf(services));
+ }
+ lookupListeners = null;
+ }
+ }
+
+ private String getDefaultPrinterNameBSD() {
+ if (cmdIndex == UNINITIALIZED) {
+ cmdIndex = getBSDCommandIndex();
+ }
+ String[] names = execCmd(lpcFirstCom[cmdIndex]);
+ if (names == null || names.length == 0) {
+ return null;
+ }
+
+ if ((cmdIndex==BSD_LPD_NG) &&
+ (names[0].startsWith("missingprinter"))) {
+ return null;
+ }
+ return names[0];
+ }
+
+ private PrintService getNamedPrinterNameBSD(String name) {
+ if (cmdIndex == UNINITIALIZED) {
+ cmdIndex = getBSDCommandIndex();
+ }
+ String command = "/usr/sbin/lpc status " + name + lpcNameCom[cmdIndex];
+ String[] result = execCmd(command);
+
+ if (result == null || !(result[0].equals(name))) {
+ return null;
+ }
+ return new UnixPrintService(name);
+ }
+
+ private String[] getAllPrinterNamesBSD() {
+ if (cmdIndex == UNINITIALIZED) {
+ cmdIndex = getBSDCommandIndex();
+ }
+ String[] names = execCmd(lpcAllCom[cmdIndex]);
+ if (names == null || names.length == 0) {
+ return null;
+ }
+ return names;
+ }
+
+ static String getDefaultPrinterNameSysV() {
+ String defaultPrinter = "lp";
+ String command = "/usr/bin/lpstat -d";
+
+ String [] names = execCmd(command);
+ if (names == null || names.length == 0) {
+ return defaultPrinter;
+ } else {
+ int index = names[0].indexOf(":");
+ if (index == -1 || (names[0].length() <= index+1)) {
+ return null;
+ } else {
+ String name = names[0].substring(index+1).trim();
+ if (name.length() == 0) {
+ return null;
+ } else {
+ return name;
+ }
+ }
+ }
+ }
+
+ private PrintService getNamedPrinterNameSysV(String name) {
+
+ String command = "/usr/bin/lpstat -v " + name;
+ String []result = execCmd(command);
+
+ if (result == null || result[0].indexOf("unknown printer") > 0) {
+ return null;
+ } else {
+ return new UnixPrintService(name);
+ }
+ }
+
+ private String[] getAllPrinterNamesSysV() {
+ String defaultPrinter = "lp";
+ String command = "/usr/bin/lpstat -v|/usr/bin/expand|/usr/bin/cut -f3 -d' ' |/usr/bin/cut -f1 -d':' | /usr/bin/sort";
+
+ String [] names = execCmd(command);
+ ArrayList<String> printerNames = new ArrayList<>();
+ for (int i=0; i < names.length; i++) {
+ if (!names[i].equals("_default") &&
+ !names[i].equals(defaultPrinter) &&
+ !names[i].equals("")) {
+ printerNames.add(names[i]);
+ }
+ }
+ return printerNames.toArray(new String[printerNames.size()]);
+ }
+
+ private String getDefaultPrinterNameAIX() {
+ String[] names = execCmd(lpNameComAix[aix_lpstat_d]);
+ // Remove headers and bogus entries added by remote printers.
+ names = UnixPrintService.filterPrinterNamesAIX(names);
+ if (names == null || names.length != 1) {
+ // No default printer found
+ return null;
+ } else {
+ return names[0];
+ }
+ }
+
+ private PrintService getNamedPrinterNameAIX(String name) {
+ // On AIX there should be no blank after '-v'.
+ String[] result = execCmd(lpNameComAix[aix_lpstat_v] + name);
+ // Remove headers and bogus entries added by remote printers.
+ result = UnixPrintService.filterPrinterNamesAIX(result);
+ if (result == null || result.length != 1) {
+ return null;
+ } else {
+ return new UnixPrintService(name);
+ }
+ }
+
+ private String[] getAllPrinterNamesAIX() {
+ // Determine all printers of the system.
+ String [] names = execCmd(lpNameComAix[aix_defaultPrinterEnumeration]);
+
+ // Remove headers and bogus entries added by remote printers.
+ names = UnixPrintService.filterPrinterNamesAIX(names);
+
+ ArrayList<String> printerNames = new ArrayList<String>();
+ for ( int i=0; i < names.length; i++) {
+ printerNames.add(names[i]);
+ }
+ return printerNames.toArray(new String[printerNames.size()]);
+ }
+
+ static String[] execCmd(final String command) {
+ ArrayList<String> results = null;
+ try {
+ final String[] cmd = new String[3];
+ if (isSysV() || isAIX()) {
+ cmd[0] = "/usr/bin/sh";
+ cmd[1] = "-c";
+ cmd[2] = "env LC_ALL=C " + command;
+ } else {
+ cmd[0] = "/bin/sh";
+ cmd[1] = "-c";
+ cmd[2] = "LC_ALL=C " + command;
+ }
+
+ results = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<ArrayList<String>>() {
+ public ArrayList<String> run() throws IOException {
+
+ Process proc;
+ BufferedReader bufferedReader = null;
+ File f = Files.createTempFile("prn","xc").toFile();
+ cmd[2] = cmd[2]+">"+f.getAbsolutePath();
+
+ proc = Runtime.getRuntime().exec(cmd);
+ try {
+ boolean done = false; // in case of interrupt.
+ while (!done) {
+ try {
+ proc.waitFor();
+ done = true;
+ } catch (InterruptedException e) {
+ }
+ }
+
+ if (proc.exitValue() == 0) {
+ FileReader reader = new FileReader(f);
+ bufferedReader = new BufferedReader(reader);
+ String line;
+ ArrayList<String> results = new ArrayList<>();
+ while ((line = bufferedReader.readLine())
+ != null) {
+ results.add(line);
+ }
+ return results;
+ }
+ } finally {
+ f.delete();
+ // promptly close all streams.
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ proc.getInputStream().close();
+ proc.getErrorStream().close();
+ proc.getOutputStream().close();
+ }
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ }
+ if (results == null) {
+ return new String[0];
+ } else {
+ return results.toArray(new String[results.size()]);
+ }
+ }
+
+ private class PrinterChangeListener extends Thread {
+
+ public void run() {
+ int refreshSecs;
+ while (true) {
+ try {
+ refreshServices();
+ } catch (Exception se) {
+ IPPPrintService.debug_println(debugPrefix+"Exception in refresh thread.");
+ break;
+ }
+
+ if ((printServices != null) &&
+ (printServices.length > minRefreshTime)) {
+ // compute new refresh time 1 printer = 1 sec
+ refreshSecs = printServices.length;
+ } else {
+ refreshSecs = minRefreshTime;
+ }
+ try {
+ sleep(refreshSecs * 1000);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
+ }
+}
--- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java Thu Oct 30 13:56:09 2014 -0700
@@ -122,7 +122,7 @@
UnixPrintJob(PrintService service) {
this.service = service;
mDestination = service.getName();
- if (UnixPrintServiceLookup.isMac()) {
+ if (PrintServiceLookupProvider.isMac()) {
mDestination = ((IPPPrintService)service).getDest();
}
mDestType = UnixPrintJob.DESTPRINTER;
@@ -880,7 +880,7 @@
pFlags |= NOSHEET;
ncomps+=1;
}
- if (UnixPrintServiceLookup.osname.equals("SunOS")) {
+ if (PrintServiceLookupProvider.osname.equals("SunOS")) {
ncomps+=1; // lp uses 1 more arg than lpr (make a copy)
execCmd = new String[ncomps];
execCmd[n++] = "/usr/bin/lp";
--- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintService.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintService.java Thu Oct 30 13:56:09 2014 -0700
@@ -220,7 +220,7 @@
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsSysV() {
String command = "/usr/bin/lpstat -a " + printer;
- String results[]= UnixPrintServiceLookup.execCmd(command);
+ String results[]= PrintServiceLookupProvider.execCmd(command);
if (results != null && results.length > 0) {
if (results[0].startsWith(printer + " accepting requests")) {
@@ -244,20 +244,20 @@
}
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsBSD() {
- if (UnixPrintServiceLookup.cmdIndex ==
- UnixPrintServiceLookup.UNINITIALIZED) {
+ if (PrintServiceLookupProvider.cmdIndex ==
+ PrintServiceLookupProvider.UNINITIALIZED) {
- UnixPrintServiceLookup.cmdIndex =
- UnixPrintServiceLookup.getBSDCommandIndex();
+ PrintServiceLookupProvider.cmdIndex =
+ PrintServiceLookupProvider.getBSDCommandIndex();
}
String command = "/usr/sbin/lpc status " + printer
- + lpcStatusCom[UnixPrintServiceLookup.cmdIndex];
- String results[]= UnixPrintServiceLookup.execCmd(command);
+ + lpcStatusCom[PrintServiceLookupProvider.cmdIndex];
+ String results[]= PrintServiceLookupProvider.execCmd(command);
if (results != null && results.length > 0) {
- if (UnixPrintServiceLookup.cmdIndex ==
- UnixPrintServiceLookup.BSD_LPD_NG) {
+ if (PrintServiceLookupProvider.cmdIndex ==
+ PrintServiceLookupProvider.BSD_LPD_NG) {
if (results[0].startsWith("enabled enabled")) {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS ;
}
@@ -276,7 +276,7 @@
// Filter the list of possible AIX Printers and remove header lines
// and extra lines which have been added for remote printers.
- // 'protected' because this method is also used from UnixPrintServiceLookup.
+ // 'protected' because this method is also used from PrintServiceLookupProvider.
protected static String[] filterPrinterNamesAIX(String[] posPrinters) {
ArrayList<String> printers = new ArrayList<>();
String [] splitPart;
@@ -301,7 +301,7 @@
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsAIX() {
// On AIX there should not be a blank after '-a'.
String command = "/usr/bin/lpstat -a" + printer;
- String results[]= UnixPrintServiceLookup.execCmd(command);
+ String results[]= PrintServiceLookupProvider.execCmd(command);
// Remove headers and bogus entries added by remote printers.
results = filterPrinterNamesAIX(results);
@@ -320,11 +320,11 @@
}
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
- if (UnixPrintServiceLookup.isSysV()) {
+ if (PrintServiceLookupProvider.isSysV()) {
return getPrinterIsAcceptingJobsSysV();
- } else if (UnixPrintServiceLookup.isBSD()) {
+ } else if (PrintServiceLookupProvider.isBSD()) {
return getPrinterIsAcceptingJobsBSD();
- } else if (UnixPrintServiceLookup.isAIX()) {
+ } else if (PrintServiceLookupProvider.isAIX()) {
return getPrinterIsAcceptingJobsAIX();
} else {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
@@ -351,29 +351,29 @@
private QueuedJobCount getQueuedJobCountSysV() {
String command = "/usr/bin/lpstat -R " + printer;
- String results[]= UnixPrintServiceLookup.execCmd(command);
+ String results[]= PrintServiceLookupProvider.execCmd(command);
int qlen = (results == null) ? 0 : results.length;
return new QueuedJobCount(qlen);
}
private QueuedJobCount getQueuedJobCountBSD() {
- if (UnixPrintServiceLookup.cmdIndex ==
- UnixPrintServiceLookup.UNINITIALIZED) {
+ if (PrintServiceLookupProvider.cmdIndex ==
+ PrintServiceLookupProvider.UNINITIALIZED) {
- UnixPrintServiceLookup.cmdIndex =
- UnixPrintServiceLookup.getBSDCommandIndex();
+ PrintServiceLookupProvider.cmdIndex =
+ PrintServiceLookupProvider.getBSDCommandIndex();
}
int qlen = 0;
String command = "/usr/sbin/lpc status " + printer
- + lpcQueueCom[UnixPrintServiceLookup.cmdIndex];
- String results[] = UnixPrintServiceLookup.execCmd(command);
+ + lpcQueueCom[PrintServiceLookupProvider.cmdIndex];
+ String results[] = PrintServiceLookupProvider.execCmd(command);
if (results != null && results.length > 0) {
String queued;
- if (UnixPrintServiceLookup.cmdIndex ==
- UnixPrintServiceLookup.BSD_LPD_NG) {
+ if (PrintServiceLookupProvider.cmdIndex ==
+ PrintServiceLookupProvider.BSD_LPD_NG) {
queued = results[0];
} else {
queued = results[3].trim();
@@ -396,7 +396,7 @@
private QueuedJobCount getQueuedJobCountAIX() {
// On AIX there should not be a blank after '-a'.
String command = "/usr/bin/lpstat -a" + printer;
- String results[]= UnixPrintServiceLookup.execCmd(command);
+ String results[]= PrintServiceLookupProvider.execCmd(command);
// Remove headers and bogus entries added by remote printers.
results = filterPrinterNamesAIX(results);
@@ -413,11 +413,11 @@
}
private QueuedJobCount getQueuedJobCount() {
- if (UnixPrintServiceLookup.isSysV()) {
+ if (PrintServiceLookupProvider.isSysV()) {
return getQueuedJobCountSysV();
- } else if (UnixPrintServiceLookup.isBSD()) {
+ } else if (PrintServiceLookupProvider.isBSD()) {
return getQueuedJobCountBSD();
- } else if (UnixPrintServiceLookup.isAIX()) {
+ } else if (PrintServiceLookupProvider.isAIX()) {
return getQueuedJobCountAIX();
} else {
return new QueuedJobCount(0);
@@ -468,9 +468,9 @@
}
private PrintServiceAttributeSet getDynamicAttributes() {
- if (UnixPrintServiceLookup.isSysV()) {
+ if (PrintServiceLookupProvider.isSysV()) {
return getSysVServiceAttributes();
- } else if (UnixPrintServiceLookup.isAIX()) {
+ } else if (PrintServiceLookupProvider.isAIX()) {
return getAIXServiceAttributes();
} else {
return getBSDServiceAttributes();
--- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintServiceLookup.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,964 +0,0 @@
-/*
- * Copyright (c) 2000, 2014, 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.
- */
-
-package sun.print;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Vector;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import javax.print.DocFlavor;
-import javax.print.MultiDocPrintService;
-import javax.print.PrintService;
-import javax.print.PrintServiceLookup;
-import javax.print.attribute.Attribute;
-import javax.print.attribute.AttributeSet;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.HashPrintServiceAttributeSet;
-import javax.print.attribute.PrintRequestAttribute;
-import javax.print.attribute.PrintRequestAttributeSet;
-import javax.print.attribute.PrintServiceAttribute;
-import javax.print.attribute.PrintServiceAttributeSet;
-import javax.print.attribute.standard.PrinterName;
-import javax.print.attribute.standard.PrinterURI;
-import java.io.File;
-import java.io.FileReader;
-import java.net.URL;
-import java.nio.file.Files;
-
-/*
- * Remind: This class uses solaris commands. We also need a linux
- * version
- */
-public class UnixPrintServiceLookup extends PrintServiceLookup
- implements BackgroundServiceLookup, Runnable {
-
- /* Remind: the current implementation is static, as its assumed
- * its preferable to minimize creation of PrintService instances.
- * Later we should add logic to add/remove services on the fly which
- * will take a hit of needing to regather the list of services.
- */
- private String defaultPrinter;
- private PrintService defaultPrintService;
- private PrintService[] printServices; /* includes the default printer */
- private Vector<BackgroundLookupListener> lookupListeners = null;
- private static String debugPrefix = "UnixPrintServiceLookup>> ";
- private static boolean pollServices = true;
- private static final int DEFAULT_MINREFRESH = 120; // 2 minutes
- private static int minRefreshTime = DEFAULT_MINREFRESH;
-
-
- static String osname;
-
- // List of commands used to deal with the printer queues on AIX
- String[] lpNameComAix = {
- "/usr/bin/lsallq",
- "/usr/bin/lpstat -W -p|/usr/bin/expand|/usr/bin/cut -f1 -d' '",
- "/usr/bin/lpstat -W -d|/usr/bin/expand|/usr/bin/cut -f1 -d' '",
- "/usr/bin/lpstat -W -v"
- };
- private static final int aix_lsallq = 0;
- private static final int aix_lpstat_p = 1;
- private static final int aix_lpstat_d = 2;
- private static final int aix_lpstat_v = 3;
- private static int aix_defaultPrinterEnumeration = aix_lsallq;
-
- static {
- /* The system property "sun.java2d.print.polling"
- * can be used to force the printing code to poll or not poll
- * for PrintServices.
- */
- String pollStr = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("sun.java2d.print.polling"));
-
- if (pollStr != null) {
- if (pollStr.equalsIgnoreCase("true")) {
- pollServices = true;
- } else if (pollStr.equalsIgnoreCase("false")) {
- pollServices = false;
- }
- }
-
- /* The system property "sun.java2d.print.minRefreshTime"
- * can be used to specify minimum refresh time (in seconds)
- * for polling PrintServices. The default is 120.
- */
- String refreshTimeStr = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction(
- "sun.java2d.print.minRefreshTime"));
-
- if (refreshTimeStr != null) {
- try {
- minRefreshTime = (new Integer(refreshTimeStr)).intValue();
- } catch (NumberFormatException e) {
- }
- if (minRefreshTime < DEFAULT_MINREFRESH) {
- minRefreshTime = DEFAULT_MINREFRESH;
- }
- }
-
- osname = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("os.name"));
-
- /* The system property "sun.java2d.print.aix.lpstat"
- * can be used to force the usage of 'lpstat -p' to enumerate all
- * printer queues. By default we use 'lsallq', because 'lpstat -p' can
- * take lots of time if thousands of printers are attached to a server.
- */
- if (isAIX()) {
- String aixPrinterEnumerator = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("sun.java2d.print.aix.lpstat"));
-
- if (aixPrinterEnumerator != null) {
- if (aixPrinterEnumerator.equalsIgnoreCase("lpstat")) {
- aix_defaultPrinterEnumeration = aix_lpstat_p;
- } else if (aixPrinterEnumerator.equalsIgnoreCase("lsallq")) {
- aix_defaultPrinterEnumeration = aix_lsallq;
- }
- }
- }
- }
-
- static boolean isMac() {
- return osname.startsWith("Mac");
- }
-
- static boolean isSysV() {
- return osname.equals("SunOS");
- }
-
- static boolean isLinux() {
- return (osname.equals("Linux"));
- }
-
- static boolean isBSD() {
- return (osname.equals("Linux") ||
- osname.contains("OS X"));
- }
-
- static boolean isAIX() {
- return osname.equals("AIX");
- }
-
- static final int UNINITIALIZED = -1;
- static final int BSD_LPD = 0;
- static final int BSD_LPD_NG = 1;
-
- static int cmdIndex = UNINITIALIZED;
-
- String[] lpcFirstCom = {
- "/usr/sbin/lpc status | grep : | sed -ne '1,1 s/://p'",
- "/usr/sbin/lpc status | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
- };
-
- String[] lpcAllCom = {
- "/usr/sbin/lpc status all | grep : | sed -e 's/://'",
- "/usr/sbin/lpc status all | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}' | sort"
- };
-
- String[] lpcNameCom = {
- "| grep : | sed -ne 's/://p'",
- "| grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
- };
-
-
- static int getBSDCommandIndex() {
- String command = "/usr/sbin/lpc status all";
- String[] names = execCmd(command);
-
- if ((names == null) || (names.length == 0)) {
- return BSD_LPD_NG;
- }
-
- for (int i=0; i<names.length; i++) {
- if (names[i].indexOf('@') != -1) {
- return BSD_LPD_NG;
- }
- }
-
- return BSD_LPD;
- }
-
-
- public UnixPrintServiceLookup() {
- // start the printer listener thread
- if (pollServices) {
- PrinterChangeListener thr = new PrinterChangeListener();
- thr.setDaemon(true);
- thr.start();
- IPPPrintService.debug_println(debugPrefix+"polling turned on");
- }
- }
-
- /* Want the PrintService which is default print service to have
- * equality of reference with the equivalent in list of print services
- * This isn't required by the API and there's a risk doing this will
- * lead people to assume its guaranteed.
- */
- public synchronized PrintService[] getPrintServices() {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
-
- if (printServices == null || !pollServices) {
- refreshServices();
- }
- if (printServices == null) {
- return new PrintService[0];
- } else {
- return printServices.clone();
- }
- }
-
- private int addPrintServiceToList(ArrayList<PrintService> printerList, PrintService ps) {
- int index = printerList.indexOf(ps);
- // Check if PrintService with same name is already in the list.
- if (CUPSPrinter.isCupsRunning() && index != -1) {
- // Bug in Linux: Duplicate entry of a remote printer
- // and treats it as local printer but it is returning wrong
- // information when queried using IPP. Workaround is to remove it.
- // Even CUPS ignores these entries as shown in lpstat or using
- // their web configuration.
- PrinterURI uri = ps.getAttribute(PrinterURI.class);
- if (uri.getURI().getHost().equals("localhost")) {
- IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, ignoring the new local printer: "+ps);
- return index; // Do not add this.
- }
- PrintService oldPS = printerList.get(index);
- uri = oldPS.getAttribute(PrinterURI.class);
- if (uri.getURI().getHost().equals("localhost")) {
- IPPPrintService.debug_println(debugPrefix+"duplicate PrintService, removing existing local printer: "+oldPS);
- printerList.remove(oldPS);
- } else {
- return index;
- }
- }
- printerList.add(ps);
- return (printerList.size() - 1);
- }
-
-
- // refreshes "printServices"
- public synchronized void refreshServices() {
- /* excludes the default printer */
- String[] printers = null; // array of printer names
- String[] printerURIs = null; //array of printer URIs
-
- try {
- getDefaultPrintService();
- } catch (Throwable t) {
- IPPPrintService.debug_println(debugPrefix+
- "Exception getting default printer : " + t);
- }
- if (CUPSPrinter.isCupsRunning()) {
- try {
- printerURIs = CUPSPrinter.getAllPrinters();
- IPPPrintService.debug_println("CUPS URIs = " + printerURIs);
- if (printerURIs != null) {
- for (int p = 0; p < printerURIs.length; p++) {
- IPPPrintService.debug_println("URI="+printerURIs[p]);
- }
- }
- } catch (Throwable t) {
- IPPPrintService.debug_println(debugPrefix+
- "Exception getting all CUPS printers : " + t);
- }
- if ((printerURIs != null) && (printerURIs.length > 0)) {
- printers = new String[printerURIs.length];
- for (int i=0; i<printerURIs.length; i++) {
- int lastIndex = printerURIs[i].lastIndexOf("/");
- printers[i] = printerURIs[i].substring(lastIndex+1);
- }
- }
- } else {
- if (isMac() || isSysV()) {
- printers = getAllPrinterNamesSysV();
- } else if (isAIX()) {
- printers = getAllPrinterNamesAIX();
- } else { //BSD
- printers = getAllPrinterNamesBSD();
- }
- }
-
- if (printers == null) {
- if (defaultPrintService != null) {
- printServices = new PrintService[1];
- printServices[0] = defaultPrintService;
- } else {
- printServices = null;
- }
- return;
- }
-
- ArrayList<PrintService> printerList = new ArrayList<>();
- int defaultIndex = -1;
- for (int p=0; p<printers.length; p++) {
- if (printers[p] == null) {
- continue;
- }
- if ((defaultPrintService != null)
- && printers[p].equals(getPrinterDestName(defaultPrintService))) {
- defaultIndex = addPrintServiceToList(printerList, defaultPrintService);
- } else {
- if (printServices == null) {
- IPPPrintService.debug_println(debugPrefix+
- "total# of printers = "+printers.length);
-
- if (CUPSPrinter.isCupsRunning()) {
- try {
- addPrintServiceToList(printerList,
- new IPPPrintService(printers[p],
- printerURIs[p],
- true));
- } catch (Exception e) {
- IPPPrintService.debug_println(debugPrefix+
- " getAllPrinters Exception "+
- e);
-
- }
- } else {
- printerList.add(new UnixPrintService(printers[p]));
- }
- } else {
- int j;
- for (j=0; j<printServices.length; j++) {
- if (printServices[j] != null) {
- if (printers[p].equals(getPrinterDestName(printServices[j]))) {
- printerList.add(printServices[j]);
- printServices[j] = null;
- break;
- }
- }
- }
-
- if (j == printServices.length) { // not found?
- if (CUPSPrinter.isCupsRunning()) {
- try {
- addPrintServiceToList(printerList,
- new IPPPrintService(printers[p],
- printerURIs[p],
- true));
- } catch (Exception e) {
- IPPPrintService.debug_println(debugPrefix+
- " getAllPrinters Exception "+
- e);
-
- }
- } else {
- printerList.add(new UnixPrintService(printers[p]));
- }
- }
- }
- }
- }
-
- // Look for deleted services and invalidate these
- if (printServices != null) {
- for (int j=0; j < printServices.length; j++) {
- if ((printServices[j] instanceof UnixPrintService) &&
- (!printServices[j].equals(defaultPrintService))) {
- ((UnixPrintService)printServices[j]).invalidateService();
- }
- }
- }
-
- //if defaultService is not found in printerList
- if (defaultIndex == -1 && defaultPrintService != null) {
- defaultIndex = addPrintServiceToList(printerList, defaultPrintService);
- }
-
- printServices = printerList.toArray(new PrintService[] {});
-
- // swap default with the first in the list
- if (defaultIndex > 0) {
- PrintService saveService = printServices[0];
- printServices[0] = printServices[defaultIndex];
- printServices[defaultIndex] = saveService;
- }
- }
-
- private boolean matchesAttributes(PrintService service,
- PrintServiceAttributeSet attributes) {
-
- Attribute [] attrs = attributes.toArray();
- for (int i=0; i<attrs.length; i++) {
- @SuppressWarnings("unchecked")
- Attribute serviceAttr
- = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
- if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
- return false;
- }
- }
- return true;
- }
-
- /* This checks for validity of the printer name before passing as
- * parameter to a shell command.
- */
- private boolean checkPrinterName(String s) {
- char c;
-
- for (int i=0; i < s.length(); i++) {
- c = s.charAt(i);
- if (Character.isLetterOrDigit(c) ||
- c == '-' || c == '_' || c == '.' || c == '/') {
- continue;
- } else {
- return false;
- }
- }
- return true;
- }
-
- /*
- * Gets the printer name compatible with the list of printers returned by
- * the system when we query default or all the available printers.
- */
- private String getPrinterDestName(PrintService ps) {
- if (isMac()) {
- return ((IPPPrintService)ps).getDest();
- }
- return ps.getName();
- }
-
- /* On a network with many (hundreds) of network printers, it
- * can save several seconds if you know all you want is a particular
- * printer, to ask for that printer rather than retrieving all printers.
- */
- private PrintService getServiceByName(PrinterName nameAttr) {
- String name = nameAttr.getValue();
- if (name == null || name.equals("") || !checkPrinterName(name)) {
- return null;
- }
- /* check if all printers are already available */
- if (printServices != null) {
- for (PrintService printService : printServices) {
- PrinterName printerName = printService.getAttribute(PrinterName.class);
- if (printerName.getValue().equals(name)) {
- return printService;
- }
- }
- }
- /* take CUPS into account first */
- if (CUPSPrinter.isCupsRunning()) {
- try {
- return new IPPPrintService(name,
- new URL("http://"+
- CUPSPrinter.getServer()+":"+
- CUPSPrinter.getPort()+"/"+
- name));
- } catch (Exception e) {
- IPPPrintService.debug_println(debugPrefix+
- " getServiceByName Exception "+
- e);
- }
- }
- /* fallback if nothing not having a printer at this point */
- PrintService printer = null;
- if (isMac() || isSysV()) {
- printer = getNamedPrinterNameSysV(name);
- } else if (isAIX()) {
- printer = getNamedPrinterNameAIX(name);
- } else {
- printer = getNamedPrinterNameBSD(name);
- }
- return printer;
- }
-
- private PrintService[]
- getPrintServices(PrintServiceAttributeSet serviceSet) {
-
- if (serviceSet == null || serviceSet.isEmpty()) {
- return getPrintServices();
- }
-
- /* Typically expect that if a service attribute is specified that
- * its a printer name and there ought to be only one match.
- * Directly retrieve that service and confirm
- * that it meets the other requirements.
- * If printer name isn't mentioned then go a slow path checking
- * all printers if they meet the reqiremements.
- */
- PrintService[] services;
- PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
- PrintService defService;
- if (name != null && (defService = getDefaultPrintService()) != null) {
- /* To avoid execing a unix command see if the client is asking
- * for the default printer by name, since we already have that
- * initialised.
- */
-
- PrinterName defName = defService.getAttribute(PrinterName.class);
-
- if (defName != null && name.equals(defName)) {
- if (matchesAttributes(defService, serviceSet)) {
- services = new PrintService[1];
- services[0] = defService;
- return services;
- } else {
- return new PrintService[0];
- }
- } else {
- /* Its not the default service */
- PrintService service = getServiceByName(name);
- if (service != null &&
- matchesAttributes(service, serviceSet)) {
- services = new PrintService[1];
- services[0] = service;
- return services;
- } else {
- return new PrintService[0];
- }
- }
- } else {
- /* specified service attributes don't include a name.*/
- Vector<PrintService> matchedServices = new Vector<>();
- services = getPrintServices();
- for (int i = 0; i< services.length; i++) {
- if (matchesAttributes(services[i], serviceSet)) {
- matchedServices.add(services[i]);
- }
- }
- services = new PrintService[matchedServices.size()];
- for (int i = 0; i< services.length; i++) {
- services[i] = matchedServices.elementAt(i);
- }
- return services;
- }
- }
-
- /*
- * If service attributes are specified then there must be additional
- * filtering.
- */
- public PrintService[] getPrintServices(DocFlavor flavor,
- AttributeSet attributes) {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
- PrintRequestAttributeSet requestSet = null;
- PrintServiceAttributeSet serviceSet = null;
-
- if (attributes != null && !attributes.isEmpty()) {
-
- requestSet = new HashPrintRequestAttributeSet();
- serviceSet = new HashPrintServiceAttributeSet();
-
- Attribute[] attrs = attributes.toArray();
- for (int i=0; i<attrs.length; i++) {
- if (attrs[i] instanceof PrintRequestAttribute) {
- requestSet.add(attrs[i]);
- } else if (attrs[i] instanceof PrintServiceAttribute) {
- serviceSet.add(attrs[i]);
- }
- }
- }
-
- PrintService[] services = getPrintServices(serviceSet);
- if (services.length == 0) {
- return services;
- }
-
- if (CUPSPrinter.isCupsRunning()) {
- ArrayList<PrintService> matchingServices = new ArrayList<>();
- for (int i=0; i<services.length; i++) {
- try {
- if (services[i].
- getUnsupportedAttributes(flavor, requestSet) == null) {
- matchingServices.add(services[i]);
- }
- } catch (IllegalArgumentException e) {
- }
- }
- services = new PrintService[matchingServices.size()];
- return matchingServices.toArray(services);
-
- } else {
- // We only need to compare 1 PrintService because all
- // UnixPrintServices are the same anyway. We will not use
- // default PrintService because it might be null.
- PrintService service = services[0];
- if ((flavor == null ||
- service.isDocFlavorSupported(flavor)) &&
- service.getUnsupportedAttributes(flavor, requestSet) == null)
- {
- return services;
- } else {
- return new PrintService[0];
- }
- }
- }
-
- /*
- * return empty array as don't support multi docs
- */
- public MultiDocPrintService[]
- getMultiDocPrintServices(DocFlavor[] flavors,
- AttributeSet attributes) {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
- return new MultiDocPrintService[0];
- }
-
-
- public synchronized PrintService getDefaultPrintService() {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
-
- // clear defaultPrintService
- defaultPrintService = null;
- String psuri = null;
-
- IPPPrintService.debug_println("isRunning ? "+
- (CUPSPrinter.isCupsRunning()));
- if (CUPSPrinter.isCupsRunning()) {
- String[] printerInfo = CUPSPrinter.getDefaultPrinter();
- if (printerInfo != null && printerInfo.length >= 2) {
- defaultPrinter = printerInfo[0];
- psuri = printerInfo[1];
- }
- } else {
- if (isMac() || isSysV()) {
- defaultPrinter = getDefaultPrinterNameSysV();
- } else if (isAIX()) {
- defaultPrinter = getDefaultPrinterNameAIX();
- } else {
- defaultPrinter = getDefaultPrinterNameBSD();
- }
- }
- if (defaultPrinter == null) {
- return null;
- }
- defaultPrintService = null;
- if (printServices != null) {
- for (int j=0; j<printServices.length; j++) {
- if (defaultPrinter.equals(getPrinterDestName(printServices[j]))) {
- defaultPrintService = printServices[j];
- break;
- }
- }
- }
- if (defaultPrintService == null) {
- if (CUPSPrinter.isCupsRunning()) {
- try {
- PrintService defaultPS;
- if ((psuri != null) && !psuri.startsWith("file")) {
- defaultPS = new IPPPrintService(defaultPrinter,
- psuri, true);
- } else {
- defaultPS = new IPPPrintService(defaultPrinter,
- new URL("http://"+
- CUPSPrinter.getServer()+":"+
- CUPSPrinter.getPort()+"/"+
- defaultPrinter));
- }
- defaultPrintService = defaultPS;
- } catch (Exception e) {
- }
- } else {
- defaultPrintService = new UnixPrintService(defaultPrinter);
- }
- }
-
- return defaultPrintService;
- }
-
- public synchronized void
- getServicesInbackground(BackgroundLookupListener listener) {
- if (printServices != null) {
- listener.notifyServices(printServices);
- } else {
- if (lookupListeners == null) {
- lookupListeners = new Vector<>();
- lookupListeners.add(listener);
- Thread lookupThread = new Thread(this);
- lookupThread.start();
- } else {
- lookupListeners.add(listener);
- }
- }
- }
-
- /* This method isn't used in most cases because we rely on code in
- * javax.print.PrintServiceLookup. This is needed just for the cases
- * where those interfaces are by-passed.
- */
- private PrintService[] copyOf(PrintService[] inArr) {
- if (inArr == null || inArr.length == 0) {
- return inArr;
- } else {
- PrintService []outArr = new PrintService[inArr.length];
- System.arraycopy(inArr, 0, outArr, 0, inArr.length);
- return outArr;
- }
- }
-
- public void run() {
- PrintService[] services = getPrintServices();
- synchronized (this) {
- BackgroundLookupListener listener;
- for (int i=0; i<lookupListeners.size(); i++) {
- listener = lookupListeners.elementAt(i);
- listener.notifyServices(copyOf(services));
- }
- lookupListeners = null;
- }
- }
-
- private String getDefaultPrinterNameBSD() {
- if (cmdIndex == UNINITIALIZED) {
- cmdIndex = getBSDCommandIndex();
- }
- String[] names = execCmd(lpcFirstCom[cmdIndex]);
- if (names == null || names.length == 0) {
- return null;
- }
-
- if ((cmdIndex==BSD_LPD_NG) &&
- (names[0].startsWith("missingprinter"))) {
- return null;
- }
- return names[0];
- }
-
- private PrintService getNamedPrinterNameBSD(String name) {
- if (cmdIndex == UNINITIALIZED) {
- cmdIndex = getBSDCommandIndex();
- }
- String command = "/usr/sbin/lpc status " + name + lpcNameCom[cmdIndex];
- String[] result = execCmd(command);
-
- if (result == null || !(result[0].equals(name))) {
- return null;
- }
- return new UnixPrintService(name);
- }
-
- private String[] getAllPrinterNamesBSD() {
- if (cmdIndex == UNINITIALIZED) {
- cmdIndex = getBSDCommandIndex();
- }
- String[] names = execCmd(lpcAllCom[cmdIndex]);
- if (names == null || names.length == 0) {
- return null;
- }
- return names;
- }
-
- static String getDefaultPrinterNameSysV() {
- String defaultPrinter = "lp";
- String command = "/usr/bin/lpstat -d";
-
- String [] names = execCmd(command);
- if (names == null || names.length == 0) {
- return defaultPrinter;
- } else {
- int index = names[0].indexOf(":");
- if (index == -1 || (names[0].length() <= index+1)) {
- return null;
- } else {
- String name = names[0].substring(index+1).trim();
- if (name.length() == 0) {
- return null;
- } else {
- return name;
- }
- }
- }
- }
-
- private PrintService getNamedPrinterNameSysV(String name) {
-
- String command = "/usr/bin/lpstat -v " + name;
- String []result = execCmd(command);
-
- if (result == null || result[0].indexOf("unknown printer") > 0) {
- return null;
- } else {
- return new UnixPrintService(name);
- }
- }
-
- private String[] getAllPrinterNamesSysV() {
- String defaultPrinter = "lp";
- String command = "/usr/bin/lpstat -v|/usr/bin/expand|/usr/bin/cut -f3 -d' ' |/usr/bin/cut -f1 -d':' | /usr/bin/sort";
-
- String [] names = execCmd(command);
- ArrayList<String> printerNames = new ArrayList<>();
- for (int i=0; i < names.length; i++) {
- if (!names[i].equals("_default") &&
- !names[i].equals(defaultPrinter) &&
- !names[i].equals("")) {
- printerNames.add(names[i]);
- }
- }
- return printerNames.toArray(new String[printerNames.size()]);
- }
-
- private String getDefaultPrinterNameAIX() {
- String[] names = execCmd(lpNameComAix[aix_lpstat_d]);
- // Remove headers and bogus entries added by remote printers.
- names = UnixPrintService.filterPrinterNamesAIX(names);
- if (names == null || names.length != 1) {
- // No default printer found
- return null;
- } else {
- return names[0];
- }
- }
-
- private PrintService getNamedPrinterNameAIX(String name) {
- // On AIX there should be no blank after '-v'.
- String[] result = execCmd(lpNameComAix[aix_lpstat_v] + name);
- // Remove headers and bogus entries added by remote printers.
- result = UnixPrintService.filterPrinterNamesAIX(result);
- if (result == null || result.length != 1) {
- return null;
- } else {
- return new UnixPrintService(name);
- }
- }
-
- private String[] getAllPrinterNamesAIX() {
- // Determine all printers of the system.
- String [] names = execCmd(lpNameComAix[aix_defaultPrinterEnumeration]);
-
- // Remove headers and bogus entries added by remote printers.
- names = UnixPrintService.filterPrinterNamesAIX(names);
-
- ArrayList<String> printerNames = new ArrayList<String>();
- for ( int i=0; i < names.length; i++) {
- printerNames.add(names[i]);
- }
- return printerNames.toArray(new String[printerNames.size()]);
- }
-
- static String[] execCmd(final String command) {
- ArrayList<String> results = null;
- try {
- final String[] cmd = new String[3];
- if (isSysV() || isAIX()) {
- cmd[0] = "/usr/bin/sh";
- cmd[1] = "-c";
- cmd[2] = "env LC_ALL=C " + command;
- } else {
- cmd[0] = "/bin/sh";
- cmd[1] = "-c";
- cmd[2] = "LC_ALL=C " + command;
- }
-
- results = AccessController.doPrivileged(
- new PrivilegedExceptionAction<ArrayList<String>>() {
- public ArrayList<String> run() throws IOException {
-
- Process proc;
- BufferedReader bufferedReader = null;
- File f = Files.createTempFile("prn","xc").toFile();
- cmd[2] = cmd[2]+">"+f.getAbsolutePath();
-
- proc = Runtime.getRuntime().exec(cmd);
- try {
- boolean done = false; // in case of interrupt.
- while (!done) {
- try {
- proc.waitFor();
- done = true;
- } catch (InterruptedException e) {
- }
- }
-
- if (proc.exitValue() == 0) {
- FileReader reader = new FileReader(f);
- bufferedReader = new BufferedReader(reader);
- String line;
- ArrayList<String> results = new ArrayList<>();
- while ((line = bufferedReader.readLine())
- != null) {
- results.add(line);
- }
- return results;
- }
- } finally {
- f.delete();
- // promptly close all streams.
- if (bufferedReader != null) {
- bufferedReader.close();
- }
- proc.getInputStream().close();
- proc.getErrorStream().close();
- proc.getOutputStream().close();
- }
- return null;
- }
- });
- } catch (PrivilegedActionException e) {
- }
- if (results == null) {
- return new String[0];
- } else {
- return results.toArray(new String[results.size()]);
- }
- }
-
- private class PrinterChangeListener extends Thread {
-
- public void run() {
- int refreshSecs;
- while (true) {
- try {
- refreshServices();
- } catch (Exception se) {
- IPPPrintService.debug_println(debugPrefix+"Exception in refresh thread.");
- break;
- }
-
- if ((printServices != null) &&
- (printServices.length > minRefreshTime)) {
- // compute new refresh time 1 printer = 1 sec
- refreshSecs = printServices.length;
- } else {
- refreshSecs = minRefreshTime;
- }
- try {
- sleep(refreshSecs * 1000);
- } catch (InterruptedException e) {
- break;
- }
- }
- }
- }
-}
--- a/jdk/src/java.desktop/unix/native/common/java2d/opengl/GLXGraphicsConfig.c Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/unix/native/common/java2d/opengl/GLXGraphicsConfig.c Thu Oct 30 13:56:09 2014 -0700
@@ -398,8 +398,8 @@
static GLXPbuffer
GLXGC_InitScratchPbuffer(GLXFBConfig fbconfig)
{
- int pbattrlist[] = {GLX_PBUFFER_WIDTH, 1,
- GLX_PBUFFER_HEIGHT, 1,
+ int pbattrlist[] = {GLX_PBUFFER_WIDTH, 4,
+ GLX_PBUFFER_HEIGHT, 4,
GLX_PRESERVED_CONTENTS, GL_FALSE,
0};
--- a/jdk/src/java.desktop/windows/classes/META-INF/services/javax.print.PrintServiceLookup Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Provider for Java Print Service
-sun.print.Win32PrintServiceLookup
--- a/jdk/src/java.desktop/windows/classes/META-INF/services/javax.print.StreamPrintServiceFactory Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Providers for Java 2D/JPS Stream print services.
-sun.print.PSStreamPrinterFactory
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java Thu Oct 30 13:56:09 2014 -0700
@@ -1400,7 +1400,9 @@
* The saved device transform is needed as the current transform
* is not likely to be the same.
*/
- deviceClip(savedClip.getPathIterator(savedTransform));
+ if (savedClip != null) {
+ deviceClip(savedClip.getPathIterator(savedTransform));
+ }
/* Scale the bounding rectangle by the scale transform.
* Because the scaling transform has only x and y
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Thu Oct 30 13:56:09 2014 -0700
@@ -93,7 +93,7 @@
import sun.print.SunPageSelection;
import sun.print.Win32MediaTray;
import sun.print.Win32PrintService;
-import sun.print.Win32PrintServiceLookup;
+import sun.print.PrintServiceLookupProvider;
import sun.print.ServiceDialog;
import sun.print.DialogOwner;
@@ -454,7 +454,7 @@
// native printer is different !
// we update the current PrintService
try {
- setPrintService(Win32PrintServiceLookup.
+ setPrintService(PrintServiceLookupProvider.
getWin32PrintLUS().
getPrintServiceByName(printerName));
} catch (PrinterException e) {
@@ -628,7 +628,7 @@
String printerName = getNativePrintService();
if (printerName != null) {
- myService = Win32PrintServiceLookup.getWin32PrintLUS().
+ myService = PrintServiceLookupProvider.getWin32PrintLUS().
getPrintServiceByName(printerName);
// no need to call setNativePrintService as this name is
// currently set in native
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2000, 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. 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.
+ */
+
+package sun.print;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import javax.print.DocFlavor;
+import javax.print.MultiDocPrintService;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.AttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.HashPrintServiceAttributeSet;
+import javax.print.attribute.PrintRequestAttribute;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.PrintServiceAttribute;
+import javax.print.attribute.PrintServiceAttributeSet;
+import javax.print.attribute.standard.PrinterName;
+
+public class PrintServiceLookupProvider extends PrintServiceLookup {
+
+ private String defaultPrinter;
+ private PrintService defaultPrintService;
+ private String[] printers; /* excludes the default printer */
+ private PrintService[] printServices; /* includes the default printer */
+
+ static {
+ java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Void>() {
+ public Void run() {
+ System.loadLibrary("awt");
+ return null;
+ }
+ });
+ }
+
+ /* The singleton win32 print lookup service.
+ * Code that is aware of this field and wants to use it must first
+ * see if its null, and if so instantiate it by calling a method such as
+ * javax.print.PrintServiceLookup.defaultPrintService() so that the
+ * same instance is stored there.
+ */
+ private static PrintServiceLookupProvider win32PrintLUS;
+
+ /* Think carefully before calling this. Preferably don't call it. */
+ public static PrintServiceLookupProvider getWin32PrintLUS() {
+ if (win32PrintLUS == null) {
+ /* This call is internally synchronized.
+ * When it returns an instance of this class will have
+ * been instantiated - else there's a JDK internal error.
+ */
+ PrintServiceLookup.lookupDefaultPrintService();
+ }
+ return win32PrintLUS;
+ }
+
+ public PrintServiceLookupProvider() {
+
+ if (win32PrintLUS == null) {
+ win32PrintLUS = this;
+
+ String osName = AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("os.name"));
+ // There's no capability for Win98 to refresh printers.
+ // See "OpenPrinter" for more info.
+ if (osName != null && osName.startsWith("Windows 98")) {
+ return;
+ }
+ // start the printer listener thread
+ PrinterChangeListener thr = new PrinterChangeListener();
+ thr.setDaemon(true);
+ thr.start();
+ } /* else condition ought to never happen! */
+ }
+
+ /* Want the PrintService which is default print service to have
+ * equality of reference with the equivalent in list of print services
+ * This isn't required by the API and there's a risk doing this will
+ * lead people to assume its guaranteed.
+ */
+ public synchronized PrintService[] getPrintServices() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+ if (printServices == null) {
+ refreshServices();
+ }
+ return printServices;
+ }
+
+ private synchronized void refreshServices() {
+ printers = getAllPrinterNames();
+ if (printers == null) {
+ // In Windows it is safe to assume no default if printers == null so we
+ // don't get the default.
+ printServices = new PrintService[0];
+ return;
+ }
+
+ PrintService[] newServices = new PrintService[printers.length];
+ PrintService defService = getDefaultPrintService();
+ for (int p = 0; p < printers.length; p++) {
+ if (defService != null &&
+ printers[p].equals(defService.getName())) {
+ newServices[p] = defService;
+ } else {
+ if (printServices == null) {
+ newServices[p] = new Win32PrintService(printers[p]);
+ } else {
+ int j;
+ for (j = 0; j < printServices.length; j++) {
+ if ((printServices[j]!= null) &&
+ (printers[p].equals(printServices[j].getName()))) {
+ newServices[p] = printServices[j];
+ printServices[j] = null;
+ break;
+ }
+ }
+ if (j == printServices.length) {
+ newServices[p] = new Win32PrintService(printers[p]);
+ }
+ }
+ }
+ }
+
+ // Look for deleted services and invalidate these
+ if (printServices != null) {
+ for (int j=0; j < printServices.length; j++) {
+ if ((printServices[j] instanceof Win32PrintService) &&
+ (!printServices[j].equals(defaultPrintService))) {
+ ((Win32PrintService)printServices[j]).invalidateService();
+ }
+ }
+ }
+ printServices = newServices;
+ }
+
+
+ public synchronized PrintService getPrintServiceByName(String name) {
+
+ if (name == null || name.equals("")) {
+ return null;
+ } else {
+ /* getPrintServices() is now very fast. */
+ PrintService[] printServices = getPrintServices();
+ for (int i=0; i<printServices.length; i++) {
+ if (printServices[i].getName().equals(name)) {
+ return printServices[i];
+ }
+ }
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked") // Cast to Class<PrintServiceAttribute>
+ boolean matchingService(PrintService service,
+ PrintServiceAttributeSet serviceSet) {
+ if (serviceSet != null) {
+ Attribute [] attrs = serviceSet.toArray();
+ Attribute serviceAttr;
+ for (int i=0; i<attrs.length; i++) {
+ serviceAttr
+ = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
+ if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public PrintService[] getPrintServices(DocFlavor flavor,
+ AttributeSet attributes) {
+
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+ PrintRequestAttributeSet requestSet = null;
+ PrintServiceAttributeSet serviceSet = null;
+
+ if (attributes != null && !attributes.isEmpty()) {
+
+ requestSet = new HashPrintRequestAttributeSet();
+ serviceSet = new HashPrintServiceAttributeSet();
+
+ Attribute[] attrs = attributes.toArray();
+ for (int i=0; i<attrs.length; i++) {
+ if (attrs[i] instanceof PrintRequestAttribute) {
+ requestSet.add(attrs[i]);
+ } else if (attrs[i] instanceof PrintServiceAttribute) {
+ serviceSet.add(attrs[i]);
+ }
+ }
+ }
+
+ /*
+ * Special case: If client is asking for a particular printer
+ * (by name) then we can save time by getting just that service
+ * to check against the rest of the specified attributes.
+ */
+ PrintService[] services = null;
+ if (serviceSet != null && serviceSet.get(PrinterName.class) != null) {
+ PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
+ PrintService service = getPrintServiceByName(name.getValue());
+ if (service == null || !matchingService(service, serviceSet)) {
+ services = new PrintService[0];
+ } else {
+ services = new PrintService[1];
+ services[0] = service;
+ }
+ } else {
+ services = getPrintServices();
+ }
+
+ if (services.length == 0) {
+ return services;
+ } else {
+ ArrayList<PrintService> matchingServices = new ArrayList<>();
+ for (int i=0; i<services.length; i++) {
+ try {
+ if (services[i].
+ getUnsupportedAttributes(flavor, requestSet) == null) {
+ matchingServices.add(services[i]);
+ }
+ } catch (IllegalArgumentException e) {
+ }
+ }
+ services = new PrintService[matchingServices.size()];
+ return matchingServices.toArray(services);
+ }
+ }
+
+ /*
+ * return empty array as don't support multi docs
+ */
+ public MultiDocPrintService[]
+ getMultiDocPrintServices(DocFlavor[] flavors,
+ AttributeSet attributes) {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+ return new MultiDocPrintService[0];
+ }
+
+
+ public synchronized PrintService getDefaultPrintService() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPrintJobAccess();
+ }
+
+
+ // Windows does not have notification for a change in default
+ // so we always get the latest.
+ defaultPrinter = getDefaultPrinterName();
+ if (defaultPrinter == null) {
+ return null;
+ }
+
+ if ((defaultPrintService != null) &&
+ defaultPrintService.getName().equals(defaultPrinter)) {
+
+ return defaultPrintService;
+ }
+
+ // Not the same as default so proceed to get new PrintService.
+
+ // clear defaultPrintService
+ defaultPrintService = null;
+
+ if (printServices != null) {
+ for (int j=0; j<printServices.length; j++) {
+ if (defaultPrinter.equals(printServices[j].getName())) {
+ defaultPrintService = printServices[j];
+ break;
+ }
+ }
+ }
+
+ if (defaultPrintService == null) {
+ defaultPrintService = new Win32PrintService(defaultPrinter);
+ }
+ return defaultPrintService;
+ }
+
+ class PrinterChangeListener extends Thread {
+ long chgObj;
+ PrinterChangeListener() {
+ chgObj = notifyFirstPrinterChange(null);
+ }
+
+ public void run() {
+ if (chgObj != -1) {
+ while (true) {
+ // wait for configuration to change
+ if (notifyPrinterChange(chgObj) != 0) {
+ try {
+ refreshServices();
+ } catch (SecurityException se) {
+ break;
+ }
+ } else {
+ notifyClosePrinterChange(chgObj);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private native String getDefaultPrinterName();
+ private native String[] getAllPrinterNames();
+ private native long notifyFirstPrinterChange(String printer);
+ private native void notifyClosePrinterChange(long chgObj);
+ private native int notifyPrinterChange(long chgObj);
+}
--- a/jdk/src/java.desktop/windows/classes/sun/print/Win32PrintServiceLookup.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/*
- * Copyright (c) 2000, 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. 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.
- */
-
-package sun.print;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import javax.print.DocFlavor;
-import javax.print.MultiDocPrintService;
-import javax.print.PrintService;
-import javax.print.PrintServiceLookup;
-import javax.print.attribute.Attribute;
-import javax.print.attribute.AttributeSet;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.HashPrintServiceAttributeSet;
-import javax.print.attribute.PrintRequestAttribute;
-import javax.print.attribute.PrintRequestAttributeSet;
-import javax.print.attribute.PrintServiceAttribute;
-import javax.print.attribute.PrintServiceAttributeSet;
-import javax.print.attribute.standard.PrinterName;
-
-public class Win32PrintServiceLookup extends PrintServiceLookup {
-
- private String defaultPrinter;
- private PrintService defaultPrintService;
- private String[] printers; /* excludes the default printer */
- private PrintService[] printServices; /* includes the default printer */
-
- static {
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Void>() {
- public Void run() {
- System.loadLibrary("awt");
- return null;
- }
- });
- }
-
- /* The singleton win32 print lookup service.
- * Code that is aware of this field and wants to use it must first
- * see if its null, and if so instantiate it by calling a method such as
- * javax.print.PrintServiceLookup.defaultPrintService() so that the
- * same instance is stored there.
- */
- private static Win32PrintServiceLookup win32PrintLUS;
-
- /* Think carefully before calling this. Preferably don't call it. */
- public static Win32PrintServiceLookup getWin32PrintLUS() {
- if (win32PrintLUS == null) {
- /* This call is internally synchronized.
- * When it returns an instance of this class will have
- * been instantiated - else there's a JDK internal error.
- */
- PrintServiceLookup.lookupDefaultPrintService();
- }
- return win32PrintLUS;
- }
-
- public Win32PrintServiceLookup() {
-
- if (win32PrintLUS == null) {
- win32PrintLUS = this;
-
- String osName = AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("os.name"));
- // There's no capability for Win98 to refresh printers.
- // See "OpenPrinter" for more info.
- if (osName != null && osName.startsWith("Windows 98")) {
- return;
- }
- // start the printer listener thread
- PrinterChangeListener thr = new PrinterChangeListener();
- thr.setDaemon(true);
- thr.start();
- } /* else condition ought to never happen! */
- }
-
- /* Want the PrintService which is default print service to have
- * equality of reference with the equivalent in list of print services
- * This isn't required by the API and there's a risk doing this will
- * lead people to assume its guaranteed.
- */
- public synchronized PrintService[] getPrintServices() {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
- if (printServices == null) {
- refreshServices();
- }
- return printServices;
- }
-
- private synchronized void refreshServices() {
- printers = getAllPrinterNames();
- if (printers == null) {
- // In Windows it is safe to assume no default if printers == null so we
- // don't get the default.
- printServices = new PrintService[0];
- return;
- }
-
- PrintService[] newServices = new PrintService[printers.length];
- PrintService defService = getDefaultPrintService();
- for (int p = 0; p < printers.length; p++) {
- if (defService != null &&
- printers[p].equals(defService.getName())) {
- newServices[p] = defService;
- } else {
- if (printServices == null) {
- newServices[p] = new Win32PrintService(printers[p]);
- } else {
- int j;
- for (j = 0; j < printServices.length; j++) {
- if ((printServices[j]!= null) &&
- (printers[p].equals(printServices[j].getName()))) {
- newServices[p] = printServices[j];
- printServices[j] = null;
- break;
- }
- }
- if (j == printServices.length) {
- newServices[p] = new Win32PrintService(printers[p]);
- }
- }
- }
- }
-
- // Look for deleted services and invalidate these
- if (printServices != null) {
- for (int j=0; j < printServices.length; j++) {
- if ((printServices[j] instanceof Win32PrintService) &&
- (!printServices[j].equals(defaultPrintService))) {
- ((Win32PrintService)printServices[j]).invalidateService();
- }
- }
- }
- printServices = newServices;
- }
-
-
- public synchronized PrintService getPrintServiceByName(String name) {
-
- if (name == null || name.equals("")) {
- return null;
- } else {
- /* getPrintServices() is now very fast. */
- PrintService[] printServices = getPrintServices();
- for (int i=0; i<printServices.length; i++) {
- if (printServices[i].getName().equals(name)) {
- return printServices[i];
- }
- }
- return null;
- }
- }
-
- @SuppressWarnings("unchecked") // Cast to Class<PrintServiceAttribute>
- boolean matchingService(PrintService service,
- PrintServiceAttributeSet serviceSet) {
- if (serviceSet != null) {
- Attribute [] attrs = serviceSet.toArray();
- Attribute serviceAttr;
- for (int i=0; i<attrs.length; i++) {
- serviceAttr
- = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
- if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
- return false;
- }
- }
- }
- return true;
- }
-
- public PrintService[] getPrintServices(DocFlavor flavor,
- AttributeSet attributes) {
-
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
- PrintRequestAttributeSet requestSet = null;
- PrintServiceAttributeSet serviceSet = null;
-
- if (attributes != null && !attributes.isEmpty()) {
-
- requestSet = new HashPrintRequestAttributeSet();
- serviceSet = new HashPrintServiceAttributeSet();
-
- Attribute[] attrs = attributes.toArray();
- for (int i=0; i<attrs.length; i++) {
- if (attrs[i] instanceof PrintRequestAttribute) {
- requestSet.add(attrs[i]);
- } else if (attrs[i] instanceof PrintServiceAttribute) {
- serviceSet.add(attrs[i]);
- }
- }
- }
-
- /*
- * Special case: If client is asking for a particular printer
- * (by name) then we can save time by getting just that service
- * to check against the rest of the specified attributes.
- */
- PrintService[] services = null;
- if (serviceSet != null && serviceSet.get(PrinterName.class) != null) {
- PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
- PrintService service = getPrintServiceByName(name.getValue());
- if (service == null || !matchingService(service, serviceSet)) {
- services = new PrintService[0];
- } else {
- services = new PrintService[1];
- services[0] = service;
- }
- } else {
- services = getPrintServices();
- }
-
- if (services.length == 0) {
- return services;
- } else {
- ArrayList<PrintService> matchingServices = new ArrayList<>();
- for (int i=0; i<services.length; i++) {
- try {
- if (services[i].
- getUnsupportedAttributes(flavor, requestSet) == null) {
- matchingServices.add(services[i]);
- }
- } catch (IllegalArgumentException e) {
- }
- }
- services = new PrintService[matchingServices.size()];
- return matchingServices.toArray(services);
- }
- }
-
- /*
- * return empty array as don't support multi docs
- */
- public MultiDocPrintService[]
- getMultiDocPrintServices(DocFlavor[] flavors,
- AttributeSet attributes) {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
- return new MultiDocPrintService[0];
- }
-
-
- public synchronized PrintService getDefaultPrintService() {
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- security.checkPrintJobAccess();
- }
-
-
- // Windows does not have notification for a change in default
- // so we always get the latest.
- defaultPrinter = getDefaultPrinterName();
- if (defaultPrinter == null) {
- return null;
- }
-
- if ((defaultPrintService != null) &&
- defaultPrintService.getName().equals(defaultPrinter)) {
-
- return defaultPrintService;
- }
-
- // Not the same as default so proceed to get new PrintService.
-
- // clear defaultPrintService
- defaultPrintService = null;
-
- if (printServices != null) {
- for (int j=0; j<printServices.length; j++) {
- if (defaultPrinter.equals(printServices[j].getName())) {
- defaultPrintService = printServices[j];
- break;
- }
- }
- }
-
- if (defaultPrintService == null) {
- defaultPrintService = new Win32PrintService(defaultPrinter);
- }
- return defaultPrintService;
- }
-
- class PrinterChangeListener extends Thread {
- long chgObj;
- PrinterChangeListener() {
- chgObj = notifyFirstPrinterChange(null);
- }
-
- public void run() {
- if (chgObj != -1) {
- while (true) {
- // wait for configuration to change
- if (notifyPrinterChange(chgObj) != 0) {
- try {
- refreshServices();
- } catch (SecurityException se) {
- break;
- }
- } else {
- notifyClosePrinterChange(chgObj);
- break;
- }
- }
- }
- }
- }
-
- private native String getDefaultPrinterName();
- private native String[] getAllPrinterNames();
- private native long notifyFirstPrinterChange(String printer);
- private native void notifyClosePrinterChange(long chgObj);
- private native int notifyPrinterChange(long chgObj);
-}
--- a/jdk/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Thu Oct 30 13:56:09 2014 -0700
@@ -68,7 +68,7 @@
extern "C" {
JNIEXPORT jstring JNICALL
-Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env,
+Java_sun_print_PrintServiceLookupProvider_getDefaultPrinterName(JNIEnv *env,
jobject peer)
{
TRY;
@@ -119,7 +119,7 @@
JNIEXPORT jobjectArray JNICALL
-Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames(JNIEnv *env,
+Java_sun_print_PrintServiceLookupProvider_getAllPrinterNames(JNIEnv *env,
jobject peer)
{
TRY;
@@ -176,7 +176,7 @@
JNIEXPORT jlong JNICALL
-Java_sun_print_Win32PrintServiceLookup_notifyFirstPrinterChange(JNIEnv *env,
+Java_sun_print_PrintServiceLookupProvider_notifyFirstPrinterChange(JNIEnv *env,
jobject peer,
jstring printer) {
HANDLE hPrinter;
@@ -210,7 +210,7 @@
JNIEXPORT void JNICALL
-Java_sun_print_Win32PrintServiceLookup_notifyClosePrinterChange(JNIEnv *env,
+Java_sun_print_PrintServiceLookupProvider_notifyClosePrinterChange(JNIEnv *env,
jobject peer,
jlong chgObject) {
FindClosePrinterChangeNotification((HANDLE)chgObject);
@@ -218,7 +218,7 @@
JNIEXPORT jint JNICALL
-Java_sun_print_Win32PrintServiceLookup_notifyPrinterChange(JNIEnv *env,
+Java_sun_print_PrintServiceLookupProvider_notifyPrinterChange(JNIEnv *env,
jobject peer,
jlong chgObject) {
DWORD dwChange;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp Thu Oct 30 13:56:09 2014 -0700
@@ -771,6 +771,17 @@
jint maxPage = env->CallIntMethod(printCtrl,
AwtPrintControl::getMaxPageID);
pd.nMaxPage = (maxPage <= (jint)((WORD)-1)) ? (WORD)maxPage : (WORD)-1;
+ // In the event that the application displays the dialog before
+ // installing a Printable, but sets a page range, then max page will be 1
+ // since the default state of a PrinterJob is an empty "Book" Pageable.
+ // Windows pops up an error dialog in such a case which isn't very
+ // forthcoming about the exact problem.
+ // So if we detect this fix up such a problem here.
+ if (pd.nMinPage > pd.nFromPage) pd.nMinPage = pd.nFromPage;
+ if (pd.nMaxPage < pd.nToPage) pd.nMaxPage = pd.nToPage;
+ if (pd.nFromPage > pd.nMinPage || pd.nToPage < pd.nMaxPage) {
+ pd.Flags |= PD_PAGENUMS;
+ }
if (env->CallBooleanMethod(printCtrl,
AwtPrintControl::getDestID)) {
--- a/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java Thu Oct 30 13:56:09 2014 -0700
@@ -47,7 +47,7 @@
* <code>DefaultLoaderRepository</code> be rewritten.</p>
*
* @deprecated Use
- * {@link javax.management.MBeanServer#getClassLoaderRepository()}}
+ * {@link javax.management.MBeanServer#getClassLoaderRepository()}
* instead.
*
* @since 1.5
--- a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -803,8 +803,10 @@
* @throws SQLException if a database access error occurs
* or the given column number is out of bounds
*/
- public boolean isDefinitelyWritable(int columnIndex)
- throws SQLException { return true;}
+ public boolean isDefinitelyWritable(int columnIndex) throws SQLException {
+ checkColRange(columnIndex);
+ return true;
+ }
/**
* Retrieves the fully-qualified name of the class in the Java
--- a/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.deploy.osx/macosx/classes/apple/security/KeychainStore.java Thu Oct 30 13:56:09 2014 -0700
@@ -140,7 +140,8 @@
* password to recover it.
*
* @param alias the alias name
- * @param password the password for recovering the key
+ * @param password the password for recovering the key. This password is
+ * used internally as the key is exported in a PKCS12 format.
*
* @return the requested key, or null if the given alias does not exist
* or does not identify a <i>key entry</i>.
@@ -155,6 +156,20 @@
{
permissionCheck();
+ // An empty password is rejected by MacOS API, no private key data
+ // is exported. If no password is passed (as is the case when
+ // this implementation is used as browser keystore in various
+ // deployment scenarios like Webstart, JFX and applets), create
+ // a dummy password so MacOS API is happy.
+ if (password == null || password.length == 0) {
+ // Must not be a char array with only a 0, as this is an empty
+ // string.
+ if (random == null) {
+ random = new SecureRandom();
+ }
+ password = Long.toString(random.nextLong()).toCharArray();
+ }
+
Object entry = entries.get(alias.toLowerCase());
if (entry == null || !(entry instanceof KeyEntry)) {
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", TRUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Thu Oct 30 13:56:09 2014 -0700
@@ -829,7 +829,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -917,6 +917,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Thu Oct 30 13:56:09 2014 -0700
@@ -831,7 +831,7 @@
{"Europe/Madrid", CET},
{"Europe/Malta", CET},
{"Europe/Mariehamn", EET},
- {"Europe/Minsk", FET},
+ {"Europe/Minsk", MSK},
{"Europe/Monaco", CET},
{"Europe/Moscow", MSK},
{"Europe/Nicosia", EET},
@@ -919,6 +919,9 @@
{"PRT", AST},
{"Pacific/Apia", WST_SAMOA},
{"Pacific/Auckland", NZST},
+ {"Pacific/Bougainville", new String[] {"Bougainville Standard Time", "BST",
+ "Bougainville Daylight Time", "BST",
+ "Bougainville Time", "BT"}},
{"Pacific/Chatham", CHAST},
{"Pacific/Chuuk", CHUT},
{"Pacific/Easter", EASTER},
--- a/jdk/test/ProblemList.txt Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/ProblemList.txt Thu Oct 30 13:56:09 2014 -0700
@@ -200,6 +200,9 @@
# jdk_rmi
+# 7140992
+java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
+
# 7146541
java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
--- a/jdk/test/TEST.ROOT Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/TEST.ROOT Thu Oct 30 13:56:09 2014 -0700
@@ -12,3 +12,6 @@
# Group definitions
groups=TEST.groups [closed/TEST.groups]
+
+# Tests using jtreg 4.1 b10 features
+requiredVersion=4.1 b10
--- a/jdk/test/com/sun/jdi/OptionTest.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/com/sun/jdi/OptionTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014, 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
@@ -34,9 +34,11 @@
*/
import java.net.ServerSocket;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class OptionTest extends Object {
- private Process subprocess;
+ private static final Pattern TRANSPORT_ERROR_PTRN = Pattern.compile("^ERROR: transport error .+$", Pattern.MULTILINE);
private int subprocessStatus;
private static final String CR = System.getProperty("line.separator");
private static final int BUFFERSIZE = 4096;
@@ -153,7 +155,7 @@
OptionTest myTest = new OptionTest();
String results [] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
if (!(results[RETSTAT].equals("0")) ||
- (results[STDERR].startsWith("ERROR:"))) {
+ (TRANSPORT_ERROR_PTRN.matcher(results[STDERR]).find())) {
throw new Exception("Test failed: jdwp doesn't like " + cmds[1]);
}
}
@@ -179,7 +181,7 @@
OptionTest myTest = new OptionTest();
String results[] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
- if (!results[RETSTAT].equals("0") && results[STDERR].startsWith("ERROR:")) {
+ if (!results[RETSTAT].equals("0") && TRANSPORT_ERROR_PTRN.matcher(results[STDERR]).find()) {
// We got expected error, test passed
}
else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Container/ContainerAIOOBE/ContainerAIOOBE.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, 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.awt.Button;
+import java.awt.Component;
+import java.awt.Container;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * @test
+ * @bug 8059590
+ * @summary ArrayIndexOutOfBoundsException occurs when Container with overridden getComponents() is deserialized.
+ * @author Alexey Ivanov
+ * @run main ContainerAIOOBE
+ */
+public class ContainerAIOOBE {
+
+ public static void main(final String[] args) throws Exception {
+ ZContainer z = new ZContainer();
+ z.add(new Button());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(z);
+ oos.flush();
+ oos.close();
+
+ byte[] array = baos.toByteArray();
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array));
+
+ // Reading the object must not throw ArrayIndexOutOfBoundsException
+ ZContainer zz = (ZContainer) ois.readObject();
+
+ if (zz.getComponentCount() != 1) {
+ throw new Exception("deserialized object must have 1 component");
+ }
+ if (!(zz.getComponent(0) instanceof Button)) {
+ throw new Exception("deserialized object must contain Button component");
+ }
+ if (zz.getComponents().length != 0) {
+ throw new Exception("deserialized object returns non-empty array");
+ }
+ System.out.println("Test passed");
+ }
+
+ static class ZContainer extends Container {
+ public Component[] getComponents() {
+ return new Component[0];
+ }
+ }
+}
--- a/jdk/test/java/awt/GraphicsDevice/CloneConfigsTest.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/awt/GraphicsDevice/CloneConfigsTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6822057 7124400
+ * @bug 6822057 7124400 8059848
*
* @summary Test verifies that list of supported graphics configurations
* can not be changed via modification of elements of an array
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/color/LoadProfileWithSM.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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.awt.color.*;
+
+/*
+ * @test
+ * @bug 8058969
+ * @summary test standard profiles loads with SecurityManager installed.
+ * @run main/othervm LoadProfileWithSM
+ */
+
+public class LoadProfileWithSM {
+
+ public static void main(String[] args) {
+ System.setSecurityManager(new SecurityManager());
+ ICC_Profile profile =
+ ((ICC_ColorSpace)(ColorSpace.getInstance(
+ ColorSpace.CS_GRAY))).getProfile();
+ /* request profile data in order to force profile loading */
+ profile.getData();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/DrawImage/IncorrectClipXorModeSW2Surface.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2014, 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.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import static java.awt.geom.Rectangle2D.Double;
+
+/**
+ * @test
+ * @bug 8061456
+ * @summary Tests drawing BI to volatile image using different clips + xor mode.
+ * Results of the blit BI to compatibleImage is used for comparison.
+ * @author Sergey Bylokhov
+ */
+public final class IncorrectClipXorModeSW2Surface {
+
+ private static int[] SIZES = {2, 10, 100};
+ private static final Shape[] SHAPES = {
+ new Rectangle(0, 0, 0, 0),
+ new Rectangle(0, 0, 1, 1),
+ new Rectangle(0, 1, 1, 1),
+ new Rectangle(1, 0, 1, 1),
+ new Rectangle(1, 1, 1, 1),
+
+ new Double(0, 0, 0.5, 0.5),
+ new Double(0, 0.5, 0.5, 0.5),
+ new Double(0.5, 0, 0.5, 0.5),
+ new Double(0.5, 0.5, 0.5, 0.5),
+ new Double(0.25, 0.25, 0.5, 0.5),
+ new Double(0, 0.25, 1, 0.5),
+ new Double(0.25, 0, 0.5, 1),
+
+ new Double(.10, .10, .20, .20),
+ new Double(.75, .75, .20, .20),
+ new Double(.75, .10, .20, .20),
+ new Double(.10, .75, .20, .20),
+ };
+
+ public static void main(final String[] args) throws IOException {
+ GraphicsEnvironment ge = GraphicsEnvironment
+ .getLocalGraphicsEnvironment();
+ GraphicsConfiguration gc = ge.getDefaultScreenDevice()
+ .getDefaultConfiguration();
+ AffineTransform at;
+ for (int size : SIZES) {
+ at = AffineTransform.getScaleInstance(size, size);
+ for (Shape clip : SHAPES) {
+ clip = at.createTransformedShape(clip);
+ for (Shape to : SHAPES) {
+ to = at.createTransformedShape(to);
+ // Prepare test images
+ BufferedImage snapshot;
+ BufferedImage bi = getBufferedImage(size);
+ VolatileImage vi = getVolatileImage(gc, size);
+ while (true) {
+ vi.validate(gc);
+ Graphics2D g2d = vi.createGraphics();
+ g2d.setColor(Color.GREEN);
+ g2d.fillRect(0, 0, size, size);
+ g2d.dispose();
+ if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
+ continue;
+ }
+ draw(clip, to, bi, vi);
+ snapshot = vi.getSnapshot();
+ if (vi.contentsLost()) {
+ continue;
+ }
+ break;
+ }
+ // Prepare gold images
+ BufferedImage goldvi = getCompatibleImage(gc, size);
+ BufferedImage goldbi = getBufferedImage(size);
+ draw(clip, to, goldbi, goldvi);
+ validate(snapshot, goldvi);
+ vi.flush();
+ }
+ }
+ }
+ }
+
+ private static void draw(Shape clip, Shape shape, Image from, Image to) {
+ Graphics2D g2d = (Graphics2D) to.getGraphics();
+ g2d.setXORMode(Color.BLACK);
+ g2d.setClip(clip);
+ Rectangle toBounds = shape.getBounds();
+ g2d.drawImage(from, toBounds.x, toBounds.y, toBounds.width,
+ toBounds.height, null);
+ g2d.dispose();
+ }
+
+ private static BufferedImage getBufferedImage(int sw) {
+ final BufferedImage bi = new BufferedImage(sw, sw, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bi.createGraphics();
+ g2d.setColor(Color.RED);
+ g2d.fillRect(0, 0, sw, sw);
+ g2d.dispose();
+
+ final DataBuffer db = bi.getRaster().getDataBuffer();
+ if (db instanceof DataBufferInt) {
+ ((DataBufferInt) db).getData();
+ } else if (db instanceof DataBufferShort) {
+ ((DataBufferShort) db).getData();
+ } else if (db instanceof DataBufferByte) {
+ ((DataBufferByte) db).getData();
+ } else {
+ try {
+ bi.setAccelerationPriority(0.0f);
+ } catch (final Throwable ignored) {
+ }
+ }
+ return bi;
+ }
+
+ private static VolatileImage getVolatileImage(GraphicsConfiguration gc,
+ int size) {
+ return gc.createCompatibleVolatileImage(size, size);
+ }
+
+ private static BufferedImage getCompatibleImage(GraphicsConfiguration gc,
+ int size) {
+ BufferedImage image = gc.createCompatibleImage(size, size);
+ Graphics2D g2d = image.createGraphics();
+ g2d.setColor(Color.GREEN);
+ g2d.fillRect(0, 0, size, size);
+ g2d.dispose();
+ return image;
+ }
+
+ private static void validate(BufferedImage bi, BufferedImage goldbi)
+ throws IOException {
+ for (int x = 0; x < bi.getWidth(); ++x) {
+ for (int y = 0; y < bi.getHeight(); ++y) {
+ if (goldbi.getRGB(x, y) != bi.getRGB(x, y)) {
+ ImageIO.write(bi, "png", new File("actual.png"));
+ ImageIO.write(goldbi, "png", new File("expected.png"));
+ throw new RuntimeException("Test failed.");
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/DrawImage/IncorrectUnmanagedImageSourceOffset.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2014, 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.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.VolatileImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import static java.awt.Transparency.*;
+import static java.awt.image.BufferedImage.*;
+
+/**
+ * @test
+ * @bug 8029253
+ * @summary Tests asymmetric source offsets when unmanaged image is drawn to VI.
+ * Results of the blit to compatibleImage are used for comparison.
+ * @author Sergey Bylokhov
+ */
+public final class IncorrectUnmanagedImageSourceOffset {
+
+ private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB,
+ TYPE_INT_ARGB_PRE, TYPE_INT_BGR,
+ TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR,
+ TYPE_4BYTE_ABGR_PRE,
+ /*TYPE_USHORT_565_RGB,
+ TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY,
+ TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY,
+ TYPE_BYTE_INDEXED};
+ private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT};
+
+ public static void main(final String[] args) throws IOException {
+ for (final int viType : TRANSPARENCIES) {
+ for (final int biType : TYPES) {
+ BufferedImage bi = makeUnmanagedBI(biType);
+ fill(bi);
+ test(bi, viType);
+ }
+ }
+ }
+
+ private static void test(BufferedImage bi, int type)
+ throws IOException {
+ GraphicsEnvironment ge = GraphicsEnvironment
+ .getLocalGraphicsEnvironment();
+ GraphicsConfiguration gc = ge.getDefaultScreenDevice()
+ .getDefaultConfiguration();
+ VolatileImage vi = gc.createCompatibleVolatileImage(511, 255, type);
+ BufferedImage gold = gc.createCompatibleImage(511, 255, type);
+ // draw to compatible Image
+ Graphics2D big = gold.createGraphics();
+ // force scaled blit
+ big.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null);
+ big.dispose();
+ // draw to volatile image
+ BufferedImage snapshot;
+ while (true) {
+ vi.validate(gc);
+ if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
+ try {
+ Thread.sleep(100);
+ } catch (final InterruptedException ignored) {
+ }
+ continue;
+ }
+ Graphics2D vig = vi.createGraphics();
+ // force scaled blit
+ vig.drawImage(bi, 7, 11, 127, 111, 7, 11, 127 * 2, 111, null);
+ vig.dispose();
+ snapshot = vi.getSnapshot();
+ if (vi.contentsLost()) {
+ try {
+ Thread.sleep(100);
+ } catch (final InterruptedException ignored) {
+ }
+ continue;
+ }
+ break;
+ }
+ // validate images
+ for (int x = 7; x < 127; ++x) {
+ for (int y = 11; y < 111; ++y) {
+ if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) {
+ ImageIO.write(gold, "png", new File("gold.png"));
+ ImageIO.write(snapshot, "png", new File("bi.png"));
+ throw new RuntimeException("Test failed.");
+ }
+ }
+ }
+ }
+
+ private static BufferedImage makeUnmanagedBI(final int type) {
+ final BufferedImage bi = new BufferedImage(511, 255, type);
+ final DataBuffer db = bi.getRaster().getDataBuffer();
+ if (db instanceof DataBufferInt) {
+ ((DataBufferInt) db).getData();
+ } else if (db instanceof DataBufferShort) {
+ ((DataBufferShort) db).getData();
+ } else if (db instanceof DataBufferByte) {
+ ((DataBufferByte) db).getData();
+ } else {
+ try {
+ bi.setAccelerationPriority(0.0f);
+ } catch (final Throwable ignored) {
+ }
+ }
+ return bi;
+ }
+
+ private static void fill(final Image image) {
+ final Graphics2D graphics = (Graphics2D) image.getGraphics();
+ graphics.setComposite(AlphaComposite.Src);
+ for (int i = 0; i < image.getHeight(null); ++i) {
+ graphics.setColor(new Color(i, 0, 0));
+ graphics.fillRect(0, i, image.getWidth(null), 1);
+ }
+ graphics.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/DrawImage/UnmanagedDrawImagePerformance.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2014, 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.awt.AlphaComposite;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Polygon;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.VolatileImage;
+
+import static java.awt.Transparency.*;
+import static java.awt.image.BufferedImage.*;
+
+/*
+ * @test
+ * @bug 8029253
+ * @summary Unmanaged images should be drawn fast.
+ * @author Sergey Bylokhov
+ */
+public final class UnmanagedDrawImagePerformance {
+
+ private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB,
+ TYPE_INT_ARGB_PRE, TYPE_INT_BGR,
+ TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR,
+ TYPE_4BYTE_ABGR_PRE,
+ TYPE_USHORT_565_RGB,
+ TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY,
+ TYPE_USHORT_GRAY, TYPE_BYTE_BINARY,
+ TYPE_BYTE_INDEXED};
+ private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT};
+ private static final int SIZE = 1000;
+ private static final AffineTransform[] TRANSFORMS = {
+ AffineTransform.getScaleInstance(.5, .5),
+ AffineTransform.getScaleInstance(1, 1),
+ AffineTransform.getScaleInstance(2, 2),
+ AffineTransform.getShearInstance(7, 11)};
+
+ public static void main(final String[] args) {
+ for (final AffineTransform atfm : TRANSFORMS) {
+ for (final int viType : TRANSPARENCIES) {
+ for (final int biType : TYPES) {
+ final BufferedImage bi = makeUnmanagedBI(biType);
+ final VolatileImage vi = makeVI(viType);
+ final long time = test(bi, vi, atfm) / 1000000000;
+ if (time > 1) {
+ throw new RuntimeException(String.format(
+ "drawImage is slow: %d seconds", time));
+ }
+ }
+ }
+ }
+ }
+
+ private static long test(Image bi, Image vi, AffineTransform atfm) {
+ final Polygon p = new Polygon();
+ p.addPoint(0, 0);
+ p.addPoint(SIZE, 0);
+ p.addPoint(0, SIZE);
+ p.addPoint(SIZE, SIZE);
+ p.addPoint(0, 0);
+ Graphics2D g2d = (Graphics2D) vi.getGraphics();
+ g2d.clip(p);
+ g2d.transform(atfm);
+ g2d.setComposite(AlphaComposite.SrcOver);
+ final long start = System.nanoTime();
+ g2d.drawImage(bi, 0, 0, null);
+ final long time = System.nanoTime() - start;
+ g2d.dispose();
+ return time;
+ }
+
+ private static VolatileImage makeVI(final int type) {
+ final GraphicsEnvironment ge = GraphicsEnvironment
+ .getLocalGraphicsEnvironment();
+ final GraphicsDevice gd = ge.getDefaultScreenDevice();
+ final GraphicsConfiguration gc = gd.getDefaultConfiguration();
+ return gc.createCompatibleVolatileImage(SIZE, SIZE, type);
+ }
+
+ private static BufferedImage makeUnmanagedBI(final int type) {
+ final BufferedImage img = new BufferedImage(SIZE, SIZE, type);
+ final DataBuffer db = img.getRaster().getDataBuffer();
+ if (db instanceof DataBufferInt) {
+ ((DataBufferInt) db).getData();
+ } else if (db instanceof DataBufferShort) {
+ ((DataBufferShort) db).getData();
+ } else if (db instanceof DataBufferByte) {
+ ((DataBufferByte) db).getData();
+ } else {
+ try {
+ img.setAccelerationPriority(0.0f);
+ } catch (final Throwable ignored) {
+ }
+ }
+ return img;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, 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 8061392
+ * @summary Test no NPE when printing transparency with null clip.
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import java.awt.print.*;
+
+public class NullClipARGB implements Printable {
+
+ public static void main( String[] args ) {
+
+ try {
+ PrinterJob pj = PrinterJob.getPrinterJob();
+ pj.setPrintable(new NullClipARGB());
+ pj.print();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public int print(Graphics g, PageFormat pf, int pageIndex)
+ throws PrinterException{
+
+ if (pageIndex != 0) {
+ return NO_SUCH_PAGE;
+ }
+ Graphics2D g2 = (Graphics2D)g;
+ System.out.println("original clip="+g2.getClip());
+ g2.translate(pf.getImageableX(), pf.getImageableY());
+ g2.rotate(0.2);
+ g2.setClip(null);
+ g2.setColor( Color.BLACK );
+ g2.drawString("This text should be visible through the image", 0, 20);
+ BufferedImage bi = new BufferedImage(100, 100,
+ BufferedImage.TYPE_INT_ARGB );
+ Graphics ig = bi.createGraphics();
+ ig.setColor( new Color( 192, 192, 192, 80 ) );
+ ig.fillRect( 0, 0, 100, 100 );
+ ig.setColor( Color.BLACK );
+ ig.drawRect( 0, 0, 99, 99 );
+ ig.dispose();
+ g2.drawImage(bi, 10, 0, 90, 90, null );
+ g2.translate(100, 100);
+ g2.drawString("This text should also be visible through the image", 0, 20);
+ g2.drawImage(bi, 10, 0, 90, 90, null );
+ return PAGE_EXISTS;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/PageRangesDlgTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014, 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 8061267
+ * @summary The specified page range should be displayed in the dialog
+ * @run main/manual=yesno PageRangesDlgTest
+ */
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.awt.*;
+import java.awt.print.*;
+
+public class PageRangesDlgTest implements Printable {
+
+ static String[] instr = {
+ "This test is to check that the print dialog displays the specified",
+ "page ranges. You must have a printer installed for this test.",
+ "It is valid only on dialogs which support page ranges",
+ "In each dialog, check that a page range of 2 to 3 is requested",
+ "Optionally press Print instead of Cancel, and verify that the",
+ "correct number/set of pages is printed",
+ };
+
+ public static void main(String args[]) throws Exception {
+ for (int i=0;i<instr.length;i++) {
+ System.out.println(instr[i]);
+ }
+ PrinterJob job = PrinterJob.getPrinterJob();
+ if (job.getPrintService() == null) {
+ System.out.println("No printers. Test cannot continue.");
+ return;
+ }
+ job.setPrintable(new PageRangesDlgTest());
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ aset.add(new PageRanges(2,3));
+ if (job.printDialog(aset)) {
+ job.print(aset);
+ }
+
+ job = PrinterJob.getPrinterJob();
+ job.setPrintable(new PageRangesDlgTest());
+ aset.add(DialogTypeSelection.NATIVE);
+ if (job.printDialog()) {
+ job.print();
+ }
+ }
+
+ public int print(Graphics g, PageFormat pf, int pi)
+ throws PrinterException {
+
+ System.out.println("pi="+pi);
+ if (pi >= 5) {
+ return NO_SUCH_PAGE;
+ }
+
+ g.drawString("Page : " + (pi+1), 200, 200);
+
+ return PAGE_EXISTS;
+ }
+}
--- a/jdk/test/java/io/FileDescriptor/Finalize.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/io/FileDescriptor/Finalize.java Thu Oct 30 13:56:09 2014 -0700
@@ -245,9 +245,10 @@
* write to fc2 - when fos1 is gc'ed and finalizer is run,
* write to fc2 should not fail
*/
- bb = ByteBuffer.allocateDirect(data.length);
- bb = bb.put(data);
- bb = (ByteBuffer) bb.flip();
+ bb = ByteBuffer.allocateDirect(data.length)
+ .put(data)
+ .flip();
+
ret = fc2.write(bb);
System.out.println("Wrote:" + ret + " bytes to fc2");
fc2.close();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/FileDescriptor/RememberAppend.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 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 8023173
+ * @summary FileDescriptor should respect append flag
+ */
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
+
+public class RememberAppend {
+ private static final byte[] bytes = "ABC ".getBytes();
+
+ public static void main(String[] args) throws Throwable {
+ File f = File.createTempFile("tmp.file", null);
+ f.deleteOnExit();
+
+ try (FileOutputStream fos1 = new FileOutputStream(f.getPath(), true)) {
+ fos1.write(bytes);
+ }
+
+ try (FileOutputStream fos1 = new FileOutputStream(f.getPath(), true);
+ FileOutputStream fos2 = new FileOutputStream(fos1.getFD())) {
+ fos2.write(bytes);
+ }
+
+ if (f.length() != 2 * bytes.length) {
+ throw new RuntimeException("Append flag ignored");
+ }
+ }
+}
--- a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThread.java Thu Oct 30 13:56:09 2014 -0700
@@ -28,7 +28,7 @@
*
* @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
* @run shell ../MakeJAR3.sh DummyAgent
- * @run main TestDaemonThreadLauncher /timeout=240
+ * @run main/timeout=240 TestDaemonThreadLauncher
*
*/
import java.io.File;
--- a/jdk/test/java/net/URLPermission/URLTest.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/net/URLPermission/URLTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -29,11 +29,11 @@
* @bug 8010464
* @library /lib/testlibrary/
* @build jdk.testlibrary.SimpleSSLContext
- * @run main/othervm/policy=policy.1 URLTest one
+ * @run main/othervm/java.security.policy=policy.1 URLTest one
* @run main/othervm URLTest one
- * @run main/othervm/policy=policy.2 URLTest two
+ * @run main/othervm/java.security.policy=policy.2 URLTest two
* @run main/othervm URLTest two
- * @run main/othervm/policy=policy.3 URLTest three
+ * @run main/othervm/java.security.policy=policy.3 URLTest three
* @run main/othervm URLTest three
*/
--- a/jdk/test/java/net/URLPermission/policy.1 Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/net/URLPermission/policy.1 Thu Oct 30 13:56:09 2014 -0700
@@ -37,60 +37,3 @@
permission "java.util.PropertyPermission" "test.src.path", "read";
};
-// Normal permissions that aren't granted when run under jtreg
-grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
- permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
- permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
- permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunec";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunEC";
- permission java.security.SecurityPermission "clearProviderProperties.SunEC";
- permission java.security.SecurityPermission "removeProviderProperty.SunEC";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
- Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
- permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
- permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
-};
-
-grant codeBase "file:${{java.home}}/jre/lib/rt.jar" {
- permission java.security.AllPermission;
-};
-
--- a/jdk/test/java/net/URLPermission/policy.2 Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/net/URLPermission/policy.2 Thu Oct 30 13:56:09 2014 -0700
@@ -37,60 +37,3 @@
permission "java.util.PropertyPermission" "test.src.path", "read";
};
-// Normal permissions that aren't granted when run under jtreg
-grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
- permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
- permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
- permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunec";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunEC";
- permission java.security.SecurityPermission "clearProviderProperties.SunEC";
- permission java.security.SecurityPermission "removeProviderProperty.SunEC";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
- Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
- permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
- permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
-};
-
-grant codeBase "file:///export/repos/jdk8/build/linux-x86_64-normal-server-fastdebug/images/j2sdk-image/jre/lib/rt.jar" {
- permission java.security.AllPermission;
-};
-
--- a/jdk/test/java/net/URLPermission/policy.3 Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/net/URLPermission/policy.3 Thu Oct 30 13:56:09 2014 -0700
@@ -36,61 +36,3 @@
permission "java.lang.RuntimePermission" "setFactory";
permission "java.util.PropertyPermission" "test.src.path", "read";
};
-
-// Normal permissions that aren't granted when run under jtreg
-grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
- permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
- permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
- permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunec";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunEC";
- permission java.security.SecurityPermission "clearProviderProperties.SunEC";
- permission java.security.SecurityPermission "removeProviderProperty.SunEC";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
- Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
- permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
- permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
-};
-
-grant codeBase "file:${{java.home}}/jre/lib/rt.jar" {
- permission java.security.AllPermission;
-};
-
--- a/jdk/test/java/nio/charset/CharsetEncoder/Flush.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/nio/charset/CharsetEncoder/Flush.java Thu Oct 30 13:56:09 2014 -0700
@@ -35,7 +35,7 @@
public class Flush {
private static byte[] contents(ByteBuffer bb) {
byte[] contents = new byte[bb.position()];
- ((ByteBuffer)(bb.duplicate().flip())).get(contents);
+ bb.duplicate().flip().get(contents);
return contents;
}
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java Thu Oct 30 13:56:09 2014 -0700
@@ -33,7 +33,7 @@
* @library ../../../testlibrary
* @build TestLibrary RMID ActivationLibrary
* ActivateMe ActivateFails_Stub ShutdownThread
- * @run main/othervm/policy=security.policy/timeout=240 ActivateFails
+ * @run main/othervm/java.security.policy=security.policy/timeout=240 ActivateFails
*/
import java.rmi.*;
--- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/security.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/security.policy Thu Oct 30 13:56:09 2014 -0700
@@ -2,10 +2,6 @@
* security policy used by the test process
*/
-grant codeBase "file:${java.home}/lib/ext/*" {
- permission java.security.AllPermission;
-};
-
grant {
// standard test activation permissions
permission java.io.FilePermission "..${/}..${/}test.props", "read";
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java Thu Oct 30 13:56:09 2014 -0700
@@ -29,7 +29,7 @@
* @library ../../../testlibrary
* @build TestLibrary RMID ActivationLibrary
* CanCreateStubs StubClassesPermitted_Stub
- * @run main/othervm/policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
+ * @run main/othervm/java.security.policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
*/
import java.io.*;
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/security.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/security.policy Thu Oct 30 13:56:09 2014 -0700
@@ -2,10 +2,6 @@
* security policy used by the test process
*/
-grant codeBase "file:${java.home}/lib/ext/*" {
- permission java.security.AllPermission;
-};
-
grant {
// standard test activation permissions
permission java.io.FilePermission "..${/}..${/}test.props", "read";
--- a/jdk/test/java/security/KeyRep/Serial.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/KeyRep/Serial.java Thu Oct 30 13:56:09 2014 -0700
@@ -26,7 +26,7 @@
* @bug 4532506 4999599
* @summary Serializing KeyPair on one VM (Sun),
* and Deserializing on another (IBM) fails
- * @run main/othervm/policy=Serial.policy Serial
+ * @run main/othervm/java.security.policy=Serial.policy Serial
*/
import java.io.*;
--- a/jdk/test/java/security/KeyRep/Serial.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/KeyRep/Serial.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,12 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
grant {
// XXX note package access is *not* granted to the 'sun' package
};
--- a/jdk/test/java/security/KeyRep/SerialDSAPubKey.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/KeyRep/SerialDSAPubKey.java Thu Oct 30 13:56:09 2014 -0700
@@ -26,7 +26,7 @@
* @bug 6232513
* @summary RMI interoperability issue with DSAPublicKey obj between
* JDK1.4 & JDK1.5
- * @run main/othervm/policy=SerialDSAPubKey.policy -Dsun.security.key.serial.interop=true -Dsun.security.pkcs11.enable-solaris=false SerialDSAPubKey
+ * @run main/othervm/java.security.policy=SerialDSAPubKey.policy -Dsun.security.key.serial.interop=true -Dsun.security.pkcs11.enable-solaris=false SerialDSAPubKey
*/
import java.io.*;
--- a/jdk/test/java/security/KeyRep/SerialOld.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/KeyRep/SerialOld.java Thu Oct 30 13:56:09 2014 -0700
@@ -26,7 +26,7 @@
* @bug 4532506
* @summary Serializing KeyPair on one VM (Sun),
* and Deserializing on another (IBM) fails
- * @run main/othervm/policy=SerialOld.policy SerialOld
+ * @run main/othervm/java.security.policy=SerialOld.policy SerialOld
*/
import java.io.*;
--- a/jdk/test/java/security/KeyRep/SerialOld.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/KeyRep/SerialOld.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,55 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
- permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
- permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
- permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunec";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunEC";
- permission java.security.SecurityPermission "clearProviderProperties.SunEC";
- permission java.security.SecurityPermission "removeProviderProperty.SunEC";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
-grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
- Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
- permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
- permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
-};
-
grant {
permission java.io.FilePermission "${test.src}${file.separator}*", "read";
--- a/jdk/test/java/security/Security/removing/RemoveStaticProvider.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/Security/removing/RemoveStaticProvider.java Thu Oct 30 13:56:09 2014 -0700
@@ -25,7 +25,7 @@
* @test
* @bug 4420687
* @summary Make sure that a removed provider won't be acceessable.
- * @run main/othervm/policy=RemoveStaticProvider.policy RemoveStaticProvider
+ * @run main/othervm/java.security.policy=RemoveStaticProvider.policy RemoveStaticProvider
*/
import java.security.*;
import javax.crypto.*;
--- a/jdk/test/java/security/Security/removing/RemoveStaticProvider.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/java/security/Security/removing/RemoveStaticProvider.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,13 +1,3 @@
-
-grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.SunJCE";
- permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
- permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
-};
-
grant {
permission java.security.SecurityPermission "removeProvider.SunJCE";
permission java.security.SecurityPermission "insertProvider.SunJCE";
--- a/jdk/test/java/sql/TEST.properties Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-# JDBC unit tests uses TestNG
-TestNG.dirs = .
-
--- a/jdk/test/java/sql/test/sql/BatchUpdateExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.ObjectInputStream;
-import java.sql.BatchUpdateException;
-import java.sql.SQLException;
-import java.util.Arrays;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.SerializedBatchUpdateException;
-import util.BaseTest;
-
-public class BatchUpdateExceptionTests extends BaseTest {
-
- private final int[] uc = {1, 2, 3};
- private final long[] luc = {1, 2, 3};
-
- private final String testSrcDir = System.getProperty("test.src", ".")
- + File.separatorChar;
-
- /**
- * Create BatchUpdateException and setting all objects to null
- */
- @Test
- public void test() {
- BatchUpdateException be = new BatchUpdateException(null,
- null, errorCode, (int[]) null, null);
- assertTrue(be.getMessage() == null && be.getSQLState() == null
- && be.getUpdateCounts() == null && be.getCause() == null
- && be.getLargeUpdateCounts() == null
- && be.getErrorCode() == errorCode);
- }
-
- /**
- * Create BatchUpdateException with no-arg constructor
- */
- @Test
- public void test1() {
- BatchUpdateException ex = new BatchUpdateException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Create BatchUpdateException with null Throwable
- */
- @Test
- public void test2() {
- BatchUpdateException ex = new BatchUpdateException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Create BatchUpdateException with message and update counts
- */
- @Test
- public void test3() {
-
- BatchUpdateException ex = new BatchUpdateException(reason, uc);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with update counts
- */
- @Test
- public void test4() {
- BatchUpdateException ex = new BatchUpdateException(uc);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with Throwable and update counts
- */
- @Test
- public void test5() {
- BatchUpdateException ex = new BatchUpdateException(uc, t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, Throwable, and update counts
- */
- @Test
- public void test6() {
- BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, Throwable, and update
- * counts
- */
- @Test
- public void test7() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, errorCode code
- * Throwable, and update counts
- */
- @Test
- public void test8() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
- uc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Create BatchUpdateException with message, SQLState, errorCode code
- * Throwable, and long [] update counts
- */
- @Test
- public void test9() {
- BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
- luc, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && Arrays.equals(ex.getUpdateCounts(), uc)
- && Arrays.equals(ex.getLargeUpdateCounts(), luc)
- );
- }
-
- /**
- * Validate that a copy of the update counts array is made
- */
- @Test
- public void test10() {
- int[] uc1 = {1, 2};
- BatchUpdateException ex = new BatchUpdateException(uc1);
- assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1));
- uc1[0] = 6689;
- assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1));
- }
-
- /**
- * Validate that if null is specified for the update count, it is returned
- * as null
- */
- @Test
- public void test11() {
- BatchUpdateException ex = new BatchUpdateException((int[]) null);
- assertTrue(ex.getMessage() == null && ex.getSQLState() == null
- && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null
- && ex.getLargeUpdateCounts() == null);
- }
-
- /**
- * Serialize a BatchUpdateException and make sure you can read it back
- * properly
- */
- @Test
- public void test12() throws Exception {
- BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
- uc, t);
- BatchUpdateException bue
- = createSerializedException(be);
- assertTrue(reason.equals(bue.getMessage())
- && bue.getSQLState().equals(state)
- && cause.equals(bue.getCause().toString())
- && bue.getErrorCode() == errorCode
- && Arrays.equals(bue.getLargeUpdateCounts(), luc)
- && Arrays.equals(bue.getUpdateCounts(), uc));
- }
-
-
-
- /**
- * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
- * read it back properly
- */
- @Test
- public void test13() throws Exception {
- String reason1 = "This was the error msg";
- String state1 = "user defined sqlState";
- String cause1 = "java.lang.Throwable: throw 1";
- int errorCode1 = 99999;
- Throwable t = new Throwable("throw 1");
- int[] uc1 = {1, 2, 21};
- long[] luc1 = {1, 2, 21};
-
- ObjectInputStream ois = new ObjectInputStream(
- new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
- BatchUpdateException bue = (BatchUpdateException) ois.readObject();
- assertTrue(reason1.equals(bue.getMessage())
- && bue.getSQLState().equals(state1)
- && bue.getErrorCode() == errorCode1
- && cause1.equals(bue.getCause().toString())
- && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
- && Arrays.equals(bue.getUpdateCounts(), uc1));
- }
-
- /**
- * Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
- * validate you can read it back properly
- */
- @Test
- public void test14() throws Exception {
- int[] uc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
- long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
- BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
- luc1, t);
- BatchUpdateException bue
- = createSerializedException(be);
- assertTrue(reason.equals(bue.getMessage())
- && bue.getSQLState().equals(state)
- && cause.equals(bue.getCause().toString())
- && bue.getErrorCode() == errorCode
- && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
- && Arrays.equals(bue.getUpdateCounts(), uc1));
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test15() {
- BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
- BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
- BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test16() {
- BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
- BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
- BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- SQLException sqe = ex;
- int num = 0;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
-}
--- a/jdk/test/java/sql/test/sql/DataTruncationTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.DataTruncation;
-import java.sql.SQLException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class DataTruncationTests extends BaseTest {
-
- private final String READ_TRUNCATION = "01004";
- private final String WRITE_TRUNCATION = "22001";
- private final String dtReason = "Data truncation";
- private final int dterrorCode = 0;
- private final String[] dtmsgs = {dtReason, "cause 1", dtReason,
- dtReason, "cause 2"};
- private boolean onRead = false;
- private final boolean parameter = false;
- private final int index = 21;
- private final int dataSize = 25;
- private final int transferSize = 10;
-
- /**
- * Create DataTruncation object indicating a truncation on read
- */
- @Test
- public void test() {
- onRead = true;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on write
- */
- @Test
- public void test1() {
- onRead = false;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(WRITE_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read with a
- * Throwable
- */
- @Test
- public void test2() {
- onRead = true;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && cause.equals(e.getCause().toString())
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read with null
- * specified for the Throwable
- */
- @Test
- public void test3() {
- onRead = true;;
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, null);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Create DataTruncation object indicating a truncation on read and you can
- * pass a -1 for the index
- */
- @Test
- public void test4() {
- onRead = true;
- int negIndex = -1;
- DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
- dataSize, transferSize);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == negIndex);
- }
-
- /**
- * Serialize a DataTruncation and make sure you can read it back properly
- */
- @Test
- public void test5() throws Exception {
- DataTruncation e = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex1 = createSerializedException(e);
- assertTrue(e.getMessage().equals(dtReason)
- && e.getSQLState().equals(READ_TRUNCATION)
- && e.getCause() == null
- && e.getErrorCode() == dterrorCode
- && e.getParameter() == parameter
- && e.getRead() == onRead
- && e.getDataSize() == dataSize
- && e.getTransferSize() == transferSize
- && e.getIndex() == index);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- DataTruncation ex = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t1);
- DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(dtmsgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- DataTruncation ex = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t1);
- DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize);
- DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
- dataSize, transferSize, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(dtmsgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/DateTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,373 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Date;
-import java.time.Instant;
-import java.time.LocalDate;
-import static org.testng.Assert.*;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class DateTests extends BaseTest {
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Date string
- */
- @Test(dataProvider = "invalidDateValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test(String d) throws Exception {
- Date.valueOf(d);
- }
-
- /*
- * Test that a date created from a date string is equal to the value
- * returned from toString()
- */
- @Test(dataProvider = "validDateValues")
- public void test00(String d, String expectedD) {
- Date d1 = Date.valueOf(d);
- Date d2 = Date.valueOf(expectedD);
- assertTrue(d1.equals(d2) && d2.equals(d1)
- && d1.toString().equals(expectedD), "Error d1 != d2");
- }
-
- /*
- * Validate that a Date.after() returns false when same date is compared
- */
- @Test
- public void test01() {
- Date d = Date.valueOf("1961-08-30");
- assertFalse(d.after(d), "Error d.after(d) = true");
- }
-
- /*
- * Validate that a Date.after() returns true when later date is compared to
- * earlier date
- */
- @Test
- public void test2() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d2.after(d), "Error d2.after(d) = false");
- }
-
- /*
- * Validate that a Date.after() returns false when earlier date is compared
- * to later date
- */
- @Test
- public void test3() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.after(d2), "Error d.after(d2) = true");
- }
-
- /*
- * Validate that a Date.after() returns false when date compared to another
- * date created from the original date
- */
- @Test
- public void test4() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.after(d2), "Error d.after(d2) = true");
- assertFalse(d2.after(d), "Error d2.after(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns false when same date is compared
- */
- @Test
- public void test5() {
- Date d = Date.valueOf("1961-08-30");
- assertFalse(d.before(d), "Error d.before(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns true when earlier date is compared
- * to later date
- */
- @Test
- public void test6() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d.before(d2), "Error d.before(d2) = false");
- }
-
- /*
- * Validate that a Date.before() returns false when later date is compared
- * to earlier date
- */
- @Test
- public void test7() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d2.before(d), "Error d2.before(d) = true");
- }
-
- /*
- * Validate that a Date.before() returns false when date compared to another
- * date created from the original date
- */
- @Test
- public void test8() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertFalse(d.before(d2), "Error d.before(d2) = true");
- assertFalse(d2.before(d), "Error d2.before(d) = true");
- }
-
- /*
- * Validate that a Date.compareTo returns 0 when both Date objects are the
- * same
- */
- @Test
- public void test9() {
- Date d = Date.valueOf("1961-08-30");
- assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
- }
-
- /*
- * Validate that a Date.compareTo returns 0 when both Date objects represent
- * the same date
- */
- @Test
- public void test10() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertTrue(d.compareTo(d2) == 0, "Error d.compareTo(d2) !=0");
- }
-
- /*
- * Validate that a Date.compareTo returns -1 when comparing a date to a
- * later date
- */
- @Test
- public void test11() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d.compareTo(d2) == -1, "Error d.compareTo(d2) != -1");
- }
-
- /*
- * Validate that a Date.compareTo returns 1 when comparing a date to an
- * earlier date
- */
- @Test
- public void test12() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(System.currentTimeMillis());
- assertTrue(d2.compareTo(d) == 1, "Error d.compareTo(d2) != 1");
- }
-
- /*
- * Validate that a Date made from a LocalDate are equal
- */
- @Test
- public void test13() {
- Date d = Date.valueOf("1961-08-30");
- LocalDate ldt = d.toLocalDate();
- Date d2 = Date.valueOf(ldt);
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that a Date LocalDate value, made from a LocalDate are equal
- */
- @Test
- public void test14() {
- LocalDate ldt = LocalDate.now();
- Date d = Date.valueOf(ldt);
- assertTrue(ldt.equals(d.toLocalDate()),
- "Error LocalDate values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDate is passed to valueOf
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test15() throws Exception {
- LocalDate ld = null;
- Date.valueOf(ld);
- }
-
- /*
- * Validate an UnsupportedOperationException occurs when toInstant() is
- * called
- */
- @Test(expectedExceptions = UnsupportedOperationException.class)
- public void test16() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- Instant instant = d.toInstant();
- }
-
- /*
- * Validate that two Date objects are equal when one is created from the
- * toString() of the other
- */
- @Test
- public void test17() {
- Date d = Date.valueOf("1961-08-30");
- Date d2 = Date.valueOf(d.toString());
- assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
- }
-
- /*
- * Validate that two Date values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test18() {
-
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(61, 7, 30);
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that two Date values one created using getTime() of the other
- * are equal
- */
- @Test
- public void test19() {
-
- Date d = Date.valueOf("1961-08-30");
- Date d2 = new Date(d.getTime());
- assertTrue(d.equals(d2), "Error d != d2");
- }
-
- /*
- * Validate that a Date value is equal to itself
- */
- @Test
- public void test20() {
-
- Date d = Date.valueOf("1961-08-30");
- assertTrue(d.equals(d), "Error d != d");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getHours
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test21() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getHours();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getMinutes
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test22() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getMinutes();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getSeconds
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test23() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.getSeconds();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setHours
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test24() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setHours(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setMinutes
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test25() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setMinutes(0);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setSeconds
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test26() throws Exception {
- Date d = Date.valueOf("1961-08-30");
- d.setSeconds(0);
- }
-
- /*
- * DataProvider used to provide Date which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidDateValues")
- private Object[][] invalidDateValues() {
- return new Object[][]{
- {"20009-11-01"},
- {"09-11-01"},
- {"-11-01"},
- {"2009-111-01"},
- {"2009--01"},
- {"2009-13-01"},
- {"2009-11-011"},
- {"2009-11-"},
- {"2009-11-00"},
- {"2009-11-33"},
- {"--"},
- {""},
- {null},
- {"-"},
- {"2009"},
- {"2009-01"},
- {"---"},
- {"2009-13--1"},
- {"1900-1-0"},
- {"2009-01-01 10:50:01"},
- {"1996-12-10 12:26:19.1"},
- {"10:50:01"}
- };
- }
-
- /*
- * DataProvider used to provide Dates which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method and the corect value from toString() is returned
- */
- @DataProvider(name = "validDateValues")
- private Object[][] validDateValues() {
- return new Object[][]{
- {"2009-08-30", "2009-08-30"},
- {"2009-01-8", "2009-01-08"},
- {"2009-1-01", "2009-01-01"},
- {"2009-1-1", "2009-01-01"}
-
- };
- }
-}
--- a/jdk/test/java/sql/test/sql/DriverManagerPermissionsTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.security.AccessControlException;
-import java.security.Policy;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import util.BaseTest;
-import util.StubDriver;
-import util.TestPolicy;
-
-public class DriverManagerPermissionsTests extends BaseTest {
-
- private static Policy policy;
- private static SecurityManager sm;
-
- /*
- * Install a SecurityManager along with a base Policy to allow testNG to run
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
- setPolicy(new TestPolicy());
- System.setSecurityManager(new SecurityManager());
- }
-
- /*
- * Install the original Policy and SecurityManager
- */
- @AfterClass
- public static void tearDownClass() throws Exception {
- System.setSecurityManager(sm);
- setPolicy(policy);
- }
-
- /*
- * Save off the original Policy and SecurityManager
- */
- public DriverManagerPermissionsTests() {
- policy = Policy.getPolicy();
- sm = System.getSecurityManager();
- }
-
- /*
- * Validate that AccessControlException is thrown if SQLPermission("setLog")
- * has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test() {
- setPolicy(new TestPolicy());
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that setLogStream succeeds if SQLPermission("setLog") has been
- * granted
- */
- @Test
- public void test1() {
- Policy.setPolicy(new TestPolicy("setLog"));
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that setLogStream succeeds if AllPermissions has been granted
- */
- @Test
- public void test2() {
- setPolicy(new TestPolicy("all"));
- DriverManager.setLogStream(null);
- }
-
- /*
- * Validate that AccessControlException is thrown if SQLPermission("setLog")
- * has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test4() {
- setPolicy(new TestPolicy());
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that setLogWriter succeeds if SQLPermission("setLog") has been
- * granted
- */
- @Test
- public void test5() {
- setPolicy(new TestPolicy("setLog"));
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that setLogWriter succeeds if AllPermissions has been granted
- */
- @Test
- public void test6() {
- setPolicy(new TestPolicy("all"));
- DriverManager.setLogWriter(null);
- }
-
- /*
- * Validate that AccessControlException is thrown if
- * SQLPermission("deregisterDriver") has not been granted
- */
- @Test(expectedExceptions = AccessControlException.class)
- public void test7() throws SQLException {
- setPolicy(new TestPolicy());
- DriverManager.deregisterDriver(new StubDriver());
- }
-
- /*
- * Validate that deregisterDriver succeeds if
- * SQLPermission("deregisterDriver") has been granted
- */
- @Test
- public void test8() throws SQLException {
- setPolicy(new TestPolicy("deregisterDriver"));
- DriverManager.deregisterDriver(new StubDriver());
- }
-
- /*
- * Validate that deregisterDriver succeeds if AllPermissions has been
- * granted
- */
- @Test
- public void test9() throws SQLException {
- setPolicy(new TestPolicy("all"));
- DriverManager.deregisterDriver(new StubDriver());
- }
-}
--- a/jdk/test/java/sql/test/sql/DriverManagerTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Properties;
-import static org.testng.Assert.*;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import util.StubDriver;
-
-public class DriverManagerTests {
-
- private final String StubDriverURL = "jdbc:tennis:boy";
- private final String StubDriverDAURL = "jdbc:luckydog:tennis";
- private final String InvalidURL = "jdbc:cardio:tennis";
- private String[] results = {"output", "more output", "and more", "the end"};
- private String noOutput = "should not find this";
-
- public DriverManagerTests() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @BeforeMethod
- public void setUpMethod() throws Exception {
- removeAllDrivers();
- }
-
- @AfterMethod
- public void tearDownMethod() throws Exception {
- }
-
- /**
- * Utility method to remove all registered drivers
- */
- private static void removeAllDrivers() {
- java.util.Enumeration e = DriverManager.getDrivers();
- while (e.hasMoreElements()) {
- try {
- DriverManager.deregisterDriver((Driver) (e.nextElement()));
- } catch (SQLException ex) {
- System.out.print(ex.getMessage());
- }
- }
- }
-
- /**
- * Utility method to see if a driver is registered
- */
- private boolean isDriverRegistered(Driver d) {
- boolean foundDriver = false;
- java.util.Enumeration e = DriverManager.getDrivers();
- while (e.hasMoreElements()) {
- if (d == (Driver) e.nextElement()) {
- foundDriver = true;
- break;
- }
- }
- return foundDriver;
- }
-
- /**
- * Validate that values set using setLoginTimeout will be returned by
- * getLoginTimeout
- */
- @Test
- public void test() {
- int[] vals = {-1, 0, 5};
- for (int val : vals) {
- DriverManager.setLoginTimeout(val);
- assertEquals(val, DriverManager.getLoginTimeout());
- }
- }
-
- /**
- * Validate that NullPointerException is thrown when null is passed to
- * registerDriver
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test1() throws Exception {
- Driver d = null;
- DriverManager.registerDriver(d);
- }
-
- /**
- * Validate that NullPointerException is thrown when null is passed to
- * registerDriver
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test2() throws Exception {
- Driver d = null;
- DriverManager.registerDriver(d, null);
- }
-
- /**
- * Validate that a null value allows for deRegisterDriver to return
- */
- @Test
- public void test3() throws Exception {
- DriverManager.deregisterDriver(null);
-
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test4() throws Exception {
- DriverManager.getConnection(InvalidURL);
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test5() throws Exception {
- DriverManager.getConnection(InvalidURL, new Properties());
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test6() throws Exception {
- DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test7() throws Exception {
- DriverManager.getConnection(null);
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test8() throws Exception {
- DriverManager.getConnection(null, new Properties());
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test9() throws Exception {
- DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
- }
-
- /**
- * Validate that SQLException is thrown when there is no Driver to service
- * the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test10() throws Exception {
- DriverManager.getDriver(InvalidURL);
- }
-
- /**
- * Validate that SQLException is thrown when null is passed for the URL
- */
- @Test(expectedExceptions = SQLException.class)
- public void test11() throws Exception {
- DriverManager.getDriver(null);
- }
-
- /**
- * Validate that a non-null Driver is returned by getDriver when a valid URL
- * is specified
- */
- @Test
- public void test12() throws Exception {
-
- DriverManager.registerDriver(new StubDriver());
- assertTrue(DriverManager.getDriver(StubDriverURL) != null);
- }
-
- /**
- * Validate that SQLException is thrown when the URL is not valid for any of
- * the registered drivers
- */
- @Test(expectedExceptions = SQLException.class)
- public void test13() throws Exception {
- DriverManager.registerDriver(new StubDriver());
- DriverManager.getDriver(InvalidURL);
- }
-
- /**
- * Validate that a Connection object is returned when a valid URL is
- * specified to getConnection
- *
- */
- @Test
- public void test14() throws Exception {
-
- DriverManager.registerDriver(new StubDriver());
- assertTrue(
- DriverManager.getConnection(StubDriverURL) != null);
- assertTrue(DriverManager.getConnection(StubDriverURL,
- "LuckyDog", "tennisanyone") != null);
- Properties props = new Properties();
- props.put("user", "LuckyDog");
- props.put("password", "tennisanyone");
- assertTrue(
- DriverManager.getConnection(StubDriverURL,
- props) != null);
- }
-
- /**
- * Register a driver and make sure you find it via its URL. Deregister the
- * driver and validate it is not longer registered
- *
- * @throws Exception
- */
- @Test()
- public void test15() throws Exception {
- DriverManager.registerDriver(new StubDriver());
- Driver d = DriverManager.getDriver(StubDriverURL);
- assertTrue(d != null);
- assertTrue(isDriverRegistered(d));
- DriverManager.deregisterDriver(d);
- assertFalse(isDriverRegistered(d));
- }
-
- /**
- * Validate that DriverAction.release is called when a driver is registered
- * via registerDriver(Driver, DriverAction)
- *
- * @throws Exception
- */
- @Test
- public void test16() throws Exception {
- File file = new File(util.StubDriverDA.DriverActionCalled);
- file.delete();
- assertFalse(file.exists());
- Driver d = null;
- Class.forName("util.StubDriverDA");
- d = DriverManager.getDriver(StubDriverDAURL);
- DriverManager.deregisterDriver(d);
- assertFalse(isDriverRegistered(d), "Driver is registered");
- assertTrue(file.exists());
- }
-
- /**
- * Create a PrintStream and use to send output via DriverManager.println
- * Validate that if you disable the stream, the output sent is not present
- */
- @Test
- public void tests17() throws Exception {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(os);
- DriverManager.setLogStream(ps);
- assertTrue(DriverManager.getLogStream() == ps);
-
- DriverManager.println(results[0]);
- DriverManager.setLogStream((PrintStream) null);
- assertTrue(DriverManager.getLogStream() == null);
- DriverManager.println(noOutput);
- DriverManager.setLogStream(ps);
- DriverManager.println(results[1]);
- DriverManager.println(results[2]);
- DriverManager.println(results[3]);
- DriverManager.setLogStream((PrintStream) null);
- DriverManager.println(noOutput);
-
- /*
- * Check we do not get the output when the stream is disabled
- */
- InputStreamReader is
- = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
- BufferedReader reader = new BufferedReader(is);
- for (String result : results) {
- assertTrue(result.equals(reader.readLine()));
- }
- }
-
- /**
- * Create a PrintWriter and use to to send output via DriverManager.println
- * Validate that if you disable the writer, the output sent is not present
- */
- @Test
- public void tests18() throws Exception {
- CharArrayWriter cw = new CharArrayWriter();
- PrintWriter pw = new PrintWriter(cw);
- DriverManager.setLogWriter(pw);
- assertTrue(DriverManager.getLogWriter() == pw);
-
- DriverManager.println(results[0]);
- DriverManager.setLogWriter(null);
- assertTrue(DriverManager.getLogWriter() == null);
- DriverManager.println(noOutput);
- DriverManager.setLogWriter(pw);
- DriverManager.println(results[1]);
- DriverManager.println(results[2]);
- DriverManager.println(results[3]);
- DriverManager.setLogWriter(null);
- DriverManager.println(noOutput);
-
- /*
- * Check we do not get the output when the stream is disabled
- */
- BufferedReader reader
- = new BufferedReader(new CharArrayReader(cw.toCharArray()));
- for (String result : results) {
- assertTrue(result.equals(reader.readLine()));
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLClientInfoExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.ClientInfoStatus;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.util.HashMap;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLClientInfoExceptionTests extends BaseTest {
-
- private final HashMap<String, ClientInfoStatus> map = new HashMap<>();
-
- public SQLClientInfoExceptionTests() {
- map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
- map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
- }
-
- /**
- * Create SQLClientInfoException and setting all objects to null
- */
- @Test
- public void test() {
- SQLClientInfoException e = new SQLClientInfoException(null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == 0
- && e.getFailedProperties() == null);
- }
-
- /**
- * Create SQLClientInfoException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLClientInfoException ex = new SQLClientInfoException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties() == null);
- }
-
- /**
- * Create SQLClientInfoException with null Throwable
- */
- @Test
- public void test2() {
-
- SQLClientInfoException ex = new SQLClientInfoException(map, null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message
- */
- @Test
- public void test3() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, map);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with null Throwable
- */
- @Test
- public void test4() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, and SQLState
- */
- @Test
- public void test5() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- map);
-
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, and SQLState
- */
- @Test
- public void test6() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- map, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, SQLState, errorCode, and
- * Throwable
- */
- @Test
- public void test7() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- errorCode, map);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Create SQLClientInfoException with message, SQLState, and error code
- */
- @Test
- public void test8() {
- SQLClientInfoException ex = new SQLClientInfoException(reason, state,
- errorCode, map, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode
- && ex.getFailedProperties().equals(map));
- }
-
- /**
- * Serialize a SQLClientInfoException and make sure you can read it back
- * properly
- */
- @Test
- public void test10() throws Exception {
- SQLClientInfoException e = new SQLClientInfoException(reason, state,
- errorCode, map, t);
- SQLClientInfoException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode
- && ex1.getFailedProperties().equals(map));
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
- map, t1);
- SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
- map);
- SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
- map, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
- map, t1);
- SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
- map);
- SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
- map, t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLDataExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLDataException;
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLDataExceptionTests extends BaseTest {
-
- /**
- * Create SQLDataException and setting all objects to null
- */
- @Test
- public void test() {
- SQLDataException e = new SQLDataException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLDataException ex = new SQLDataException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message
- */
- @Test
- public void test2() {
- SQLDataException ex = new SQLDataException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLDataException ex = new SQLDataException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLDataException ex = new SQLDataException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLDataException ex = new SQLDataException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLDataException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLDataException ex = new SQLDataException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLDataException ex = new SQLDataException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with null Throwable
- */
- @Test
- public void test8() {
- SQLDataException ex = new SQLDataException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLDataException with Throwable
- */
- @Test
- public void test9() {
- SQLDataException ex = new SQLDataException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLDataException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLDataException e = new SQLDataException(reason, state, errorCode, t);
- SQLDataException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLDataException ex = new SQLDataException("Exception 1", t1);
- SQLDataException ex1 = new SQLDataException("Exception 2");
- SQLDataException ex2 = new SQLDataException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLDataException ex = new SQLDataException("Exception 1", t1);
- SQLDataException ex1 = new SQLDataException("Exception 2");
- SQLDataException ex2 = new SQLDataException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLDataException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLDataException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLExceptionTests extends BaseTest {
-
- /**
- * Create SQLException and setting all objects to null
- */
- @Test
- public void test() {
- SQLException e = new SQLException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLException ex = new SQLException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message
- */
- @Test
- public void test2() {
- SQLException ex = new SQLException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLException ex = new SQLException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLException ex = new SQLException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLException ex = new SQLException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLException ex = new SQLException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLException ex = new SQLException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with null Throwable
- */
- @Test
- public void test8() {
- SQLException ex = new SQLException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLException with Throwable
- */
- @Test
- public void test9() {
- SQLException ex = new SQLException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLException e = new SQLException(reason, state, errorCode, t);
- SQLException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLException ex = new SQLException("Exception 1", t1);
- SQLException ex1 = new SQLException("Exception 2");
- SQLException ex2 = new SQLException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLException ex = new SQLException("Exception 1", t1);
- SQLException ex1 = new SQLException("Exception 2");
- SQLException ex2 = new SQLException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- while (ex != null) {
- assertTrue(msgs[num++].equals(ex.getMessage()));
- Throwable c = ex.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- ex = ex.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLFeatureNotSupportedExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLFeatureNotSupportedExceptionTests extends BaseTest {
-
- /**
- * Create SQLFeatureNotSupportedException and setting all objects to null
- */
- @Test
- public void test() {
- SQLFeatureNotSupportedException e =
- new SQLFeatureNotSupportedException(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message
- */
- @Test
- public void test2() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with null Throwable
- */
- @Test
- public void test8() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLFeatureNotSupportedException with Throwable
- */
- @Test
- public void test9() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLFeatureNotSupportedException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLFeatureNotSupportedException e =
- new SQLFeatureNotSupportedException(reason, state, errorCode, t);
- SQLFeatureNotSupportedException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException("Exception 1", t1);
- SQLFeatureNotSupportedException ex1 =
- new SQLFeatureNotSupportedException("Exception 2");
- SQLFeatureNotSupportedException ex2 =
- new SQLFeatureNotSupportedException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLFeatureNotSupportedException ex =
- new SQLFeatureNotSupportedException("Exception 1", t1);
- SQLFeatureNotSupportedException ex1 =
- new SQLFeatureNotSupportedException("Exception 2");
- SQLFeatureNotSupportedException ex2 =
- new SQLFeatureNotSupportedException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLFeatureNotSupportedException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLFeatureNotSupportedException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLIntegrityConstraintViolationExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLIntegrityConstraintViolationException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {
-
- /**
- * Create SQLIntegrityConstraintViolationException and setting all objects to null
- */
- @Test
- public void test() {
- SQLIntegrityConstraintViolationException e =
- new SQLIntegrityConstraintViolationException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message
- */
- @Test
- public void test2() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with null Throwable
- */
- @Test
- public void test8() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException with Throwable
- */
- @Test
- public void test9() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLIntegrityConstraintViolationException and make sure
- * you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLIntegrityConstraintViolationException e =
- new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
- SQLIntegrityConstraintViolationException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException("Exception 1", t1);
- SQLIntegrityConstraintViolationException ex1 =
- new SQLIntegrityConstraintViolationException("Exception 2");
- SQLIntegrityConstraintViolationException ex2 =
- new SQLIntegrityConstraintViolationException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLIntegrityConstraintViolationException ex =
- new SQLIntegrityConstraintViolationException("Exception 1", t1);
- SQLIntegrityConstraintViolationException ex1 =
- new SQLIntegrityConstraintViolationException("Exception 2");
- SQLIntegrityConstraintViolationException ex2 =
- new SQLIntegrityConstraintViolationException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLIntegrityConstraintViolationException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLIntegrityConstraintViolationException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLInvalidAuthorizationSpecException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {
-
- /**
- * Create SQLInvalidAuthorizationSpecException and setting all objects to
- * null
- */
- @Test
- public void test() {
- SQLInvalidAuthorizationSpecException e
- = new SQLInvalidAuthorizationSpecException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message
- */
- @Test
- public void test2() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
- * error code
- */
- @Test
- public void test4() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState,
- * errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
- * Throwable
- */
- @Test
- public void test6() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with null Throwable
- */
- @Test
- public void test8() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException with Throwable
- */
- @Test
- public void test9() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLInvalidAuthorizationSpecException and make sure you can
- * read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLInvalidAuthorizationSpecException e
- = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
- SQLInvalidAuthorizationSpecException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
- SQLInvalidAuthorizationSpecException ex1
- = new SQLInvalidAuthorizationSpecException("Exception 2");
- SQLInvalidAuthorizationSpecException ex2
- = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLInvalidAuthorizationSpecException ex
- = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
- SQLInvalidAuthorizationSpecException ex1
- = new SQLInvalidAuthorizationSpecException("Exception 2");
- SQLInvalidAuthorizationSpecException ex2
- = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLInvalidAuthorizationSpecException and validate it is an
- * instance of SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLInvalidAuthorizationSpecException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLNonTransientConnectionExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientConnectionException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLNonTransientConnectionExceptionTests extends BaseTest {
-
- /**
- * Create SQLNonTransientConnectionException and setting all objects to null
- */
- @Test
- public void test() {
- SQLNonTransientConnectionException e =
- new SQLNonTransientConnectionException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message
- */
- @Test
- public void test2() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with null Throwable
- */
- @Test
- public void test8() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientConnectionException with Throwable
- */
- @Test
- public void test9() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLNonTransientConnectionException and make sure you can
- * read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLNonTransientConnectionException e =
- new SQLNonTransientConnectionException(reason, state, errorCode, t);
- SQLNonTransientConnectionException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException("Exception 1", t1);
- SQLNonTransientConnectionException ex1 =
- new SQLNonTransientConnectionException("Exception 2");
- SQLNonTransientConnectionException ex2 =
- new SQLNonTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLNonTransientConnectionException ex =
- new SQLNonTransientConnectionException("Exception 1", t1);
- SQLNonTransientConnectionException ex1 =
- new SQLNonTransientConnectionException("Exception 2");
- SQLNonTransientConnectionException ex2 =
- new SQLNonTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLNonTransientConnectionException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLNonTransientConnectionException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLNonTransientExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLNonTransientExceptionTests extends BaseTest {
-
- /**
- * Create SQLNonTransientException and setting all objects to null
- */
- @Test
- public void test() {
- SQLNonTransientException e = new SQLNonTransientException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLNonTransientException ex = new SQLNonTransientException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message
- */
- @Test
- public void test2() {
- SQLNonTransientException ex = new SQLNonTransientException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, and error code
- */
- @Test
- public void test4() {;
- SQLNonTransientException ex =
- new SQLNonTransientException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLNonTransientException ex =
- new SQLNonTransientException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLNonTransientException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLNonTransientException ex = new SQLNonTransientException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with null Throwable
- */
- @Test
- public void test8() {
- SQLNonTransientException ex = new SQLNonTransientException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLNonTransientException with Throwable
- */
- @Test
- public void test9() {
- SQLNonTransientException ex = new SQLNonTransientException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLNonTransientException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLNonTransientException e =
- new SQLNonTransientException(reason, state, errorCode, t);
- SQLNonTransientException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
- SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
- SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
- SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
- SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLRecoverableExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLRecoverableException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLRecoverableExceptionTests extends BaseTest {
-
- /**
- * Create SQLRecoverableException and setting all objects to null
- */
- @Test
- public void test() {
- SQLRecoverableException e = new SQLRecoverableException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLRecoverableException ex = new SQLRecoverableException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message
- */
- @Test
- public void test2() {
- SQLRecoverableException ex = new SQLRecoverableException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLRecoverableException ex =
- new SQLRecoverableException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLRecoverableException ex =
- new SQLRecoverableException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLRecoverableException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLRecoverableException ex = new SQLRecoverableException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with null Throwable
- */
- @Test
- public void test8() {
- SQLRecoverableException ex = new SQLRecoverableException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLRecoverableException with Throwable
- */
- @Test
- public void test9() {
- SQLRecoverableException ex = new SQLRecoverableException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLRecoverableException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLRecoverableException e =
- new SQLRecoverableException(reason, state, errorCode, t);
- SQLRecoverableException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
- SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
- SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
- SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
- SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLSyntaxErrorExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLNonTransientException;
-import java.sql.SQLSyntaxErrorException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLSyntaxErrorExceptionTests extends BaseTest {
-
- /**
- * Create SQLSyntaxErrorException and setting all objects to null
- */
- @Test
- public void test() {
- SQLSyntaxErrorException e = new SQLSyntaxErrorException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message
- */
- @Test
- public void test2() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLSyntaxErrorException ex =
- new SQLSyntaxErrorException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLSyntaxErrorException ex =
- new SQLSyntaxErrorException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with null Throwable
- */
- @Test
- public void test8() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLSyntaxErrorException with Throwable
- */
- @Test
- public void test9() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLSyntaxErrorException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
-
- SQLSyntaxErrorException e =
- new SQLSyntaxErrorException(reason, state, errorCode, t);
- SQLSyntaxErrorException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
- SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
- SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
- SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
- SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLSyntaxErrorException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLSyntaxErrorException();
- assertTrue(ex instanceof SQLNonTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTimeoutExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTimeoutException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTimeoutExceptionTests extends BaseTest {
-
- /**
- * Create SQLTimeoutException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTimeoutException e = new SQLTimeoutException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTimeoutException ex = new SQLTimeoutException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message
- */
- @Test
- public void test2() {
- SQLTimeoutException ex = new SQLTimeoutException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTimeoutException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTimeoutException ex = new SQLTimeoutException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with null Throwable
- */
- @Test
- public void test8() {
- SQLTimeoutException ex = new SQLTimeoutException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTimeoutException with Throwable
- */
- @Test
- public void test9() {
- SQLTimeoutException ex = new SQLTimeoutException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTimeoutException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTimeoutException e =
- new SQLTimeoutException(reason, state, errorCode, t);
- SQLTimeoutException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
- SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
- SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
- SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
- SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTimeoutException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTimeoutException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransactionRollbackExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransactionRollbackException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransactionRollbackExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransactionRollbackException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransactionRollbackException e =
- new SQLTransactionRollbackException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransactionRollbackException ex = new SQLTransactionRollbackException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message
- */
- @Test
- public void test2() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransactionRollbackException with Throwable
- */
- @Test
- public void test9() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransactionRollbackException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransactionRollbackException e =
- new SQLTransactionRollbackException(reason, state, errorCode, t);
- SQLTransactionRollbackException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException("Exception 1", t1);
- SQLTransactionRollbackException ex1 =
- new SQLTransactionRollbackException("Exception 2");
- SQLTransactionRollbackException ex2 =
- new SQLTransactionRollbackException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransactionRollbackException ex =
- new SQLTransactionRollbackException("Exception 1", t1);
- SQLTransactionRollbackException ex1 =
- new SQLTransactionRollbackException("Exception 2");
- SQLTransactionRollbackException ex2 =
- new SQLTransactionRollbackException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTransactionRollbackException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTransactionRollbackException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransientConnectionExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransientConnectionException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransientConnectionExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransientConnectionException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransientConnectionException e =
- new SQLTransientConnectionException( null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransientConnectionException ex = new SQLTransientConnectionException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message
- */
- @Test
- public void test2() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, and error code
- */
- @Test
- public void test4() {;
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientConnectionException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientConnectionException with Throwable
- */
- @Test
- public void test9() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransientConnectionException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransientConnectionException e =
- new SQLTransientConnectionException(reason, state, errorCode, t);
- SQLTransientConnectionException ex1 =
- createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException("Exception 1", t1);
- SQLTransientConnectionException ex1 =
- new SQLTransientConnectionException("Exception 2");
- SQLTransientConnectionException ex2 =
- new SQLTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransientConnectionException ex =
- new SQLTransientConnectionException("Exception 1", t1);
- SQLTransientConnectionException ex1 =
- new SQLTransientConnectionException("Exception 2");
- SQLTransientConnectionException ex2 =
- new SQLTransientConnectionException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Create SQLTransientConnectionException and validate it is an instance of
- * SQLNonTransientException
- */
- @Test
- public void test13() {
- Exception ex = new SQLTransientConnectionException();
- assertTrue(ex instanceof SQLTransientException);
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLTransientExceptionTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLTransientException;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLTransientExceptionTests extends BaseTest {
-
- /**
- * Create SQLTransientException and setting all objects to null
- */
- @Test
- public void test() {
- SQLTransientException e = new SQLTransientException(null,
- null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with no-arg constructor
- */
- @Test
- public void test1() {
- SQLTransientException ex = new SQLTransientException();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message
- */
- @Test
- public void test2() {
- SQLTransientException ex = new SQLTransientException(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, and SQLState
- */
- @Test
- public void test3() {
- SQLTransientException ex = new SQLTransientException(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLTransientException ex = new SQLTransientException(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLTransientException ex =
- new SQLTransientException(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLTransientException with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLTransientException ex = new SQLTransientException(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with message, and Throwable
- */
- @Test
- public void test7() {
- SQLTransientException ex = new SQLTransientException(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with null Throwable
- */
- @Test
- public void test8() {
- SQLTransientException ex = new SQLTransientException((Throwable)null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLTransientException with Throwable
- */
- @Test
- public void test9() {
- SQLTransientException ex = new SQLTransientException(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLTransientException and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLTransientException e =
- new SQLTransientException(reason, state, errorCode, t);
- SQLTransientException ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using for-each loop
- */
- @Test
- public void test11() {
- SQLTransientException ex = new SQLTransientException("Exception 1", t1);
- SQLTransientException ex1 = new SQLTransientException("Exception 2");
- SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct
- * using traditional while loop
- */
- @Test
- public void test12() {
- SQLTransientException ex = new SQLTransientException("Exception 1", t1);
- SQLTransientException ex1 = new SQLTransientException("Exception 2");
- SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/SQLWarningTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import static org.testng.Assert.*;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class SQLWarningTests extends BaseTest {
-
- private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
- "Warning 3", "cause 2"};
-
- /**
- * Create SQLWarning and setting all objects to null
- */
- @Test
- public void test() {
- SQLWarning e = new SQLWarning(null, null, errorCode, null);
- assertTrue(e.getMessage() == null && e.getSQLState() == null
- && e.getCause() == null && e.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with no-arg constructor
- */
- @Test
- public void test1() {
- SQLWarning ex = new SQLWarning();
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message
- */
- @Test
- public void test2() {
- SQLWarning ex = new SQLWarning(reason);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, and SQLState
- */
- @Test
- public void test3() {
-
- SQLWarning ex = new SQLWarning(reason, state);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, SQLState, and error code
- */
- @Test
- public void test4() {
- SQLWarning ex = new SQLWarning(reason, state, errorCode);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && ex.getCause() == null
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with message, SQLState, errorCode, and Throwable
- */
- @Test
- public void test5() {
- SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == errorCode);
- }
-
- /**
- * Create SQLWarning with message, SQLState, and Throwable
- */
- @Test
- public void test6() {
- SQLWarning ex = new SQLWarning(reason, state, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState().equals(state)
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with message, and Throwable
- */
- @Test
- public void test7() {
- SQLWarning ex = new SQLWarning(reason, t);
- assertTrue(ex.getMessage().equals(reason)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with null Throwable
- */
- @Test
- public void test8() {
- SQLWarning ex = new SQLWarning((Throwable) null);
- assertTrue(ex.getMessage() == null
- && ex.getSQLState() == null
- && ex.getCause() == null
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Create SQLWarning with Throwable
- */
- @Test
- public void test9() {
- SQLWarning ex = new SQLWarning(t);
- assertTrue(ex.getMessage().equals(cause)
- && ex.getSQLState() == null
- && cause.equals(ex.getCause().toString())
- && ex.getErrorCode() == 0);
- }
-
- /**
- * Serialize a SQLWarning and make sure you can read it back properly
- */
- @Test
- public void test10() throws Exception {
- SQLWarning e = new SQLWarning(reason, state, errorCode, t);
- SQLWarning ex1 = createSerializedException(e);
- assertTrue(reason.equals(ex1.getMessage())
- && ex1.getSQLState().equals(state)
- && cause.equals(ex1.getCause().toString())
- && ex1.getErrorCode() == errorCode);
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * for-each loop
- */
- @Test
- public void test11() {
- SQLWarning ex = new SQLWarning("Exception 1", t1);
- SQLWarning ex1 = new SQLWarning("Exception 2");
- SQLWarning ex2 = new SQLWarning("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(msgs[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned Exceptions is correct using
- * traditional while loop
- */
- @Test
- public void test12() {
- SQLWarning ex = new SQLWarning("Exception 1", t1);
- SQLWarning ex1 = new SQLWarning("Exception 2");
- SQLWarning ex2 = new SQLWarning("Exception 3", t2);
- ex.setNextException(ex1);
- ex.setNextException(ex2);
- int num = 0;
- SQLException sqe = ex;
- while (sqe != null) {
- assertTrue(msgs[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextException();
- }
- }
-
- /**
- * Validate that the ordering of the returned SQLWarning is correct using
- * for-each loop
- */
- @Test
- public void test13() {
- SQLWarning ex = new SQLWarning("Warning 1", t1);
- SQLWarning ex1 = new SQLWarning("Warning 2");
- SQLWarning ex2 = new SQLWarning("Warning 3", t2);
- ex.setNextWarning(ex1);
- ex.setNextWarning(ex2);
- int num = 0;
- for (Throwable e : ex) {
- assertTrue(warnings[num++].equals(e.getMessage()));
- }
- }
-
- /**
- * Validate that the ordering of the returned SQLWarning is correct using
- * traditional while loop
- */
- @Test
- public void test14() {
- SQLWarning ex = new SQLWarning("Warning 1", t1);
- SQLWarning ex1 = new SQLWarning("Warning 2");
- SQLWarning ex2 = new SQLWarning("Warning 3", t2);
- ex.setNextWarning(ex1);
- ex.setNextWarning(ex2);
- int num = 0;
- SQLWarning sqe = ex;
- while (sqe != null) {
- assertTrue(warnings[num++].equals(sqe.getMessage()));
- Throwable c = sqe.getCause();
- while (c != null) {
- assertTrue(msgs[num++].equals(c.getMessage()));
- c = c.getCause();
- }
- sqe = sqe.getNextWarning();
- }
- }
-}
--- a/jdk/test/java/sql/test/sql/TimeTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,348 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Time;
-import java.time.LocalTime;
-import static org.testng.Assert.*;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class TimeTests extends BaseTest {
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getYear
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test01() {
- Time t = Time.valueOf("08:30:59");
- t.getYear();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getMonth
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test02() {
- Time t = Time.valueOf("08:30:59");
- t.getMonth();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getDay
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test03() {
- Time t = Time.valueOf("08:30:59");
- t.getDay();
- }
-
- /**
- * Validate an IllegalArgumentException is thrown for calling getDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test04() {
- Time t = Time.valueOf("08:30:59");
- t.getDate();
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setYear
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test05() {
- Time t = Time.valueOf("08:30:59");
- t.setYear(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setMonth
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test06() {
- Time t = Time.valueOf("08:30:59");
- t.setMonth(8);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling setDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test07() {
- Time t = Time.valueOf("08:30:59");
- t.setDate(30);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for calling getDate
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test08() {
- Time t = Time.valueOf("08:30:59");
- t.getDate();
- }
-
- /*
- * Validate that a Time made from a toLocalTime() LocalTime are equal
- */
- @Test
- public void test09() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = Time.valueOf(t.toLocalTime());
- assertTrue(t.equals(t2), "Error t != t2");
- }
-
- /*
- * Validate that a Time LocalTime value, made from a LocalTime are equal
- */
- @Test
- public void test10() {
- LocalTime lt = LocalTime.of(8, 30, 59);
- Time t = Time.valueOf(lt);
- System.out.println("lt=" + lt + ",t=" + t.toLocalTime());
- assertTrue(lt.equals(t.toLocalTime()),
- "Error LocalTime values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDate is passed to valueOf
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test11() throws Exception {
- LocalTime ld = null;
- Time.valueOf(ld);
- }
-
- /*
- * Validate an UnsupportedOperationException occurs when toInstant() is
- * called
- */
- @Test(expectedExceptions = UnsupportedOperationException.class)
- public void test12() throws Exception {
- Time t = new Time(System.currentTimeMillis());
- t.toInstant();
- }
-
- /*
- * Validate that two Time objects are equal when one is created from the
- * toString() of the other and that the correct value is returned from
- * toString()
- */
- @Test(dataProvider = "validTimeValues")
- public void test13(String time, String expected) {
- Time t1 = Time.valueOf(time);
- Time t2 = Time.valueOf(t1.toString());
- assertTrue(t1.equals(t2) && t2.equals(t1)
- && t1.toString().equals(expected), "Error t1 != t2");
- }
-
- /*
- * Validate that two Time values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test14() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(8, 30, 59);
- assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
- }
-
- /*
- * Validate that two Time values one created using valueOf and another via a
- * constructor are equal
- */
- @Test
- public void test15() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Time string
- */
- @Test(dataProvider = "invalidTimeValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test16(String time) throws Exception {
- Time.valueOf(time);
- }
-
- /*
- * Validate that Time.after() returns false when same date is compared
- */
- @Test
- public void test17() {
- Time t = Time.valueOf("08:30:59");
- assertFalse(t.after(t), "Error t.after(t) = true");
- }
-
- /*
- * Validate that Time.after() returns true when later date is compared to
- * earlier date
- */
- @Test
- public void test18() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(System.currentTimeMillis());
- assertTrue(t2.after(t), "Error t2.after(t) = false");
- }
-
- /*
- * Validate that Time.after() returns false when earlier date is compared to
- * itself
- */
- @Test
- public void test19() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertFalse(t.after(t2), "Error t.after(t2) = true");
- assertFalse(t2.after(t), "Error t2.after(t) = true");
- }
-
- /*
- * Validate that Time.before() returns false when same date is compared
- */
- @Test
- public void test20() {
- Time t = Time.valueOf("08:30:59");
- assertFalse(t.before(t), "Error t.before(t) = true");
- }
-
- /*
- * Validate that Time.before() returns true when earlier date is compared to
- * later date
- */
- @Test
- public void test21() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(System.currentTimeMillis());
- assertTrue(t.before(t2), "Error t.before(t2) = false");
- }
-
- /*
- * Validate that Time.before() returns false when earlier date is compared
- * to itself
- */
- @Test
- public void test22() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertFalse(t.before(t2), "Error t.after(t2) = true");
- assertFalse(t2.before(t), "Error t2.after(t) = true");
- }
-
- /*
- * Validate that Time.compareTo returns 0 when both Date objects are the
- * same
- */
- @Test
- public void test23() {
- Time t = Time.valueOf("08:30:59");
- assertTrue(t.compareTo(t) == 0, "Error t.compareTo(t) !=0");
- }
-
- /*
- * Validate thatTime.compareTo returns 0 when both Time objects are the same
- */
- @Test
- public void test24() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime());
- assertTrue(t.compareTo(t2) == 0, "Error t.compareTo(t2) !=0");
- }
-
- /*
- * Validate that Time.compareTo returns 1 when comparing a later Time to an
- * earlier Time
- */
- @Test
- public void test25() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime() + 1);
- assertTrue(t2.compareTo(t) == 1, "Error t2.compareTo(t) !=1");
- }
-
- /*
- * Validate thatTime.compareTo returns 1 when comparing a later Time to an
- * earlier Time
- */
- @Test
- public void test26() {
- Time t = Time.valueOf("08:30:59");
- Time t2 = new Time(t.getTime() + 1);
- assertTrue(t.compareTo(t2) == -1, "Error t.compareTo(t2) != -1");
- }
-
- /*
- * DataProvider used to provide Time values which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidTimeValues")
- private Object[][] invalidTimeValues() {
- return new Object[][]{
- {"2009-11-01 10:50:01"},
- {"1961-08-30 10:50:01.1"},
- {"1961-08-30"},
- {"00:00:00."},
- {"10:50:0.1"},
- {":00:00"},
- {"00::00"},
- {"00:00:"},
- {"::"},
- {" : : "},
- {"0a:00:00"},
- {"00:bb:00"},
- {"00:01:cc"},
- {"08:10:Batman"},
- {"08:10:10:10"},
- {"08:10"},
- {"a:b:c"},
- {null},
- {"8:"}
- };
- }
-
- /*
- * DataProvider used to provide Time values which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method. It also contains the expected return value from
- * toString()
- */
- @DataProvider(name = "validTimeValues")
- private Object[][] validTimeValues() {
- return new Object[][]{
- {"10:50:01", "10:50:01"},
- {"01:1:1", "01:01:01"},
- {"01:01:1", "01:01:01"},
- {"1:01:1", "01:01:01"},
- {"2:02:02", "02:02:02"},
- {"2:02:2", "02:02:02"},
- {"10:50:1", "10:50:01"},
- {"00:00:00", "00:00:00"},
- {"08:30:59", "08:30:59"},
- {"9:0:1", "09:00:01"}
- };
- }
-}
--- a/jdk/test/java/sql/test/sql/TimestampTests.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,777 +0,0 @@
-/*
- * Copyright (c) 2014, 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 test.sql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.Calendar;
-import java.util.TimeZone;
-import static org.testng.Assert.*;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import util.BaseTest;
-
-public class TimestampTests extends BaseTest {
-
- private static TimeZone defaultTimeZone = null;
-
- /*
- * Need to set and use a custom TimeZone which does not
- * observe daylight savings time for this test.
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
- defaultTimeZone = TimeZone.getDefault();
- TimeZone tzone = TimeZone.getTimeZone("GMT+01");
- assertFalse(tzone.observesDaylightTime());
- TimeZone.setDefault(tzone);
- }
-
- /*
- * Conservatively reset the default time zone after test.
- */
- @AfterClass
- public static void tearDownClass() throws Exception {
- TimeZone.setDefault(defaultTimeZone);
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid Timestamp
- */
- @Test(dataProvider = "invalidTimestampValues",
- expectedExceptions = IllegalArgumentException.class)
- public void test(String ts) throws Exception {
- Timestamp.valueOf(ts);
- }
-
- /*
- * Validate that two Timestamp are equal when the leading 0 in seconds is
- * omitted
- */
- @Test
- public void test01() throws Exception {
- String testTS = "2009-01-01 10:50:00";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate two Timestamps created from the same string are equal
- */
- @Test
- public void test02() throws Exception {
- String testTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(testTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month and day
- * equals same string without the leading 0s.
- */
- @Test
- public void test03() throws Exception {
- String testTS = "2009-1-1 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for day omitted
- * are equal
- */
- @Test
- public void test04() throws Exception {
- String testTS = "2009-01-1 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month omitted
- * and both with leading 0s for seconds omitted are equal
- */
- @Test
- public void test05() throws Exception {
- String testTS = "2009-1-01 10:50:0";
- String ExpectedTS = "2009-01-01 10:50:0";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one with leading 0s for month omitted
- */
- @Test
- public void test06() throws Exception {
- String testTS = "2005-1-01 10:20:50.00";
- String ExpectedTS = "2005-01-01 10:20:50.00";
- Timestamp ts = Timestamp.valueOf(testTS);
- Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
- assertEquals(ts, ts2, "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test07() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
- Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 1000000);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test08() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
- Timestamp ts2 = new Timestamp(ts1.getTime());
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that two Timestamp values one created using valueOf and another
- * via a constructor are equal
- */
- @Test
- public void test09() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.0");
- Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 0);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp cannot be equal to null
- */
- @Test
- public void test10() {
-
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25.745634");
- Timestamp ts2 = null;
- assertFalse(ts1.equals(ts2), "Error ts1 == null");
- }
-
- /*
- * Validate that a Timestamp is equal to another timestamp created with the
- * using the same value but not equal to a Timestamp which is one day later
- */
- @Test
- public void test11() {
-
- Timestamp ts1 = Timestamp.valueOf("1996-12-10 12:26:19.12");
- Timestamp ts2 = Timestamp.valueOf("1996-12-10 12:26:19.12");
- Timestamp ts3 = Timestamp.valueOf("1996-12-11 12:24:19.12");
- assertTrue(ts1.equals(ts2) && ts2.equals(ts1), "Error ts1 != ts2");
- assertFalse(ts1.equals(ts3) && ts3.equals(ts1), "Error ts1 == ts3");
-
- }
-
- /*
- * Validate that a Timestamp is equal to itself
- */
- @Test
- public void test12() {
- Timestamp ts1 = Timestamp.valueOf("1996-10-15 12:26:19.12");
- assertTrue(ts1.equals(ts1), "Error ts1 != ts1");
- }
-
- /*
- * Validate that two Timestamps are equal when one is created from the
- * toString() of the other
- */
- @Test(dataProvider = "validTimestampValues")
- public void test13(String ts, String expectedTS) {
- Timestamp ts1 = Timestamp.valueOf(ts);
- Timestamp ts2 = Timestamp.valueOf(ts1.toString());
- assertTrue(ts1.equals(ts2) && ts2.equals(ts1)
- && ts1.toString().equals(expectedTS), "Error ts1 != ts2");
- }
-
- // Before Tests
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test14() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1996-12-13 15:15:25.645634");
- assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
- }
-
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test15() {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25");
- Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25");
- assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
- }
-
- /*
- * Validate that Timestamp ts1 is before Timestamp ts2
- */
- @Test
- public void test16() {
-
- Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1999-11-13 15:15:25.645634");
- assertFalse(ts1.before(ts2), "Error ts1 before ts2");
- }
-
- /*
- * Validate that a NullPointerException is thrown if a null is passed to
- * the before method
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test17() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- ts1.before(null);
- }
-
- /*
- * Validate a Timestamp cannot be before itself
- */
- @Test
- public void test18() {
- Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
- assertFalse(ts1.before(ts1), "Error ts1 before ts1!");
- }
-
- /*
- * Create 3 Timestamps and make sure the 1st is before the other two
- * Timestamps which are each greater than the one before it
- */
- @Test
- public void test19() {
-
- Timestamp ts1 = new Timestamp(1234560000);
- Timestamp ts2 = new Timestamp(1234567000);
- Timestamp ts3 = new Timestamp(1234569000);
- assertTrue(ts1.before(ts2) && ts2.before(ts3) && ts1.before(ts3));
- }
-
- /*
- * Validate that Timestamp ts1 is not after Timestamp ts2
- */
- @Test
- public void test20() {
- Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25.645634");
- assertFalse(ts1.after(ts2), "Error ts1 is after ts2");
-
- }
-
- /*
- * Validate that Timestamp ts1 is after Timestamp ts2
- */
- @Test
- public void test21() {
- Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
- Timestamp ts2 = Timestamp.valueOf("1996-11-13 15:15:25.645634");
- assertTrue(ts1.after(ts2), "Error ts1 not after ts2");
- }
-
- /*
- * Validate that a NullPointerException is thrown if a null is passed to the
- * after method
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test22() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- ts1.after(null);
- }
-
- /*
- * Validate that a Timestamp cannot be after itself
- */
- @Test
- public void test23() {
- Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
- assertFalse(ts1.after(ts1), "Error ts1 is after itself");
- }
-
- /*
- * Validate that a Timestamp after() works correctly with Timestamp created
- * using milliseconds
- */
- @Test
- public void test24() {
-
- Timestamp ts1 = new Timestamp(1234568000);
- Timestamp ts2 = new Timestamp(1234565000);
- Timestamp ts3 = new Timestamp(1234562000);
- assertTrue(ts1.after(ts2) && ts2.after(ts3) && ts1.after(ts3));
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test25() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime());
- assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
- }
-
- /*
- * Validate compareTo returns -1 for when the 1st Timestamp is earlier than
- * the 2nd Timestamp
- */
- @Test
- public void test26() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime() + 1000);
- assertTrue(ts1.compareTo(ts2) == -1, "Error ts1 not before ts2");
- assertTrue(ts2.compareTo(ts1) == 1, "Error ts1 is not before ts2");
- }
-
- /*
- * Validate compareTo returns 1 for when the 1st Timestamp is later than the
- * 2nd Timestamp
- */
- @Test
- public void test27() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = new Timestamp(ts1.getTime() - 1000);
- assertTrue(ts1.compareTo(ts2) == 1, "Error ts1 not after ts2");
- assertTrue(ts2.compareTo(ts1) == -1, "Error ts1 not after ts2");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test28() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date ts2 = new java.util.Date(ts1.getTime());
- assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test29() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new java.util.Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 == d");
- }
-
- /*
- * Validate compareTo returns 0 for Timestamps that are the same
- */
- @Test
- public void test30() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new Timestamp(ts1.getTime());
- assertTrue(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Date object is passed to equals
- */
- @Test
- public void test31() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Date d = new Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Date object is passed to equals
- */
- @Test
- public void test32() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- java.util.Date d = new Date(ts1.getTime());
- assertFalse(ts1.equals(d), "Error ts1 != d");
- }
-
- /*
- * Validate equals returns false when a Time object is passed to equals
- */
- @Test
- public void test33() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Time t1 = new Time(ts1.getTime());
- assertFalse(ts1.equals(t1), "Error ts1 == t1");
- }
-
- /*
- * Validate equals returns false when a String object is passed to equals
- */
- @Test
- public void test34() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- assertFalse(ts1.equals("1966-08-30 08:08:08"), "Error ts1 == a String");
- }
-
- /*
- * Validate getTime() returns the same value from 2 timeStamps created by
- */
- @Test
- public void test35() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = Timestamp.valueOf("1966-08-30 08:08:08");
- assertTrue(ts2.getTime() == ts1.getTime(),
- "ts1.getTime() != ts2.getTime()");
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate getTime() returns the same value from 2 timeStamps when
- * setTime() is used to specify the same value for both Timestamps
- */
- @Test
- public void test36() {
- Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
- Timestamp ts2 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts2.setTime(ts1.getTime());
- assertTrue(ts2.getTime() == ts1.getTime(),
- "ts1.getTime() != ts2.getTime()");
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid nanos value
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test38() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(-1);
-
- }
-
- /*
- * Validate an IllegalArgumentException is thrown for an invalid nanos value
- */
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void test39() throws Exception {
- int nanos = 999999999;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos + 1);
- }
-
- /*
- * Validate you can set nanos to 999999999
- */
- @Test
- public void test40() throws Exception {
- int nanos = 999999999;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos);
- assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
- }
-
- /*
- * Validate you can set nanos to 0
- */
- @Test
- public void test41() throws Exception {
- int nanos = 0;
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- ts1.setNanos(nanos);
- assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
- }
-
- /*
- * Validate that a Timestamp made from a LocalDateTime are equal
- */
- @Test
- public void test42() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- LocalDateTime ldt = ts1.toLocalDateTime();
- Timestamp ts2 = Timestamp.valueOf(ldt);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp LocalDateTime value, made from a LocalDateTime
- * are equal
- */
- @Test
- public void test43() throws Exception {
- LocalDateTime ldt = LocalDateTime.now();
- Timestamp ts2 = Timestamp.valueOf(ldt);
- assertTrue(ldt.equals(ts2.toLocalDateTime()),
- "Error LocalDateTime values are not equal");
- }
-
- /*
- * Validate an NPE occurs when a null LocalDateTime is passed to valueOF
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test44() throws Exception {
- LocalDateTime ldt = null;
- Timestamp.valueOf(ldt);
- }
-
- /*
- * Validate that a Timestamp made from a Instant are equal
- */
- @Test
- public void test45() throws Exception {
- Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
- Instant instant = ts1.toInstant();
- Timestamp ts2 = Timestamp.from(instant);
- assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
- }
-
- /*
- * Validate that a Timestamp made from a Instant are equal
- */
- @Test
- public void test46() throws Exception {
- Instant instant = Instant.now();
- Timestamp ts2 = Timestamp.from(instant);
- assertTrue(instant.equals(ts2.toInstant()),
- "Error Instant values do not match");
- }
-
- /*
- * Validate an NPE occurs when a null instant is passed to from
- */
- @Test(expectedExceptions = NullPointerException.class)
- public void test47() throws Exception {
- Instant instant = null;
- Timestamp.from(instant);
- }
-
- // Added SQE tests
- /*
- * Create a Timestamp and a 2nd Timestamp that is 1 month earlier and
- * validate that it is not before or after the original Timestamp
- */
- @Test
- public void test48() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertFalse(ts1.before(ts2) || ts2.after(ts1));
- }
-
- /*
- * Create two Timestamps and validate that compareTo returns 1 to indicate
- * the 1st Timestamp is greater than the 2nd Timestamp
- */
- @Test
- public void test49() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertTrue(ts1.compareTo(ts2) == 1);
- }
-
- /*
- * Create two Timestamps and validate that the 1st Timestamp is not equal to
- * the 2nd Timestamp but equal to itself
- */
- @Test
- public void test50() {
- Calendar cal = Calendar.getInstance();
- Timestamp ts1 = new Timestamp(System.currentTimeMillis());
- cal.setTimeInMillis(ts1.getTime());
- cal.add(Calendar.MONTH, -1);
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
- Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
- assertTrue(!ts1.equals(ts2) && ts1.equals(ts1));
- }
-
- /*
- * Validate that two Timestamps are equal when one is created from the
- * toString() of the other
- */
- @Test(dataProvider = "validateNanos")
- public void test51(String ts, int nanos) {
- Timestamp ts1 = Timestamp.valueOf(ts);
- Timestamp ts2 = Timestamp.valueOf(ts1.toString());
- assertTrue(ts1.getNanos() == nanos && ts1.equals(ts2),
- "Error with Nanos");
- }
-
- @Test(dataProvider = "validTimestampLongValues")
- public void test52(long value, String ts) {
- Timestamp ts1 = new Timestamp(value);
- assertEquals(ts1.toString(), ts, "ts1.toString() != ts");
- }
-
- /*
- * DataProvider used to provide Timestamps which are not valid and are used
- * to validate that an IllegalArgumentException will be thrown from the
- * valueOf method
- */
- @DataProvider(name = "invalidTimestampValues")
- private Object[][] invalidTimestampValues() {
- return new Object[][]{
- {"2009-11-01-01 10:50:01"},
- {"aaaa-11-01-01 10:50"},
- {"aaaa-11-01 10:50"},
- {"1961--30 00:00:00"},
- {"--30 00:00:00"},
- {"-- 00:00:00"},
- {"1961-1- 00:00:00"},
- {"2009-11-01"},
- {"10:50:01"},
- {"1961-a-30 00:00:00"},
- {"1961-01-bb 00:00:00"},
- {"1961-08-30 00:00:00."},
- {"1961-08-30 :00:00"},
- {"1961-08-30 00::00"},
- {"1961-08-30 00:00:"},
- {"1961-08-30 ::"},
- {"1961-08-30 0a:00:00"},
- {"1961-08-30 00:bb:00"},
- {"1961-08-30 00:01:cc"},
- {"1961-08-30 00:00:00.01a"},
- {"1961-08-30 00:00:00.a"},
- {"1996-12-10 12:26:19.1234567890"},
- {null}
- };
- }
-
- /*
- * DataProvider used to provide Timestamps which are valid and are used
- * to validate that an IllegalArgumentException will not be thrown from the
- * valueOf method and the corect value from toString() is returned
- */
- @DataProvider(name = "validTimestampValues")
- private Object[][] validTimestampValues() {
- return new Object[][]{
- {"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
- {"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
- {"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
- {"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
- {"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
- {"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
- {"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
- {"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
- {"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
- {"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
- {"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
- {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
- {"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
- {"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
- {"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
- {"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
- {"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
- {"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
- {"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
- {"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
- {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
- {"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
- {"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
- };
- }
-
- @DataProvider(name = "validTimestampLongValues")
- private Object[][] validTimestampLongValues() {
- return new Object[][]{
- {1L, "1970-01-01 01:00:00.001"},
- {-3600*1000L - 1, "1969-12-31 23:59:59.999"},
- {-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
- {Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
- {Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
- {new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
- {new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
- {new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
- {new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
- {LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
-
- // millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
- // Long.MAX_VALUE, while actually representing 292278994 BCE
- {Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
- {Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
- {Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
- {Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
-
- // wrap around point near 0001-01-01, test that we never get a negative year:
- {-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
- {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
- {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
-
- {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
- {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
- .toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
- };
- }
-
- /*
- * DataProvider used to provide Timestamp and Nanos values in order to
- * validate that the correct Nanos value is generated from the specified
- * Timestamp
- */
- @DataProvider(name = "validateNanos")
- private Object[][] validateNanos() {
- return new Object[][]{
- {"1961-08-30 00:00:00", 0},
- {"1996-12-10 12:26:19.1", 100000000},
- {"1996-12-10 12:26:19.12", 120000000},
- {"1996-12-10 12:26:19.123", 123000000},
- {"1996-12-10 12:26:19.1234", 123400000},
- {"1996-12-10 12:26:19.12345", 123450000},
- {"1996-12-10 12:26:19.123456", 123456000},
- {"1996-12-10 12:26:19.1234567", 123456700},
- {"1996-12-10 12:26:19.12345678", 123456780},
- {"1996-12-10 12:26:19.123456789", 123456789},
- {"1996-12-10 12:26:19.000000001", 1},
- {"1996-12-10 12:26:19.000000012", 12},
- {"1996-12-10 12:26:19.000000123", 123},
- {"1996-12-10 12:26:19.000001234", 1234},
- {"1996-12-10 12:26:19.000012345", 12345},
- {"1996-12-10 12:26:19.000123456", 123456},
- {"1996-12-10 12:26:19.001234567", 1234567},
- {"1996-12-10 12:26:19.012345678", 12345678},
- {"1996-12-10 12:26:19.0", 0},
- {"1996-12-10 12:26:19.01230", 12300000}
- };
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/TEST.properties Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,3 @@
+# JDBC unit tests uses TestNG
+TestNG.dirs = .
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/BatchUpdateExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.ObjectInputStream;
+import java.sql.BatchUpdateException;
+import java.sql.SQLException;
+import java.util.Arrays;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.SerializedBatchUpdateException;
+import util.BaseTest;
+
+public class BatchUpdateExceptionTests extends BaseTest {
+
+ private final int[] uc = {1, 2, 3};
+ private final long[] luc = {1, 2, 3};
+
+ private final String testSrcDir = System.getProperty("test.src", ".")
+ + File.separatorChar;
+
+ /**
+ * Create BatchUpdateException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ BatchUpdateException be = new BatchUpdateException(null,
+ null, errorCode, (int[]) null, null);
+ assertTrue(be.getMessage() == null && be.getSQLState() == null
+ && be.getUpdateCounts() == null && be.getCause() == null
+ && be.getLargeUpdateCounts() == null
+ && be.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create BatchUpdateException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ BatchUpdateException ex = new BatchUpdateException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Create BatchUpdateException with null Throwable
+ */
+ @Test
+ public void test2() {
+ BatchUpdateException ex = new BatchUpdateException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Create BatchUpdateException with message and update counts
+ */
+ @Test
+ public void test3() {
+
+ BatchUpdateException ex = new BatchUpdateException(reason, uc);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with update counts
+ */
+ @Test
+ public void test4() {
+ BatchUpdateException ex = new BatchUpdateException(uc);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with Throwable and update counts
+ */
+ @Test
+ public void test5() {
+ BatchUpdateException ex = new BatchUpdateException(uc, t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, Throwable, and update counts
+ */
+ @Test
+ public void test6() {
+ BatchUpdateException ex = new BatchUpdateException(reason, uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, Throwable, and update
+ * counts
+ */
+ @Test
+ public void test7() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, errorCode code
+ * Throwable, and update counts
+ */
+ @Test
+ public void test8() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
+ uc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Create BatchUpdateException with message, SQLState, errorCode code
+ * Throwable, and long [] update counts
+ */
+ @Test
+ public void test9() {
+ BatchUpdateException ex = new BatchUpdateException(reason, state, errorCode,
+ luc, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && Arrays.equals(ex.getUpdateCounts(), uc)
+ && Arrays.equals(ex.getLargeUpdateCounts(), luc)
+ );
+ }
+
+ /**
+ * Validate that a copy of the update counts array is made
+ */
+ @Test
+ public void test10() {
+ int[] uc1 = {1, 2};
+ BatchUpdateException ex = new BatchUpdateException(uc1);
+ assertTrue(Arrays.equals(ex.getUpdateCounts(), uc1));
+ uc1[0] = 6689;
+ assertFalse(Arrays.equals(ex.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Validate that if null is specified for the update count, it is returned
+ * as null
+ */
+ @Test
+ public void test11() {
+ BatchUpdateException ex = new BatchUpdateException((int[]) null);
+ assertTrue(ex.getMessage() == null && ex.getSQLState() == null
+ && ex.getErrorCode() == 0 && ex.getUpdateCounts() == null
+ && ex.getLargeUpdateCounts() == null);
+ }
+
+ /**
+ * Serialize a BatchUpdateException and make sure you can read it back
+ * properly
+ */
+ @Test
+ public void test12() throws Exception {
+ BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
+ uc, t);
+ BatchUpdateException bue
+ = createSerializedException(be);
+ assertTrue(reason.equals(bue.getMessage())
+ && bue.getSQLState().equals(state)
+ && cause.equals(bue.getCause().toString())
+ && bue.getErrorCode() == errorCode
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc)
+ && Arrays.equals(bue.getUpdateCounts(), uc));
+ }
+
+
+
+ /**
+ * De-Serialize a BatchUpdateException from JDBC 4.0 and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test13() throws Exception {
+ String reason1 = "This was the error msg";
+ String state1 = "user defined sqlState";
+ String cause1 = "java.lang.Throwable: throw 1";
+ int errorCode1 = 99999;
+ Throwable t = new Throwable("throw 1");
+ int[] uc1 = {1, 2, 21};
+ long[] luc1 = {1, 2, 21};
+
+ ObjectInputStream ois = new ObjectInputStream(
+ new ByteArrayInputStream(SerializedBatchUpdateException.DATA));
+ BatchUpdateException bue = (BatchUpdateException) ois.readObject();
+ assertTrue(reason1.equals(bue.getMessage())
+ && bue.getSQLState().equals(state1)
+ && bue.getErrorCode() == errorCode1
+ && cause1.equals(bue.getCause().toString())
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
+ && Arrays.equals(bue.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Serialize a BatchUpdateException with an Integer.MAX_VALUE + 1 and
+ * validate you can read it back properly
+ */
+ @Test
+ public void test14() throws Exception {
+ int[] uc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
+ long[] luc1 = {Integer.MAX_VALUE, Integer.MAX_VALUE + 1};
+ BatchUpdateException be = new BatchUpdateException(reason, state, errorCode,
+ luc1, t);
+ BatchUpdateException bue
+ = createSerializedException(be);
+ assertTrue(reason.equals(bue.getMessage())
+ && bue.getSQLState().equals(state)
+ && cause.equals(bue.getCause().toString())
+ && bue.getErrorCode() == errorCode
+ && Arrays.equals(bue.getLargeUpdateCounts(), luc1)
+ && Arrays.equals(bue.getUpdateCounts(), uc1));
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test15() {
+ BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
+ BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
+ BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test16() {
+ BatchUpdateException ex = new BatchUpdateException("Exception 1", uc, t1);
+ BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
+ BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ SQLException sqe = ex;
+ int num = 0;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DataTruncationTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.DataTruncation;
+import java.sql.SQLException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class DataTruncationTests extends BaseTest {
+
+ private final String READ_TRUNCATION = "01004";
+ private final String WRITE_TRUNCATION = "22001";
+ private final String dtReason = "Data truncation";
+ private final int dterrorCode = 0;
+ private final String[] dtmsgs = {dtReason, "cause 1", dtReason,
+ dtReason, "cause 2"};
+ private boolean onRead = false;
+ private final boolean parameter = false;
+ private final int index = 21;
+ private final int dataSize = 25;
+ private final int transferSize = 10;
+
+ /**
+ * Create DataTruncation object indicating a truncation on read
+ */
+ @Test
+ public void test() {
+ onRead = true;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on write
+ */
+ @Test
+ public void test1() {
+ onRead = false;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(WRITE_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read with a
+ * Throwable
+ */
+ @Test
+ public void test2() {
+ onRead = true;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && cause.equals(e.getCause().toString())
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read with null
+ * specified for the Throwable
+ */
+ @Test
+ public void test3() {
+ onRead = true;;
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, null);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Create DataTruncation object indicating a truncation on read and you can
+ * pass a -1 for the index
+ */
+ @Test
+ public void test4() {
+ onRead = true;
+ int negIndex = -1;
+ DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
+ dataSize, transferSize);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == negIndex);
+ }
+
+ /**
+ * Serialize a DataTruncation and make sure you can read it back properly
+ */
+ @Test
+ public void test5() throws Exception {
+ DataTruncation e = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex1 = createSerializedException(e);
+ assertTrue(e.getMessage().equals(dtReason)
+ && e.getSQLState().equals(READ_TRUNCATION)
+ && e.getCause() == null
+ && e.getErrorCode() == dterrorCode
+ && e.getParameter() == parameter
+ && e.getRead() == onRead
+ && e.getDataSize() == dataSize
+ && e.getTransferSize() == transferSize
+ && e.getIndex() == index);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ DataTruncation ex = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t1);
+ DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(dtmsgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ DataTruncation ex = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t1);
+ DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize);
+ DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
+ dataSize, transferSize, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(dtmsgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DateTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Date;
+import java.time.Instant;
+import java.time.LocalDate;
+import static org.testng.Assert.*;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class DateTests extends BaseTest {
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Date string
+ */
+ @Test(dataProvider = "invalidDateValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test(String d) throws Exception {
+ Date.valueOf(d);
+ }
+
+ /*
+ * Test that a date created from a date string is equal to the value
+ * returned from toString()
+ */
+ @Test(dataProvider = "validDateValues")
+ public void test00(String d, String expectedD) {
+ Date d1 = Date.valueOf(d);
+ Date d2 = Date.valueOf(expectedD);
+ assertTrue(d1.equals(d2) && d2.equals(d1)
+ && d1.toString().equals(expectedD), "Error d1 != d2");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when same date is compared
+ */
+ @Test
+ public void test01() {
+ Date d = Date.valueOf("1961-08-30");
+ assertFalse(d.after(d), "Error d.after(d) = true");
+ }
+
+ /*
+ * Validate that a Date.after() returns true when later date is compared to
+ * earlier date
+ */
+ @Test
+ public void test2() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d2.after(d), "Error d2.after(d) = false");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when earlier date is compared
+ * to later date
+ */
+ @Test
+ public void test3() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.after(d2), "Error d.after(d2) = true");
+ }
+
+ /*
+ * Validate that a Date.after() returns false when date compared to another
+ * date created from the original date
+ */
+ @Test
+ public void test4() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.after(d2), "Error d.after(d2) = true");
+ assertFalse(d2.after(d), "Error d2.after(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when same date is compared
+ */
+ @Test
+ public void test5() {
+ Date d = Date.valueOf("1961-08-30");
+ assertFalse(d.before(d), "Error d.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns true when earlier date is compared
+ * to later date
+ */
+ @Test
+ public void test6() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d.before(d2), "Error d.before(d2) = false");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when later date is compared
+ * to earlier date
+ */
+ @Test
+ public void test7() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d2.before(d), "Error d2.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.before() returns false when date compared to another
+ * date created from the original date
+ */
+ @Test
+ public void test8() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertFalse(d.before(d2), "Error d.before(d2) = true");
+ assertFalse(d2.before(d), "Error d2.before(d) = true");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 0 when both Date objects are the
+ * same
+ */
+ @Test
+ public void test9() {
+ Date d = Date.valueOf("1961-08-30");
+ assertTrue(d.compareTo(d) == 0, "Error d.compareTo(d) !=0");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 0 when both Date objects represent
+ * the same date
+ */
+ @Test
+ public void test10() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertTrue(d.compareTo(d2) == 0, "Error d.compareTo(d2) !=0");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns -1 when comparing a date to a
+ * later date
+ */
+ @Test
+ public void test11() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d.compareTo(d2) == -1, "Error d.compareTo(d2) != -1");
+ }
+
+ /*
+ * Validate that a Date.compareTo returns 1 when comparing a date to an
+ * earlier date
+ */
+ @Test
+ public void test12() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(System.currentTimeMillis());
+ assertTrue(d2.compareTo(d) == 1, "Error d.compareTo(d2) != 1");
+ }
+
+ /*
+ * Validate that a Date made from a LocalDate are equal
+ */
+ @Test
+ public void test13() {
+ Date d = Date.valueOf("1961-08-30");
+ LocalDate ldt = d.toLocalDate();
+ Date d2 = Date.valueOf(ldt);
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that a Date LocalDate value, made from a LocalDate are equal
+ */
+ @Test
+ public void test14() {
+ LocalDate ldt = LocalDate.now();
+ Date d = Date.valueOf(ldt);
+ assertTrue(ldt.equals(d.toLocalDate()),
+ "Error LocalDate values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDate is passed to valueOf
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test15() throws Exception {
+ LocalDate ld = null;
+ Date.valueOf(ld);
+ }
+
+ /*
+ * Validate an UnsupportedOperationException occurs when toInstant() is
+ * called
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void test16() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ Instant instant = d.toInstant();
+ }
+
+ /*
+ * Validate that two Date objects are equal when one is created from the
+ * toString() of the other
+ */
+ @Test
+ public void test17() {
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = Date.valueOf(d.toString());
+ assertTrue(d.equals(d2) && d2.equals(d), "Error d != d2");
+ }
+
+ /*
+ * Validate that two Date values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test18() {
+
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(61, 7, 30);
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that two Date values one created using getTime() of the other
+ * are equal
+ */
+ @Test
+ public void test19() {
+
+ Date d = Date.valueOf("1961-08-30");
+ Date d2 = new Date(d.getTime());
+ assertTrue(d.equals(d2), "Error d != d2");
+ }
+
+ /*
+ * Validate that a Date value is equal to itself
+ */
+ @Test
+ public void test20() {
+
+ Date d = Date.valueOf("1961-08-30");
+ assertTrue(d.equals(d), "Error d != d");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getHours
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test21() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getHours();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getMinutes
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test22() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getMinutes();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getSeconds
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test23() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.getSeconds();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setHours
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test24() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setHours(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setMinutes
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test25() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setMinutes(0);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setSeconds
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test26() throws Exception {
+ Date d = Date.valueOf("1961-08-30");
+ d.setSeconds(0);
+ }
+
+ /*
+ * DataProvider used to provide Date which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidDateValues")
+ private Object[][] invalidDateValues() {
+ return new Object[][]{
+ {"20009-11-01"},
+ {"09-11-01"},
+ {"-11-01"},
+ {"2009-111-01"},
+ {"2009--01"},
+ {"2009-13-01"},
+ {"2009-11-011"},
+ {"2009-11-"},
+ {"2009-11-00"},
+ {"2009-11-33"},
+ {"--"},
+ {""},
+ {null},
+ {"-"},
+ {"2009"},
+ {"2009-01"},
+ {"---"},
+ {"2009-13--1"},
+ {"1900-1-0"},
+ {"2009-01-01 10:50:01"},
+ {"1996-12-10 12:26:19.1"},
+ {"10:50:01"}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Dates which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method and the corect value from toString() is returned
+ */
+ @DataProvider(name = "validDateValues")
+ private Object[][] validDateValues() {
+ return new Object[][]{
+ {"2009-08-30", "2009-08-30"},
+ {"2009-01-8", "2009-01-08"},
+ {"2009-1-01", "2009-01-01"},
+ {"2009-1-1", "2009-01-01"}
+
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DriverManagerPermissionsTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.security.AccessControlException;
+import java.security.Policy;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import util.BaseTest;
+import util.StubDriver;
+import util.TestPolicy;
+
+public class DriverManagerPermissionsTests extends BaseTest {
+
+ private static Policy policy;
+ private static SecurityManager sm;
+
+ /*
+ * Install a SecurityManager along with a base Policy to allow testNG to run
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ setPolicy(new TestPolicy());
+ System.setSecurityManager(new SecurityManager());
+ }
+
+ /*
+ * Install the original Policy and SecurityManager
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ System.setSecurityManager(sm);
+ setPolicy(policy);
+ }
+
+ /*
+ * Save off the original Policy and SecurityManager
+ */
+ public DriverManagerPermissionsTests() {
+ policy = Policy.getPolicy();
+ sm = System.getSecurityManager();
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if SQLPermission("setLog")
+ * has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test() {
+ setPolicy(new TestPolicy());
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that setLogStream succeeds if SQLPermission("setLog") has been
+ * granted
+ */
+ @Test
+ public void test1() {
+ Policy.setPolicy(new TestPolicy("setLog"));
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that setLogStream succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test2() {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.setLogStream(null);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if SQLPermission("setLog")
+ * has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test4() {
+ setPolicy(new TestPolicy());
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that setLogWriter succeeds if SQLPermission("setLog") has been
+ * granted
+ */
+ @Test
+ public void test5() {
+ setPolicy(new TestPolicy("setLog"));
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that setLogWriter succeeds if AllPermissions has been granted
+ */
+ @Test
+ public void test6() {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.setLogWriter(null);
+ }
+
+ /*
+ * Validate that AccessControlException is thrown if
+ * SQLPermission("deregisterDriver") has not been granted
+ */
+ @Test(expectedExceptions = AccessControlException.class)
+ public void test7() throws SQLException {
+ setPolicy(new TestPolicy());
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+
+ /*
+ * Validate that deregisterDriver succeeds if
+ * SQLPermission("deregisterDriver") has been granted
+ */
+ @Test
+ public void test8() throws SQLException {
+ setPolicy(new TestPolicy("deregisterDriver"));
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+
+ /*
+ * Validate that deregisterDriver succeeds if AllPermissions has been
+ * granted
+ */
+ @Test
+ public void test9() throws SQLException {
+ setPolicy(new TestPolicy("all"));
+ DriverManager.deregisterDriver(new StubDriver());
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/DriverManagerTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import util.StubDriver;
+
+public class DriverManagerTests {
+
+ private final String StubDriverURL = "jdbc:tennis:boy";
+ private final String StubDriverDAURL = "jdbc:luckydog:tennis";
+ private final String InvalidURL = "jdbc:cardio:tennis";
+ private String[] results = {"output", "more output", "and more", "the end"};
+ private String noOutput = "should not find this";
+
+ public DriverManagerTests() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ removeAllDrivers();
+ }
+
+ @AfterMethod
+ public void tearDownMethod() throws Exception {
+ }
+
+ /**
+ * Utility method to remove all registered drivers
+ */
+ private static void removeAllDrivers() {
+ java.util.Enumeration e = DriverManager.getDrivers();
+ while (e.hasMoreElements()) {
+ try {
+ DriverManager.deregisterDriver((Driver) (e.nextElement()));
+ } catch (SQLException ex) {
+ System.out.print(ex.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Utility method to see if a driver is registered
+ */
+ private boolean isDriverRegistered(Driver d) {
+ boolean foundDriver = false;
+ java.util.Enumeration e = DriverManager.getDrivers();
+ while (e.hasMoreElements()) {
+ if (d == (Driver) e.nextElement()) {
+ foundDriver = true;
+ break;
+ }
+ }
+ return foundDriver;
+ }
+
+ /**
+ * Validate that values set using setLoginTimeout will be returned by
+ * getLoginTimeout
+ */
+ @Test
+ public void test() {
+ int[] vals = {-1, 0, 5};
+ for (int val : vals) {
+ DriverManager.setLoginTimeout(val);
+ assertEquals(val, DriverManager.getLoginTimeout());
+ }
+ }
+
+ /**
+ * Validate that NullPointerException is thrown when null is passed to
+ * registerDriver
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test1() throws Exception {
+ Driver d = null;
+ DriverManager.registerDriver(d);
+ }
+
+ /**
+ * Validate that NullPointerException is thrown when null is passed to
+ * registerDriver
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test2() throws Exception {
+ Driver d = null;
+ DriverManager.registerDriver(d, null);
+ }
+
+ /**
+ * Validate that a null value allows for deRegisterDriver to return
+ */
+ @Test
+ public void test3() throws Exception {
+ DriverManager.deregisterDriver(null);
+
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test4() throws Exception {
+ DriverManager.getConnection(InvalidURL);
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test5() throws Exception {
+ DriverManager.getConnection(InvalidURL, new Properties());
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test6() throws Exception {
+ DriverManager.getConnection(InvalidURL, "LuckyDog", "tennisanyone");
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test7() throws Exception {
+ DriverManager.getConnection(null);
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test8() throws Exception {
+ DriverManager.getConnection(null, new Properties());
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test9() throws Exception {
+ DriverManager.getConnection(null, "LuckyDog", "tennisanyone");
+ }
+
+ /**
+ * Validate that SQLException is thrown when there is no Driver to service
+ * the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test10() throws Exception {
+ DriverManager.getDriver(InvalidURL);
+ }
+
+ /**
+ * Validate that SQLException is thrown when null is passed for the URL
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test11() throws Exception {
+ DriverManager.getDriver(null);
+ }
+
+ /**
+ * Validate that a non-null Driver is returned by getDriver when a valid URL
+ * is specified
+ */
+ @Test
+ public void test12() throws Exception {
+
+ DriverManager.registerDriver(new StubDriver());
+ assertTrue(DriverManager.getDriver(StubDriverURL) != null);
+ }
+
+ /**
+ * Validate that SQLException is thrown when the URL is not valid for any of
+ * the registered drivers
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test13() throws Exception {
+ DriverManager.registerDriver(new StubDriver());
+ DriverManager.getDriver(InvalidURL);
+ }
+
+ /**
+ * Validate that a Connection object is returned when a valid URL is
+ * specified to getConnection
+ *
+ */
+ @Test
+ public void test14() throws Exception {
+
+ DriverManager.registerDriver(new StubDriver());
+ assertTrue(
+ DriverManager.getConnection(StubDriverURL) != null);
+ assertTrue(DriverManager.getConnection(StubDriverURL,
+ "LuckyDog", "tennisanyone") != null);
+ Properties props = new Properties();
+ props.put("user", "LuckyDog");
+ props.put("password", "tennisanyone");
+ assertTrue(
+ DriverManager.getConnection(StubDriverURL,
+ props) != null);
+ }
+
+ /**
+ * Register a driver and make sure you find it via its URL. Deregister the
+ * driver and validate it is not longer registered
+ *
+ * @throws Exception
+ */
+ @Test()
+ public void test15() throws Exception {
+ DriverManager.registerDriver(new StubDriver());
+ Driver d = DriverManager.getDriver(StubDriverURL);
+ assertTrue(d != null);
+ assertTrue(isDriverRegistered(d));
+ DriverManager.deregisterDriver(d);
+ assertFalse(isDriverRegistered(d));
+ }
+
+ /**
+ * Validate that DriverAction.release is called when a driver is registered
+ * via registerDriver(Driver, DriverAction)
+ *
+ * @throws Exception
+ */
+ @Test
+ public void test16() throws Exception {
+ File file = new File(util.StubDriverDA.DriverActionCalled);
+ file.delete();
+ assertFalse(file.exists());
+ Driver d = null;
+ Class.forName("util.StubDriverDA");
+ d = DriverManager.getDriver(StubDriverDAURL);
+ DriverManager.deregisterDriver(d);
+ assertFalse(isDriverRegistered(d), "Driver is registered");
+ assertTrue(file.exists());
+ }
+
+ /**
+ * Create a PrintStream and use to send output via DriverManager.println
+ * Validate that if you disable the stream, the output sent is not present
+ */
+ @Test
+ public void tests17() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(os);
+ DriverManager.setLogStream(ps);
+ assertTrue(DriverManager.getLogStream() == ps);
+
+ DriverManager.println(results[0]);
+ DriverManager.setLogStream((PrintStream) null);
+ assertTrue(DriverManager.getLogStream() == null);
+ DriverManager.println(noOutput);
+ DriverManager.setLogStream(ps);
+ DriverManager.println(results[1]);
+ DriverManager.println(results[2]);
+ DriverManager.println(results[3]);
+ DriverManager.setLogStream((PrintStream) null);
+ DriverManager.println(noOutput);
+
+ /*
+ * Check we do not get the output when the stream is disabled
+ */
+ InputStreamReader is
+ = new InputStreamReader(new ByteArrayInputStream(os.toByteArray()));
+ BufferedReader reader = new BufferedReader(is);
+ for (String result : results) {
+ assertTrue(result.equals(reader.readLine()));
+ }
+ }
+
+ /**
+ * Create a PrintWriter and use to to send output via DriverManager.println
+ * Validate that if you disable the writer, the output sent is not present
+ */
+ @Test
+ public void tests18() throws Exception {
+ CharArrayWriter cw = new CharArrayWriter();
+ PrintWriter pw = new PrintWriter(cw);
+ DriverManager.setLogWriter(pw);
+ assertTrue(DriverManager.getLogWriter() == pw);
+
+ DriverManager.println(results[0]);
+ DriverManager.setLogWriter(null);
+ assertTrue(DriverManager.getLogWriter() == null);
+ DriverManager.println(noOutput);
+ DriverManager.setLogWriter(pw);
+ DriverManager.println(results[1]);
+ DriverManager.println(results[2]);
+ DriverManager.println(results[3]);
+ DriverManager.setLogWriter(null);
+ DriverManager.println(noOutput);
+
+ /*
+ * Check we do not get the output when the stream is disabled
+ */
+ BufferedReader reader
+ = new BufferedReader(new CharArrayReader(cw.toCharArray()));
+ for (String result : results) {
+ assertTrue(result.equals(reader.readLine()));
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.ClientInfoStatus;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLClientInfoExceptionTests extends BaseTest {
+
+ private final HashMap<String, ClientInfoStatus> map = new HashMap<>();
+
+ public SQLClientInfoExceptionTests() {
+ map.put("1", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
+ map.put("21", ClientInfoStatus.REASON_UNKNOWN_PROPERTY);
+ }
+
+ /**
+ * Create SQLClientInfoException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLClientInfoException e = new SQLClientInfoException(null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == 0
+ && e.getFailedProperties() == null);
+ }
+
+ /**
+ * Create SQLClientInfoException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLClientInfoException ex = new SQLClientInfoException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties() == null);
+ }
+
+ /**
+ * Create SQLClientInfoException with null Throwable
+ */
+ @Test
+ public void test2() {
+
+ SQLClientInfoException ex = new SQLClientInfoException(map, null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message
+ */
+ @Test
+ public void test3() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, map);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with null Throwable
+ */
+ @Test
+ public void test4() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, map, null);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, and SQLState
+ */
+ @Test
+ public void test5() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ map);
+
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, and SQLState
+ */
+ @Test
+ public void test6() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ map, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, SQLState, errorCode, and
+ * Throwable
+ */
+ @Test
+ public void test7() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ errorCode, map);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Create SQLClientInfoException with message, SQLState, and error code
+ */
+ @Test
+ public void test8() {
+ SQLClientInfoException ex = new SQLClientInfoException(reason, state,
+ errorCode, map, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode
+ && ex.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Serialize a SQLClientInfoException and make sure you can read it back
+ * properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLClientInfoException e = new SQLClientInfoException(reason, state,
+ errorCode, map, t);
+ SQLClientInfoException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode
+ && ex1.getFailedProperties().equals(map));
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
+ map, t1);
+ SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
+ map);
+ SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
+ map, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLClientInfoException ex = new SQLClientInfoException("Exception 1",
+ map, t1);
+ SQLClientInfoException ex1 = new SQLClientInfoException("Exception 2",
+ map);
+ SQLClientInfoException ex2 = new SQLClientInfoException("Exception 3",
+ map, t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLDataExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLDataException;
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLDataExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLDataException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLDataException e = new SQLDataException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLDataException ex = new SQLDataException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message
+ */
+ @Test
+ public void test2() {
+ SQLDataException ex = new SQLDataException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLDataException ex = new SQLDataException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLDataException ex = new SQLDataException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLDataException ex = new SQLDataException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLDataException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLDataException ex = new SQLDataException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLDataException ex = new SQLDataException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLDataException ex = new SQLDataException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLDataException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLDataException ex = new SQLDataException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLDataException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLDataException e = new SQLDataException(reason, state, errorCode, t);
+ SQLDataException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLDataException ex = new SQLDataException("Exception 1", t1);
+ SQLDataException ex1 = new SQLDataException("Exception 2");
+ SQLDataException ex2 = new SQLDataException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLDataException ex = new SQLDataException("Exception 1", t1);
+ SQLDataException ex1 = new SQLDataException("Exception 2");
+ SQLDataException ex2 = new SQLDataException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLDataException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLDataException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLException e = new SQLException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLException ex = new SQLException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message
+ */
+ @Test
+ public void test2() {
+ SQLException ex = new SQLException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLException ex = new SQLException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLException ex = new SQLException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLException ex = new SQLException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLException ex = new SQLException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLException ex = new SQLException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLException ex = new SQLException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLException ex = new SQLException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLException e = new SQLException(reason, state, errorCode, t);
+ SQLException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLException ex = new SQLException("Exception 1", t1);
+ SQLException ex1 = new SQLException("Exception 2");
+ SQLException ex2 = new SQLException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLException ex = new SQLException("Exception 1", t1);
+ SQLException ex1 = new SQLException("Exception 2");
+ SQLException ex2 = new SQLException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ while (ex != null) {
+ assertTrue(msgs[num++].equals(ex.getMessage()));
+ Throwable c = ex.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ ex = ex.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLFeatureNotSupportedExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLFeatureNotSupportedException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLFeatureNotSupportedException e =
+ new SQLFeatureNotSupportedException(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message
+ */
+ @Test
+ public void test2() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLFeatureNotSupportedException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLFeatureNotSupportedException e =
+ new SQLFeatureNotSupportedException(reason, state, errorCode, t);
+ SQLFeatureNotSupportedException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException("Exception 1", t1);
+ SQLFeatureNotSupportedException ex1 =
+ new SQLFeatureNotSupportedException("Exception 2");
+ SQLFeatureNotSupportedException ex2 =
+ new SQLFeatureNotSupportedException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLFeatureNotSupportedException ex =
+ new SQLFeatureNotSupportedException("Exception 1", t1);
+ SQLFeatureNotSupportedException ex1 =
+ new SQLFeatureNotSupportedException("Exception 2");
+ SQLFeatureNotSupportedException ex2 =
+ new SQLFeatureNotSupportedException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLFeatureNotSupportedException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLFeatureNotSupportedException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLIntegrityConstraintViolationException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLIntegrityConstraintViolationExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLIntegrityConstraintViolationException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLIntegrityConstraintViolationException e =
+ new SQLIntegrityConstraintViolationException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message
+ */
+ @Test
+ public void test2() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLIntegrityConstraintViolationException and make sure
+ * you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLIntegrityConstraintViolationException e =
+ new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
+ SQLIntegrityConstraintViolationException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException("Exception 1", t1);
+ SQLIntegrityConstraintViolationException ex1 =
+ new SQLIntegrityConstraintViolationException("Exception 2");
+ SQLIntegrityConstraintViolationException ex2 =
+ new SQLIntegrityConstraintViolationException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLIntegrityConstraintViolationException ex =
+ new SQLIntegrityConstraintViolationException("Exception 1", t1);
+ SQLIntegrityConstraintViolationException ex1 =
+ new SQLIntegrityConstraintViolationException("Exception 2");
+ SQLIntegrityConstraintViolationException ex2 =
+ new SQLIntegrityConstraintViolationException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLIntegrityConstraintViolationException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLIntegrityConstraintViolationException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLInvalidAuthorizationSpecException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLInvalidAuthorizationSpecExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException and setting all objects to
+ * null
+ */
+ @Test
+ public void test() {
+ SQLInvalidAuthorizationSpecException e
+ = new SQLInvalidAuthorizationSpecException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message
+ */
+ @Test
+ public void test2() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
+ * error code
+ */
+ @Test
+ public void test4() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState,
+ * errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, SQLState, and
+ * Throwable
+ */
+ @Test
+ public void test6() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLInvalidAuthorizationSpecException and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLInvalidAuthorizationSpecException e
+ = new SQLInvalidAuthorizationSpecException(reason, state, errorCode, t);
+ SQLInvalidAuthorizationSpecException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
+ SQLInvalidAuthorizationSpecException ex1
+ = new SQLInvalidAuthorizationSpecException("Exception 2");
+ SQLInvalidAuthorizationSpecException ex2
+ = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLInvalidAuthorizationSpecException ex
+ = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
+ SQLInvalidAuthorizationSpecException ex1
+ = new SQLInvalidAuthorizationSpecException("Exception 2");
+ SQLInvalidAuthorizationSpecException ex2
+ = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLInvalidAuthorizationSpecException and validate it is an
+ * instance of SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLInvalidAuthorizationSpecException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientConnectionException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLNonTransientConnectionExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLNonTransientConnectionException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLNonTransientConnectionException e =
+ new SQLNonTransientConnectionException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message
+ */
+ @Test
+ public void test2() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLNonTransientConnectionException and make sure you can
+ * read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLNonTransientConnectionException e =
+ new SQLNonTransientConnectionException(reason, state, errorCode, t);
+ SQLNonTransientConnectionException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException("Exception 1", t1);
+ SQLNonTransientConnectionException ex1 =
+ new SQLNonTransientConnectionException("Exception 2");
+ SQLNonTransientConnectionException ex2 =
+ new SQLNonTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLNonTransientConnectionException ex =
+ new SQLNonTransientConnectionException("Exception 1", t1);
+ SQLNonTransientConnectionException ex1 =
+ new SQLNonTransientConnectionException("Exception 2");
+ SQLNonTransientConnectionException ex2 =
+ new SQLNonTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLNonTransientConnectionException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLNonTransientConnectionException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLNonTransientExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLNonTransientException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLNonTransientException e = new SQLNonTransientException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLNonTransientException ex = new SQLNonTransientException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message
+ */
+ @Test
+ public void test2() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {;
+ SQLNonTransientException ex =
+ new SQLNonTransientException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLNonTransientException ex =
+ new SQLNonTransientException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLNonTransientException ex = new SQLNonTransientException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLNonTransientException ex = new SQLNonTransientException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLNonTransientException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLNonTransientException ex = new SQLNonTransientException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLNonTransientException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLNonTransientException e =
+ new SQLNonTransientException(reason, state, errorCode, t);
+ SQLNonTransientException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
+ SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
+ SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
+ SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
+ SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLRecoverableException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLRecoverableExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLRecoverableException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLRecoverableException e = new SQLRecoverableException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLRecoverableException ex = new SQLRecoverableException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message
+ */
+ @Test
+ public void test2() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLRecoverableException ex =
+ new SQLRecoverableException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLRecoverableException ex =
+ new SQLRecoverableException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLRecoverableException ex = new SQLRecoverableException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLRecoverableException ex = new SQLRecoverableException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLRecoverableException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLRecoverableException ex = new SQLRecoverableException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLRecoverableException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLRecoverableException e =
+ new SQLRecoverableException(reason, state, errorCode, t);
+ SQLRecoverableException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
+ SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
+ SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLRecoverableException ex = new SQLRecoverableException("Exception 1", t1);
+ SQLRecoverableException ex1 = new SQLRecoverableException("Exception 2");
+ SQLRecoverableException ex2 = new SQLRecoverableException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLNonTransientException;
+import java.sql.SQLSyntaxErrorException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLSyntaxErrorExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLSyntaxErrorException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLSyntaxErrorException e = new SQLSyntaxErrorException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message
+ */
+ @Test
+ public void test2() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLSyntaxErrorException ex =
+ new SQLSyntaxErrorException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLSyntaxErrorException ex =
+ new SQLSyntaxErrorException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLSyntaxErrorException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLSyntaxErrorException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+
+ SQLSyntaxErrorException e =
+ new SQLSyntaxErrorException(reason, state, errorCode, t);
+ SQLSyntaxErrorException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
+ SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
+ SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
+ SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
+ SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLSyntaxErrorException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLSyntaxErrorException();
+ assertTrue(ex instanceof SQLNonTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTimeoutException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTimeoutExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTimeoutException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTimeoutException e = new SQLTimeoutException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTimeoutException ex = new SQLTimeoutException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message
+ */
+ @Test
+ public void test2() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTimeoutException ex = new SQLTimeoutException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTimeoutException ex = new SQLTimeoutException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTimeoutException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTimeoutException ex = new SQLTimeoutException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTimeoutException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTimeoutException e =
+ new SQLTimeoutException(reason, state, errorCode, t);
+ SQLTimeoutException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
+ SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
+ SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTimeoutException ex = new SQLTimeoutException("Exception 1", t1);
+ SQLTimeoutException ex1 = new SQLTimeoutException("Exception 2");
+ SQLTimeoutException ex2 = new SQLTimeoutException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTimeoutException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTimeoutException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransactionRollbackException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransactionRollbackExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransactionRollbackException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransactionRollbackException e =
+ new SQLTransactionRollbackException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransactionRollbackException ex = new SQLTransactionRollbackException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransactionRollbackException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransactionRollbackException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransactionRollbackException e =
+ new SQLTransactionRollbackException(reason, state, errorCode, t);
+ SQLTransactionRollbackException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException("Exception 1", t1);
+ SQLTransactionRollbackException ex1 =
+ new SQLTransactionRollbackException("Exception 2");
+ SQLTransactionRollbackException ex2 =
+ new SQLTransactionRollbackException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransactionRollbackException ex =
+ new SQLTransactionRollbackException("Exception 1", t1);
+ SQLTransactionRollbackException ex1 =
+ new SQLTransactionRollbackException("Exception 2");
+ SQLTransactionRollbackException ex2 =
+ new SQLTransactionRollbackException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTransactionRollbackException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTransactionRollbackException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransientConnectionException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransientConnectionExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransientConnectionException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransientConnectionException e =
+ new SQLTransientConnectionException( null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransientConnectionException ex = new SQLTransientConnectionException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {;
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientConnectionException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransientConnectionException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransientConnectionException e =
+ new SQLTransientConnectionException(reason, state, errorCode, t);
+ SQLTransientConnectionException ex1 =
+ createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException("Exception 1", t1);
+ SQLTransientConnectionException ex1 =
+ new SQLTransientConnectionException("Exception 2");
+ SQLTransientConnectionException ex2 =
+ new SQLTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransientConnectionException ex =
+ new SQLTransientConnectionException("Exception 1", t1);
+ SQLTransientConnectionException ex1 =
+ new SQLTransientConnectionException("Exception 2");
+ SQLTransientConnectionException ex2 =
+ new SQLTransientConnectionException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Create SQLTransientConnectionException and validate it is an instance of
+ * SQLNonTransientException
+ */
+ @Test
+ public void test13() {
+ Exception ex = new SQLTransientConnectionException();
+ assertTrue(ex instanceof SQLTransientException);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLTransientExceptionTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLTransientExceptionTests extends BaseTest {
+
+ /**
+ * Create SQLTransientException and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLTransientException e = new SQLTransientException(null,
+ null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLTransientException ex = new SQLTransientException();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message
+ */
+ @Test
+ public void test2() {
+ SQLTransientException ex = new SQLTransientException(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, and SQLState
+ */
+ @Test
+ public void test3() {
+ SQLTransientException ex = new SQLTransientException(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLTransientException ex = new SQLTransientException(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLTransientException ex =
+ new SQLTransientException(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLTransientException with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLTransientException ex = new SQLTransientException(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLTransientException ex = new SQLTransientException(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLTransientException ex = new SQLTransientException((Throwable)null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLTransientException with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLTransientException ex = new SQLTransientException(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLTransientException and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLTransientException e =
+ new SQLTransientException(reason, state, errorCode, t);
+ SQLTransientException ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLTransientException ex = new SQLTransientException("Exception 1", t1);
+ SQLTransientException ex1 = new SQLTransientException("Exception 2");
+ SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct
+ * using traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLTransientException ex = new SQLTransientException("Exception 1", t1);
+ SQLTransientException ex1 = new SQLTransientException("Exception 2");
+ SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/SQLWarningTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class SQLWarningTests extends BaseTest {
+
+ private final String[] warnings = {"Warning 1", "cause 1", "Warning 2",
+ "Warning 3", "cause 2"};
+
+ /**
+ * Create SQLWarning and setting all objects to null
+ */
+ @Test
+ public void test() {
+ SQLWarning e = new SQLWarning(null, null, errorCode, null);
+ assertTrue(e.getMessage() == null && e.getSQLState() == null
+ && e.getCause() == null && e.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with no-arg constructor
+ */
+ @Test
+ public void test1() {
+ SQLWarning ex = new SQLWarning();
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message
+ */
+ @Test
+ public void test2() {
+ SQLWarning ex = new SQLWarning(reason);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, and SQLState
+ */
+ @Test
+ public void test3() {
+
+ SQLWarning ex = new SQLWarning(reason, state);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, and error code
+ */
+ @Test
+ public void test4() {
+ SQLWarning ex = new SQLWarning(reason, state, errorCode);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && ex.getCause() == null
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, errorCode, and Throwable
+ */
+ @Test
+ public void test5() {
+ SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Create SQLWarning with message, SQLState, and Throwable
+ */
+ @Test
+ public void test6() {
+ SQLWarning ex = new SQLWarning(reason, state, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState().equals(state)
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with message, and Throwable
+ */
+ @Test
+ public void test7() {
+ SQLWarning ex = new SQLWarning(reason, t);
+ assertTrue(ex.getMessage().equals(reason)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with null Throwable
+ */
+ @Test
+ public void test8() {
+ SQLWarning ex = new SQLWarning((Throwable) null);
+ assertTrue(ex.getMessage() == null
+ && ex.getSQLState() == null
+ && ex.getCause() == null
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Create SQLWarning with Throwable
+ */
+ @Test
+ public void test9() {
+ SQLWarning ex = new SQLWarning(t);
+ assertTrue(ex.getMessage().equals(cause)
+ && ex.getSQLState() == null
+ && cause.equals(ex.getCause().toString())
+ && ex.getErrorCode() == 0);
+ }
+
+ /**
+ * Serialize a SQLWarning and make sure you can read it back properly
+ */
+ @Test
+ public void test10() throws Exception {
+ SQLWarning e = new SQLWarning(reason, state, errorCode, t);
+ SQLWarning ex1 = createSerializedException(e);
+ assertTrue(reason.equals(ex1.getMessage())
+ && ex1.getSQLState().equals(state)
+ && cause.equals(ex1.getCause().toString())
+ && ex1.getErrorCode() == errorCode);
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * for-each loop
+ */
+ @Test
+ public void test11() {
+ SQLWarning ex = new SQLWarning("Exception 1", t1);
+ SQLWarning ex1 = new SQLWarning("Exception 2");
+ SQLWarning ex2 = new SQLWarning("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(msgs[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned Exceptions is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test12() {
+ SQLWarning ex = new SQLWarning("Exception 1", t1);
+ SQLWarning ex1 = new SQLWarning("Exception 2");
+ SQLWarning ex2 = new SQLWarning("Exception 3", t2);
+ ex.setNextException(ex1);
+ ex.setNextException(ex2);
+ int num = 0;
+ SQLException sqe = ex;
+ while (sqe != null) {
+ assertTrue(msgs[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextException();
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned SQLWarning is correct using
+ * for-each loop
+ */
+ @Test
+ public void test13() {
+ SQLWarning ex = new SQLWarning("Warning 1", t1);
+ SQLWarning ex1 = new SQLWarning("Warning 2");
+ SQLWarning ex2 = new SQLWarning("Warning 3", t2);
+ ex.setNextWarning(ex1);
+ ex.setNextWarning(ex2);
+ int num = 0;
+ for (Throwable e : ex) {
+ assertTrue(warnings[num++].equals(e.getMessage()));
+ }
+ }
+
+ /**
+ * Validate that the ordering of the returned SQLWarning is correct using
+ * traditional while loop
+ */
+ @Test
+ public void test14() {
+ SQLWarning ex = new SQLWarning("Warning 1", t1);
+ SQLWarning ex1 = new SQLWarning("Warning 2");
+ SQLWarning ex2 = new SQLWarning("Warning 3", t2);
+ ex.setNextWarning(ex1);
+ ex.setNextWarning(ex2);
+ int num = 0;
+ SQLWarning sqe = ex;
+ while (sqe != null) {
+ assertTrue(warnings[num++].equals(sqe.getMessage()));
+ Throwable c = sqe.getCause();
+ while (c != null) {
+ assertTrue(msgs[num++].equals(c.getMessage()));
+ c = c.getCause();
+ }
+ sqe = sqe.getNextWarning();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/TimeTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Time;
+import java.time.LocalTime;
+import static org.testng.Assert.*;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class TimeTests extends BaseTest {
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getYear
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test01() {
+ Time t = Time.valueOf("08:30:59");
+ t.getYear();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getMonth
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test02() {
+ Time t = Time.valueOf("08:30:59");
+ t.getMonth();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getDay
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test03() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDay();
+ }
+
+ /**
+ * Validate an IllegalArgumentException is thrown for calling getDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test04() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDate();
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setYear
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test05() {
+ Time t = Time.valueOf("08:30:59");
+ t.setYear(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setMonth
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test06() {
+ Time t = Time.valueOf("08:30:59");
+ t.setMonth(8);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling setDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test07() {
+ Time t = Time.valueOf("08:30:59");
+ t.setDate(30);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for calling getDate
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test08() {
+ Time t = Time.valueOf("08:30:59");
+ t.getDate();
+ }
+
+ /*
+ * Validate that a Time made from a toLocalTime() LocalTime are equal
+ */
+ @Test
+ public void test09() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = Time.valueOf(t.toLocalTime());
+ assertTrue(t.equals(t2), "Error t != t2");
+ }
+
+ /*
+ * Validate that a Time LocalTime value, made from a LocalTime are equal
+ */
+ @Test
+ public void test10() {
+ LocalTime lt = LocalTime.of(8, 30, 59);
+ Time t = Time.valueOf(lt);
+ System.out.println("lt=" + lt + ",t=" + t.toLocalTime());
+ assertTrue(lt.equals(t.toLocalTime()),
+ "Error LocalTime values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDate is passed to valueOf
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test11() throws Exception {
+ LocalTime ld = null;
+ Time.valueOf(ld);
+ }
+
+ /*
+ * Validate an UnsupportedOperationException occurs when toInstant() is
+ * called
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void test12() throws Exception {
+ Time t = new Time(System.currentTimeMillis());
+ t.toInstant();
+ }
+
+ /*
+ * Validate that two Time objects are equal when one is created from the
+ * toString() of the other and that the correct value is returned from
+ * toString()
+ */
+ @Test(dataProvider = "validTimeValues")
+ public void test13(String time, String expected) {
+ Time t1 = Time.valueOf(time);
+ Time t2 = Time.valueOf(t1.toString());
+ assertTrue(t1.equals(t2) && t2.equals(t1)
+ && t1.toString().equals(expected), "Error t1 != t2");
+ }
+
+ /*
+ * Validate that two Time values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test14() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(8, 30, 59);
+ assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
+ }
+
+ /*
+ * Validate that two Time values one created using valueOf and another via a
+ * constructor are equal
+ */
+ @Test
+ public void test15() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Time string
+ */
+ @Test(dataProvider = "invalidTimeValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test16(String time) throws Exception {
+ Time.valueOf(time);
+ }
+
+ /*
+ * Validate that Time.after() returns false when same date is compared
+ */
+ @Test
+ public void test17() {
+ Time t = Time.valueOf("08:30:59");
+ assertFalse(t.after(t), "Error t.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.after() returns true when later date is compared to
+ * earlier date
+ */
+ @Test
+ public void test18() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(System.currentTimeMillis());
+ assertTrue(t2.after(t), "Error t2.after(t) = false");
+ }
+
+ /*
+ * Validate that Time.after() returns false when earlier date is compared to
+ * itself
+ */
+ @Test
+ public void test19() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertFalse(t.after(t2), "Error t.after(t2) = true");
+ assertFalse(t2.after(t), "Error t2.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.before() returns false when same date is compared
+ */
+ @Test
+ public void test20() {
+ Time t = Time.valueOf("08:30:59");
+ assertFalse(t.before(t), "Error t.before(t) = true");
+ }
+
+ /*
+ * Validate that Time.before() returns true when earlier date is compared to
+ * later date
+ */
+ @Test
+ public void test21() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(System.currentTimeMillis());
+ assertTrue(t.before(t2), "Error t.before(t2) = false");
+ }
+
+ /*
+ * Validate that Time.before() returns false when earlier date is compared
+ * to itself
+ */
+ @Test
+ public void test22() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertFalse(t.before(t2), "Error t.after(t2) = true");
+ assertFalse(t2.before(t), "Error t2.after(t) = true");
+ }
+
+ /*
+ * Validate that Time.compareTo returns 0 when both Date objects are the
+ * same
+ */
+ @Test
+ public void test23() {
+ Time t = Time.valueOf("08:30:59");
+ assertTrue(t.compareTo(t) == 0, "Error t.compareTo(t) !=0");
+ }
+
+ /*
+ * Validate thatTime.compareTo returns 0 when both Time objects are the same
+ */
+ @Test
+ public void test24() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime());
+ assertTrue(t.compareTo(t2) == 0, "Error t.compareTo(t2) !=0");
+ }
+
+ /*
+ * Validate that Time.compareTo returns 1 when comparing a later Time to an
+ * earlier Time
+ */
+ @Test
+ public void test25() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime() + 1);
+ assertTrue(t2.compareTo(t) == 1, "Error t2.compareTo(t) !=1");
+ }
+
+ /*
+ * Validate thatTime.compareTo returns 1 when comparing a later Time to an
+ * earlier Time
+ */
+ @Test
+ public void test26() {
+ Time t = Time.valueOf("08:30:59");
+ Time t2 = new Time(t.getTime() + 1);
+ assertTrue(t.compareTo(t2) == -1, "Error t.compareTo(t2) != -1");
+ }
+
+ /*
+ * DataProvider used to provide Time values which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidTimeValues")
+ private Object[][] invalidTimeValues() {
+ return new Object[][]{
+ {"2009-11-01 10:50:01"},
+ {"1961-08-30 10:50:01.1"},
+ {"1961-08-30"},
+ {"00:00:00."},
+ {"10:50:0.1"},
+ {":00:00"},
+ {"00::00"},
+ {"00:00:"},
+ {"::"},
+ {" : : "},
+ {"0a:00:00"},
+ {"00:bb:00"},
+ {"00:01:cc"},
+ {"08:10:Batman"},
+ {"08:10:10:10"},
+ {"08:10"},
+ {"a:b:c"},
+ {null},
+ {"8:"}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Time values which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method. It also contains the expected return value from
+ * toString()
+ */
+ @DataProvider(name = "validTimeValues")
+ private Object[][] validTimeValues() {
+ return new Object[][]{
+ {"10:50:01", "10:50:01"},
+ {"01:1:1", "01:01:01"},
+ {"01:01:1", "01:01:01"},
+ {"1:01:1", "01:01:01"},
+ {"2:02:02", "02:02:02"},
+ {"2:02:2", "02:02:02"},
+ {"10:50:1", "10:50:01"},
+ {"00:00:00", "00:00:00"},
+ {"08:30:59", "08:30:59"},
+ {"9:0:1", "09:00:01"}
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/test/sql/TimestampTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,777 @@
+/*
+ * Copyright (c) 2014, 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 test.sql;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Calendar;
+import java.util.TimeZone;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class TimestampTests extends BaseTest {
+
+ private static TimeZone defaultTimeZone = null;
+
+ /*
+ * Need to set and use a custom TimeZone which does not
+ * observe daylight savings time for this test.
+ */
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ defaultTimeZone = TimeZone.getDefault();
+ TimeZone tzone = TimeZone.getTimeZone("GMT+01");
+ assertFalse(tzone.observesDaylightTime());
+ TimeZone.setDefault(tzone);
+ }
+
+ /*
+ * Conservatively reset the default time zone after test.
+ */
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ TimeZone.setDefault(defaultTimeZone);
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid Timestamp
+ */
+ @Test(dataProvider = "invalidTimestampValues",
+ expectedExceptions = IllegalArgumentException.class)
+ public void test(String ts) throws Exception {
+ Timestamp.valueOf(ts);
+ }
+
+ /*
+ * Validate that two Timestamp are equal when the leading 0 in seconds is
+ * omitted
+ */
+ @Test
+ public void test01() throws Exception {
+ String testTS = "2009-01-01 10:50:00";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate two Timestamps created from the same string are equal
+ */
+ @Test
+ public void test02() throws Exception {
+ String testTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(testTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month and day
+ * equals same string without the leading 0s.
+ */
+ @Test
+ public void test03() throws Exception {
+ String testTS = "2009-1-1 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for day omitted
+ * are equal
+ */
+ @Test
+ public void test04() throws Exception {
+ String testTS = "2009-01-1 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month omitted
+ * and both with leading 0s for seconds omitted are equal
+ */
+ @Test
+ public void test05() throws Exception {
+ String testTS = "2009-1-01 10:50:0";
+ String ExpectedTS = "2009-01-01 10:50:0";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one with leading 0s for month omitted
+ */
+ @Test
+ public void test06() throws Exception {
+ String testTS = "2005-1-01 10:20:50.00";
+ String ExpectedTS = "2005-01-01 10:20:50.00";
+ Timestamp ts = Timestamp.valueOf(testTS);
+ Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
+ assertEquals(ts, ts2, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test07() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
+ Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 1000000);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test08() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.001");
+ Timestamp ts2 = new Timestamp(ts1.getTime());
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that two Timestamp values one created using valueOf and another
+ * via a constructor are equal
+ */
+ @Test
+ public void test09() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.0");
+ Timestamp ts2 = new Timestamp(96, 11, 13, 14, 15, 25, 0);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp cannot be equal to null
+ */
+ @Test
+ public void test10() {
+
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25.745634");
+ Timestamp ts2 = null;
+ assertFalse(ts1.equals(ts2), "Error ts1 == null");
+ }
+
+ /*
+ * Validate that a Timestamp is equal to another timestamp created with the
+ * using the same value but not equal to a Timestamp which is one day later
+ */
+ @Test
+ public void test11() {
+
+ Timestamp ts1 = Timestamp.valueOf("1996-12-10 12:26:19.12");
+ Timestamp ts2 = Timestamp.valueOf("1996-12-10 12:26:19.12");
+ Timestamp ts3 = Timestamp.valueOf("1996-12-11 12:24:19.12");
+ assertTrue(ts1.equals(ts2) && ts2.equals(ts1), "Error ts1 != ts2");
+ assertFalse(ts1.equals(ts3) && ts3.equals(ts1), "Error ts1 == ts3");
+
+ }
+
+ /*
+ * Validate that a Timestamp is equal to itself
+ */
+ @Test
+ public void test12() {
+ Timestamp ts1 = Timestamp.valueOf("1996-10-15 12:26:19.12");
+ assertTrue(ts1.equals(ts1), "Error ts1 != ts1");
+ }
+
+ /*
+ * Validate that two Timestamps are equal when one is created from the
+ * toString() of the other
+ */
+ @Test(dataProvider = "validTimestampValues")
+ public void test13(String ts, String expectedTS) {
+ Timestamp ts1 = Timestamp.valueOf(ts);
+ Timestamp ts2 = Timestamp.valueOf(ts1.toString());
+ assertTrue(ts1.equals(ts2) && ts2.equals(ts1)
+ && ts1.toString().equals(expectedTS), "Error ts1 != ts2");
+ }
+
+ // Before Tests
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test14() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1996-12-13 15:15:25.645634");
+ assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
+ }
+
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test15() {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 14:15:25");
+ Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25");
+ assertTrue(ts1.before(ts2), "Error ts1 not before ts2");
+ }
+
+ /*
+ * Validate that Timestamp ts1 is before Timestamp ts2
+ */
+ @Test
+ public void test16() {
+
+ Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1999-11-13 15:15:25.645634");
+ assertFalse(ts1.before(ts2), "Error ts1 before ts2");
+ }
+
+ /*
+ * Validate that a NullPointerException is thrown if a null is passed to
+ * the before method
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test17() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ ts1.before(null);
+ }
+
+ /*
+ * Validate a Timestamp cannot be before itself
+ */
+ @Test
+ public void test18() {
+ Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
+ assertFalse(ts1.before(ts1), "Error ts1 before ts1!");
+ }
+
+ /*
+ * Create 3 Timestamps and make sure the 1st is before the other two
+ * Timestamps which are each greater than the one before it
+ */
+ @Test
+ public void test19() {
+
+ Timestamp ts1 = new Timestamp(1234560000);
+ Timestamp ts2 = new Timestamp(1234567000);
+ Timestamp ts3 = new Timestamp(1234569000);
+ assertTrue(ts1.before(ts2) && ts2.before(ts3) && ts1.before(ts3));
+ }
+
+ /*
+ * Validate that Timestamp ts1 is not after Timestamp ts2
+ */
+ @Test
+ public void test20() {
+ Timestamp ts1 = Timestamp.valueOf("1999-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1999-12-13 15:15:25.645634");
+ assertFalse(ts1.after(ts2), "Error ts1 is after ts2");
+
+ }
+
+ /*
+ * Validate that Timestamp ts1 is after Timestamp ts2
+ */
+ @Test
+ public void test21() {
+ Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
+ Timestamp ts2 = Timestamp.valueOf("1996-11-13 15:15:25.645634");
+ assertTrue(ts1.after(ts2), "Error ts1 not after ts2");
+ }
+
+ /*
+ * Validate that a NullPointerException is thrown if a null is passed to the
+ * after method
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test22() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ ts1.after(null);
+ }
+
+ /*
+ * Validate that a Timestamp cannot be after itself
+ */
+ @Test
+ public void test23() {
+ Timestamp ts1 = Timestamp.valueOf("1999-11-10 12:26:19.3456543");
+ assertFalse(ts1.after(ts1), "Error ts1 is after itself");
+ }
+
+ /*
+ * Validate that a Timestamp after() works correctly with Timestamp created
+ * using milliseconds
+ */
+ @Test
+ public void test24() {
+
+ Timestamp ts1 = new Timestamp(1234568000);
+ Timestamp ts2 = new Timestamp(1234565000);
+ Timestamp ts3 = new Timestamp(1234562000);
+ assertTrue(ts1.after(ts2) && ts2.after(ts3) && ts1.after(ts3));
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test25() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime());
+ assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate compareTo returns -1 for when the 1st Timestamp is earlier than
+ * the 2nd Timestamp
+ */
+ @Test
+ public void test26() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime() + 1000);
+ assertTrue(ts1.compareTo(ts2) == -1, "Error ts1 not before ts2");
+ assertTrue(ts2.compareTo(ts1) == 1, "Error ts1 is not before ts2");
+ }
+
+ /*
+ * Validate compareTo returns 1 for when the 1st Timestamp is later than the
+ * 2nd Timestamp
+ */
+ @Test
+ public void test27() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = new Timestamp(ts1.getTime() - 1000);
+ assertTrue(ts1.compareTo(ts2) == 1, "Error ts1 not after ts2");
+ assertTrue(ts2.compareTo(ts1) == -1, "Error ts1 not after ts2");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test28() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date ts2 = new java.util.Date(ts1.getTime());
+ assertTrue(ts1.compareTo(ts2) == 0, "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test29() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new java.util.Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 == d");
+ }
+
+ /*
+ * Validate compareTo returns 0 for Timestamps that are the same
+ */
+ @Test
+ public void test30() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new Timestamp(ts1.getTime());
+ assertTrue(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Date object is passed to equals
+ */
+ @Test
+ public void test31() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Date d = new Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Date object is passed to equals
+ */
+ @Test
+ public void test32() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ java.util.Date d = new Date(ts1.getTime());
+ assertFalse(ts1.equals(d), "Error ts1 != d");
+ }
+
+ /*
+ * Validate equals returns false when a Time object is passed to equals
+ */
+ @Test
+ public void test33() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Time t1 = new Time(ts1.getTime());
+ assertFalse(ts1.equals(t1), "Error ts1 == t1");
+ }
+
+ /*
+ * Validate equals returns false when a String object is passed to equals
+ */
+ @Test
+ public void test34() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ assertFalse(ts1.equals("1966-08-30 08:08:08"), "Error ts1 == a String");
+ }
+
+ /*
+ * Validate getTime() returns the same value from 2 timeStamps created by
+ */
+ @Test
+ public void test35() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = Timestamp.valueOf("1966-08-30 08:08:08");
+ assertTrue(ts2.getTime() == ts1.getTime(),
+ "ts1.getTime() != ts2.getTime()");
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate getTime() returns the same value from 2 timeStamps when
+ * setTime() is used to specify the same value for both Timestamps
+ */
+ @Test
+ public void test36() {
+ Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
+ Timestamp ts2 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts2.setTime(ts1.getTime());
+ assertTrue(ts2.getTime() == ts1.getTime(),
+ "ts1.getTime() != ts2.getTime()");
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid nanos value
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test38() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(-1);
+
+ }
+
+ /*
+ * Validate an IllegalArgumentException is thrown for an invalid nanos value
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test39() throws Exception {
+ int nanos = 999999999;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos + 1);
+ }
+
+ /*
+ * Validate you can set nanos to 999999999
+ */
+ @Test
+ public void test40() throws Exception {
+ int nanos = 999999999;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos);
+ assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
+ }
+
+ /*
+ * Validate you can set nanos to 0
+ */
+ @Test
+ public void test41() throws Exception {
+ int nanos = 0;
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ ts1.setNanos(nanos);
+ assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
+ }
+
+ /*
+ * Validate that a Timestamp made from a LocalDateTime are equal
+ */
+ @Test
+ public void test42() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ LocalDateTime ldt = ts1.toLocalDateTime();
+ Timestamp ts2 = Timestamp.valueOf(ldt);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp LocalDateTime value, made from a LocalDateTime
+ * are equal
+ */
+ @Test
+ public void test43() throws Exception {
+ LocalDateTime ldt = LocalDateTime.now();
+ Timestamp ts2 = Timestamp.valueOf(ldt);
+ assertTrue(ldt.equals(ts2.toLocalDateTime()),
+ "Error LocalDateTime values are not equal");
+ }
+
+ /*
+ * Validate an NPE occurs when a null LocalDateTime is passed to valueOF
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test44() throws Exception {
+ LocalDateTime ldt = null;
+ Timestamp.valueOf(ldt);
+ }
+
+ /*
+ * Validate that a Timestamp made from a Instant are equal
+ */
+ @Test
+ public void test45() throws Exception {
+ Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
+ Instant instant = ts1.toInstant();
+ Timestamp ts2 = Timestamp.from(instant);
+ assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
+ }
+
+ /*
+ * Validate that a Timestamp made from a Instant are equal
+ */
+ @Test
+ public void test46() throws Exception {
+ Instant instant = Instant.now();
+ Timestamp ts2 = Timestamp.from(instant);
+ assertTrue(instant.equals(ts2.toInstant()),
+ "Error Instant values do not match");
+ }
+
+ /*
+ * Validate an NPE occurs when a null instant is passed to from
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void test47() throws Exception {
+ Instant instant = null;
+ Timestamp.from(instant);
+ }
+
+ // Added SQE tests
+ /*
+ * Create a Timestamp and a 2nd Timestamp that is 1 month earlier and
+ * validate that it is not before or after the original Timestamp
+ */
+ @Test
+ public void test48() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertFalse(ts1.before(ts2) || ts2.after(ts1));
+ }
+
+ /*
+ * Create two Timestamps and validate that compareTo returns 1 to indicate
+ * the 1st Timestamp is greater than the 2nd Timestamp
+ */
+ @Test
+ public void test49() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertTrue(ts1.compareTo(ts2) == 1);
+ }
+
+ /*
+ * Create two Timestamps and validate that the 1st Timestamp is not equal to
+ * the 2nd Timestamp but equal to itself
+ */
+ @Test
+ public void test50() {
+ Calendar cal = Calendar.getInstance();
+ Timestamp ts1 = new Timestamp(System.currentTimeMillis());
+ cal.setTimeInMillis(ts1.getTime());
+ cal.add(Calendar.MONTH, -1);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ Timestamp ts2 = new Timestamp(cal.getTimeInMillis());
+ assertTrue(!ts1.equals(ts2) && ts1.equals(ts1));
+ }
+
+ /*
+ * Validate that two Timestamps are equal when one is created from the
+ * toString() of the other
+ */
+ @Test(dataProvider = "validateNanos")
+ public void test51(String ts, int nanos) {
+ Timestamp ts1 = Timestamp.valueOf(ts);
+ Timestamp ts2 = Timestamp.valueOf(ts1.toString());
+ assertTrue(ts1.getNanos() == nanos && ts1.equals(ts2),
+ "Error with Nanos");
+ }
+
+ @Test(dataProvider = "validTimestampLongValues")
+ public void test52(long value, String ts) {
+ Timestamp ts1 = new Timestamp(value);
+ assertEquals(ts1.toString(), ts, "ts1.toString() != ts");
+ }
+
+ /*
+ * DataProvider used to provide Timestamps which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "invalidTimestampValues")
+ private Object[][] invalidTimestampValues() {
+ return new Object[][]{
+ {"2009-11-01-01 10:50:01"},
+ {"aaaa-11-01-01 10:50"},
+ {"aaaa-11-01 10:50"},
+ {"1961--30 00:00:00"},
+ {"--30 00:00:00"},
+ {"-- 00:00:00"},
+ {"1961-1- 00:00:00"},
+ {"2009-11-01"},
+ {"10:50:01"},
+ {"1961-a-30 00:00:00"},
+ {"1961-01-bb 00:00:00"},
+ {"1961-08-30 00:00:00."},
+ {"1961-08-30 :00:00"},
+ {"1961-08-30 00::00"},
+ {"1961-08-30 00:00:"},
+ {"1961-08-30 ::"},
+ {"1961-08-30 0a:00:00"},
+ {"1961-08-30 00:bb:00"},
+ {"1961-08-30 00:01:cc"},
+ {"1961-08-30 00:00:00.01a"},
+ {"1961-08-30 00:00:00.a"},
+ {"1996-12-10 12:26:19.1234567890"},
+ {null}
+ };
+ }
+
+ /*
+ * DataProvider used to provide Timestamps which are valid and are used
+ * to validate that an IllegalArgumentException will not be thrown from the
+ * valueOf method and the corect value from toString() is returned
+ */
+ @DataProvider(name = "validTimestampValues")
+ private Object[][] validTimestampValues() {
+ return new Object[][]{
+ {"1961-08-30 00:00:00", "1961-08-30 00:00:00.0"},
+ {"1961-08-30 11:22:33", "1961-08-30 11:22:33.0"},
+ {"1961-8-30 00:00:00", "1961-08-30 00:00:00.0"},
+ {"1966-08-1 00:00:00", "1966-08-01 00:00:00.0"},
+ {"1996-12-10 12:26:19.1", "1996-12-10 12:26:19.1"},
+ {"1996-12-10 12:26:19.12", "1996-12-10 12:26:19.12"},
+ {"1996-12-10 12:26:19.123", "1996-12-10 12:26:19.123"},
+ {"1996-12-10 12:26:19.1234", "1996-12-10 12:26:19.1234"},
+ {"1996-12-10 12:26:19.12345", "1996-12-10 12:26:19.12345"},
+ {"1996-12-10 12:26:19.123456", "1996-12-10 12:26:19.123456"},
+ {"1996-12-10 12:26:19.1234567", "1996-12-10 12:26:19.1234567"},
+ {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
+ {"1996-12-10 12:26:19.123456789", "1996-12-10 12:26:19.123456789"},
+ {"1996-12-10 12:26:19.000000001", "1996-12-10 12:26:19.000000001"},
+ {"1996-12-10 12:26:19.000000012", "1996-12-10 12:26:19.000000012"},
+ {"1996-12-10 12:26:19.000000123", "1996-12-10 12:26:19.000000123"},
+ {"1996-12-10 12:26:19.000001234", "1996-12-10 12:26:19.000001234"},
+ {"1996-12-10 12:26:19.000012345", "1996-12-10 12:26:19.000012345"},
+ {"1996-12-10 12:26:19.000123456", "1996-12-10 12:26:19.000123456"},
+ {"1996-12-10 12:26:19.001234567", "1996-12-10 12:26:19.001234567"},
+ {"1996-12-10 12:26:19.12345678", "1996-12-10 12:26:19.12345678"},
+ {"1996-12-10 12:26:19.0", "1996-12-10 12:26:19.0"},
+ {"1996-12-10 12:26:19.01230", "1996-12-10 12:26:19.0123"}
+ };
+ }
+
+ @DataProvider(name = "validTimestampLongValues")
+ private Object[][] validTimestampLongValues() {
+ return new Object[][]{
+ {1L, "1970-01-01 01:00:00.001"},
+ {-3600*1000L - 1, "1969-12-31 23:59:59.999"},
+ {-(20000L*365*24*60*60*1000), "18018-08-28 01:00:00.0"},
+ {Timestamp.valueOf("1961-08-30 11:22:33").getTime(), "1961-08-30 11:22:33.0"},
+ {Timestamp.valueOf("1961-08-30 11:22:33.54321000").getTime(), "1961-08-30 11:22:33.543"}, // nanoprecision lost
+ {new Timestamp(114, 10, 10, 10, 10, 10, 100000000).getTime(), "2014-11-10 10:10:10.1"},
+ {new Timestamp(0, 10, 10, 10, 10, 10, 100000).getTime(), "1900-11-10 10:10:10.0"}, // nanoprecision lost
+ {new Date(114, 10, 10).getTime(), "2014-11-10 00:00:00.0"},
+ {new Date(0, 10, 10).getTime(), "1900-11-10 00:00:00.0"},
+ {LocalDateTime.of(1960, 10, 10, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli(), "1960-10-10 19:10:10.0"},
+
+ // millisecond timestamps wraps around at year 1, so Long.MIN_VALUE looks similar
+ // Long.MAX_VALUE, while actually representing 292278994 BCE
+ {Long.MIN_VALUE, "292278994-08-17 08:12:55.192"},
+ {Long.MAX_VALUE + 1, "292278994-08-17 08:12:55.192"},
+ {Long.MAX_VALUE, "292278994-08-17 08:12:55.807"},
+ {Long.MIN_VALUE - 1, "292278994-08-17 08:12:55.807"},
+
+ // wrap around point near 0001-01-01, test that we never get a negative year:
+ {-(1970L*365*24*60*60*1000), "0001-04-25 01:00:00.0"},
+ {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L), "0001-12-31 01:00:00.0"},
+ {-(1970L*365*24*60*60*1000 + 115*24*60*60*1000L - 23*60*60*1000L), "0001-01-01 00:00:00.0"},
+
+ {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli() - 2*24*60*60*1000L, "0001-01-01 19:03:08.0"}, // 1 BCE
+ {LocalDateTime.of(0, 1, 1, 10, 10, 10, 50000).atZone(ZoneId.of("America/Los_Angeles"))
+ .toInstant().toEpochMilli() - 3*24*60*60*1000L, "0002-12-31 19:03:08.0"} // 2 BCE
+ };
+ }
+
+ /*
+ * DataProvider used to provide Timestamp and Nanos values in order to
+ * validate that the correct Nanos value is generated from the specified
+ * Timestamp
+ */
+ @DataProvider(name = "validateNanos")
+ private Object[][] validateNanos() {
+ return new Object[][]{
+ {"1961-08-30 00:00:00", 0},
+ {"1996-12-10 12:26:19.1", 100000000},
+ {"1996-12-10 12:26:19.12", 120000000},
+ {"1996-12-10 12:26:19.123", 123000000},
+ {"1996-12-10 12:26:19.1234", 123400000},
+ {"1996-12-10 12:26:19.12345", 123450000},
+ {"1996-12-10 12:26:19.123456", 123456000},
+ {"1996-12-10 12:26:19.1234567", 123456700},
+ {"1996-12-10 12:26:19.12345678", 123456780},
+ {"1996-12-10 12:26:19.123456789", 123456789},
+ {"1996-12-10 12:26:19.000000001", 1},
+ {"1996-12-10 12:26:19.000000012", 12},
+ {"1996-12-10 12:26:19.000000123", 123},
+ {"1996-12-10 12:26:19.000001234", 1234},
+ {"1996-12-10 12:26:19.000012345", 12345},
+ {"1996-12-10 12:26:19.000123456", 123456},
+ {"1996-12-10 12:26:19.001234567", 1234567},
+ {"1996-12-10 12:26:19.012345678", 12345678},
+ {"1996-12-10 12:26:19.0", 0},
+ {"1996-12-10 12:26:19.01230", 12300000}
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/BaseTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.security.Policy;
+import java.sql.JDBCType;
+import java.sql.SQLException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+
+public class BaseTest {
+
+ protected final String reason = "reason";
+ protected final String state = "SQLState";
+ protected final String cause = "java.lang.Throwable: cause";
+ protected final Throwable t = new Throwable("cause");
+ protected final Throwable t1 = new Throwable("cause 1");
+ protected final Throwable t2 = new Throwable("cause 2");
+ protected final int errorCode = 21;
+ protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
+ "Exception 3", "cause 2"};
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ }
+
+ @AfterMethod
+ public void tearDownMethod() throws Exception {
+ }
+
+ /*
+ * Take some form of SQLException, serialize and deserialize it
+ */
+ @SuppressWarnings("unchecked")
+ protected <T extends SQLException> T
+ createSerializedException(T ex)
+ throws IOException, ClassNotFoundException {
+ return (T) serializeDeserializeObject(ex);
+ }
+
+ /*
+ * Utility method to serialize and deserialize an object
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> T serializeDeserializeObject(T o)
+ throws IOException, ClassNotFoundException {
+ T o1;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(o);
+ }
+ try (ObjectInputStream ois
+ = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
+ o1 = (T) ois.readObject();
+ }
+ return o1;
+ }
+
+ /*
+ * Utility Method used to set the current Policy
+ */
+ protected static void setPolicy(Policy p) {
+ Policy.setPolicy(p);
+ }
+
+ /*
+ * DataProvider used to specify the value to set and check for
+ * methods using boolean values
+ */
+ @DataProvider(name = "trueFalse")
+ protected Object[][] trueFalse() {
+ return new Object[][]{
+ {true},
+ {false}
+ };
+ }
+
+ /*
+ * DataProvider used to specify the standard JDBC Types
+ */
+ @DataProvider(name = "jdbcTypes")
+ protected Object[][] jdbcTypes() {
+ Object[][] o = new Object[JDBCType.values().length][1];
+ int pos = 0;
+ for (JDBCType c : JDBCType.values()) {
+ o[pos++][0] = c.getVendorTypeNumber();
+ }
+ return o;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/DriverActionImpl.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.DriverAction;
+
+/**
+ * Simple implementation of DriverAction which calls back into the Driver when
+ * release is called.
+ */
+class DriverActionImpl implements DriverAction {
+
+ public DriverActionImpl(StubDriverDA d) {
+ driver = d;
+ }
+
+ private final StubDriverDA driver;
+
+ @Override
+ public void deregister() {
+ driver.release();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/SerializedBatchUpdateException.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+public class SerializedBatchUpdateException {
+ /**
+ * Serialized BatchUpdateException from JDBC 4.0 with the following values
+ * reason = "This was the error msg"
+ * SQLState = "user defined sqlState"
+ * vendor Code = 99999
+ * Update Counts = {1, 2, 21}
+ * cause = = "java.lang.Throwable: throw 1"
+ */
+ public static byte[] DATA = {
+ (byte) 0xac, (byte) 0xed, (byte) 0x0, (byte) 0x5, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1d, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
+ (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x52, (byte) 0xf4, (byte) 0x73, (byte) 0xc0, (byte) 0xc1, (byte) 0x8b, (byte) 0xe, (byte) 0x5d, (byte) 0x3, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x0, (byte) 0x10, (byte) 0x6c, (byte) 0x6f, (byte) 0x6e, (byte) 0x67, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75,
+ (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x5b, (byte) 0x0, (byte) 0xc, (byte) 0x75, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x15,
+ (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x1d, (byte) 0xa1, (byte) 0xe9, (byte) 0x30, (byte) 0xdb, (byte) 0x3e, (byte) 0x75, (byte) 0xdc, (byte) 0x2, (byte) 0x0, (byte) 0x3,
+ (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x76, (byte) 0x65, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x72, (byte) 0x43, (byte) 0x6f, (byte) 0x64, (byte) 0x65, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x74, (byte) 0x0, (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) 0x4c, (byte) 0x0, (byte) 0x4, (byte) 0x6e, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x74, (byte) 0x0, (byte) 0x17, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x73, (byte) 0x71, (byte) 0x6c,
+ (byte) 0x2f, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x3b, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
+ (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0xd0, (byte) 0xfd, (byte) 0x1f, (byte) 0x3e, (byte) 0x1a, (byte) 0x3b, (byte) 0x1c, (byte) 0xc4, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x54, (byte) 0x68,
+ (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0xd5, (byte) 0xc6, (byte) 0x35, (byte) 0x27, (byte) 0x39, (byte) 0x77, (byte) 0xb8, (byte) 0xcb, (byte) 0x3, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x5, (byte) 0x63, (byte) 0x61, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x4c, (byte) 0x6a, (byte) 0x61,
+ (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x54, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0xd, (byte) 0x64, (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6c, (byte) 0x4d, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x61,
+ (byte) 0x67, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x5b, (byte) 0x0, (byte) 0xa, (byte) 0x73, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (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) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x75, (byte) 0x70, (byte) 0x70, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,
+ (byte) 0x65, (byte) 0x64, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x10, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f, (byte) 0x4c, (byte) 0x69, (byte) 0x73, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
+ (byte) 0x70, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x7, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xc, (byte) 0x74, (byte) 0x0, (byte) 0x7, (byte) 0x74, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x20, (byte) 0x31, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
+ (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x2, (byte) 0x46, (byte) 0x2a, (byte) 0x3c, (byte) 0x3c, (byte) 0xfd, (byte) 0x22, (byte) 0x39,
+ (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1b, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63,
+ (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x9, (byte) 0xc5, (byte) 0x9a, (byte) 0x26, (byte) 0x36, (byte) 0xdd, (byte) 0x85, (byte) 0x2, (byte) 0x0, (byte) 0x4, (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x6c, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x4e, (byte) 0x75, (byte) 0x6d, (byte) 0x62, (byte) 0x65, (byte) 0x72,
+ (byte) 0x4c, (byte) 0x0, (byte) 0xe, (byte) 0x64, (byte) 0x65, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x43, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
+ (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0xa, (byte) 0x6d, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6f, (byte) 0x64, (byte) 0x4e, (byte) 0x61, (byte) 0x6d, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x23, (byte) 0x74, (byte) 0x0,
+ (byte) 0x17, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x0, (byte) 0x1c, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74,
+ (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x2e, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x74, (byte) 0x0, (byte) 0x9, (byte) 0x77, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x65, (byte) 0x54,
+ (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x74, (byte) 0x0, (byte) 0x4, (byte) 0x6d, (byte) 0x61, (byte) 0x69, (byte) 0x6e, (byte) 0x70, (byte) 0x78,
+ (byte) 0x74, (byte) 0x0, (byte) 0x16, (byte) 0x54, (byte) 0x68, (byte) 0x69, (byte) 0x73, (byte) 0x20, (byte) 0x77, (byte) 0x61, (byte) 0x73, (byte) 0x20, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x20, (byte) 0x65, (byte) 0x72, (byte) 0x72, (byte) 0x6f, (byte) 0x72, (byte) 0x20, (byte) 0x6d, (byte) 0x73, (byte) 0x67, (byte) 0x75, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xe, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x28, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e,
+ (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x16, (byte) 0x70, (byte) 0x78, (byte) 0x0, (byte) 0x1, (byte) 0x86, (byte) 0x9f, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x73,
+ (byte) 0x65, (byte) 0x72, (byte) 0x20, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x70, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x78, (byte) 0x20, (byte) 0x4, (byte) 0xb5, (byte) 0x12, (byte) 0xb1,
+ (byte) 0x75, (byte) 0x93, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x4d, (byte) 0xba, (byte) 0x60, (byte) 0x26, (byte) 0x76, (byte) 0xea, (byte) 0xb2, (byte) 0xa5, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x78
+ };
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubConnection.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public class StubConnection implements Connection {
+
+ @Override
+ public Statement createStatement() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String nativeSQL(String sql) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setAutoCommit(boolean autoCommit) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getAutoCommit() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void commit() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void rollback() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setCatalog(String catalog) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getCatalog() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTransactionIsolation(int level) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getTransactionIsolation() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setHoldability(int holdability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Savepoint setSavepoint() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Savepoint setSavepoint(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void rollback(Savepoint savepoint) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob createClob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob createBlob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob createNClob() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML createSQLXML() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isValid(int timeout) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClientInfo(String name, String value) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setClientInfo(Properties properties) throws SQLClientInfoException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getClientInfo(String name) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Properties getClientInfo() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setSchema(String schema) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getSchema() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void abort(Executor executor) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubDriver.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class StubDriver implements Driver {
+
+ public StubDriver() {
+ }
+
+ @Override
+ public Connection connect(String url, Properties info) throws SQLException {
+ if (acceptsURL(url)) {
+ return new StubConnection();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ return url.matches("^jdbc:tennis:.*");
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return 1;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ @Override
+ public boolean jdbcCompliant() {
+ return true;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/StubDriverDA.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.DriverAction;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Simple java.sql.Driver stub class that registers the driver via a static
+ * block with a DriverAction Implementation
+ * @author ljanders
+ */
+public class StubDriverDA extends StubDriver {
+
+ public static final String DriverActionCalled = "DriverActionCalled.txt";
+
+ static DriverAction da;
+
+ static {
+ try {
+ DriverManager.registerDriver(new StubDriverDA(), da);
+ } catch (SQLException ex) {
+ Logger.getLogger(StubDriverDA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public StubDriverDA() {
+ da = new DriverActionImpl(this);
+ }
+
+ @Override
+ public boolean acceptsURL(String url) throws SQLException {
+ return url.matches("^jdbc:luckydog:.*");
+ }
+
+ /**
+ * This method will write out a text file when called by the
+ * DriverActionImpl.release method when DriverManager.deregisterDriver
+ * is called. This is used by DriverManagerTests to validate that
+ * DriverAction.release was called
+ */
+ protected void release() {
+ File file = new File(DriverActionCalled);
+ try {
+ file.createNewFile();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/testng/util/TestPolicy.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.FilePermission;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.security.SecurityPermission;
+import java.sql.SQLPermission;
+import java.util.Enumeration;
+import java.util.PropertyPermission;
+import java.util.StringJoiner;
+
+/*
+ * Simple Policy class that supports the required Permissions to validate the
+ * JDBC concrete classes
+ */
+public class TestPolicy extends Policy {
+
+ final PermissionCollection permissions = new Permissions();
+
+ /**
+ * Constructor which sets the minimum permissions allowing testNG to work
+ * with a SecurityManager
+ */
+ public TestPolicy() {
+ setMinimalPermissions();
+ }
+
+ /*
+ * Constructor which determines which permissions are defined for this
+ * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
+ * setLog (SQLPemission("setLog"), deregisterDriver
+ * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
+ * and setSyncFactory(SQLPermission(setSyncFactory),
+ *
+ * @param policy Permissions to set
+ */
+ public TestPolicy(String policy) {
+
+ switch (policy) {
+ case "all":
+ permissions.add(new AllPermission());
+ break;
+ case "setLog":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("setLog"));
+ break;
+ case "deregisterDriver":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("deregisterDriver"));
+ break;
+ case "setSyncFactory":
+ setMinimalPermissions();
+ permissions.add(new SQLPermission("setSyncFactory"));
+ break;
+ default:
+ setMinimalPermissions();
+ }
+ }
+
+ /*
+ * Defines the minimal permissions required by testNG when running these
+ * tests
+ */
+ private void setMinimalPermissions() {
+ permissions.add(new SecurityPermission("getPolicy"));
+ permissions.add(new SecurityPermission("setPolicy"));
+ permissions.add(new RuntimePermission("getClassLoader"));
+ permissions.add(new RuntimePermission("setSecurityManager"));
+ permissions.add(new RuntimePermission("createSecurityManager"));
+ permissions.add(new PropertyPermission("testng.show.stack.frames",
+ "read"));
+ permissions.add(new PropertyPermission("line.separator", "read"));
+ permissions.add(new PropertyPermission("fileStringBuffer", "read"));
+ permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
+ permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
+ permissions.add(new FilePermission("<<ALL FILES>>",
+ "read, write, delete"));
+ }
+
+ /*
+ * Overloaded methods from the Policy class
+ */
+ @Override
+ public String toString() {
+ StringJoiner sj = new StringJoiner("\n", "policy: ", "");
+ Enumeration<Permission> perms = permissions.elements();
+ while (perms.hasMoreElements()) {
+ sj.add(perms.nextElement().toString());
+ }
+ return sj.toString();
+
+ }
+
+ @Override
+ public PermissionCollection getPermissions(ProtectionDomain domain) {
+ return permissions;
+ }
+
+ @Override
+ public PermissionCollection getPermissions(CodeSource codesource) {
+ return permissions;
+ }
+
+ @Override
+ public boolean implies(ProtectionDomain domain, Permission perm) {
+ return permissions.implies(perm);
+ }
+}
--- a/jdk/test/java/sql/util/BaseTest.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Policy;
-import java.sql.SQLException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-
-public class BaseTest {
-
- protected final String reason = "reason";
- protected final String state = "SQLState";
- protected final String cause = "java.lang.Throwable: cause";
- protected final Throwable t = new Throwable("cause");
- protected final Throwable t1 = new Throwable("cause 1");
- protected final Throwable t2 = new Throwable("cause 2");
- protected final int errorCode = 21;
- protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
- "Exception 3", "cause 2"};
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @BeforeMethod
- public void setUpMethod() throws Exception {
- }
-
- @AfterMethod
- public void tearDownMethod() throws Exception {
- }
-
- /*
- * Take some form of SQLException, serialize and deserialize it
- */
- @SuppressWarnings("unchecked")
- protected <T extends SQLException> T
- createSerializedException(T ex)
- throws IOException, ClassNotFoundException {
- return (T) serializeDeserializeObject(ex);
- }
-
- /*
- * Utility method to serialize and deserialize an object
- */
- @SuppressWarnings("unchecked")
- protected <T> T serializeDeserializeObject(T o)
- throws IOException, ClassNotFoundException {
- T o1;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
- oos.writeObject(o);
- }
- try (ObjectInputStream ois
- = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
- o1 = (T) ois.readObject();
- }
- return o1;
- }
-
- /*
- * Utility Method used to set the current Policy
- */
- protected static void setPolicy(Policy p) {
- Policy.setPolicy(p);
- }
-}
--- a/jdk/test/java/sql/util/DriverActionImpl.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.DriverAction;
-
-/**
- * Simple implementation of DriverAction which calls back into the Driver when
- * release is called.
- */
-class DriverActionImpl implements DriverAction {
-
- public DriverActionImpl(StubDriverDA d) {
- driver = d;
- }
-
- private final StubDriverDA driver;
-
- @Override
- public void deregister() {
- driver.release();
- }
-}
--- a/jdk/test/java/sql/util/SerializedBatchUpdateException.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-public class SerializedBatchUpdateException {
- /**
- * Serialized BatchUpdateException from JDBC 4.0 with the following values
- * reason = "This was the error msg"
- * SQLState = "user defined sqlState"
- * vendor Code = 99999
- * Update Counts = {1, 2, 21}
- * cause = = "java.lang.Throwable: throw 1"
- */
- public static byte[] DATA = {
- (byte) 0xac, (byte) 0xed, (byte) 0x0, (byte) 0x5, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1d, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
- (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x52, (byte) 0xf4, (byte) 0x73, (byte) 0xc0, (byte) 0xc1, (byte) 0x8b, (byte) 0xe, (byte) 0x5d, (byte) 0x3, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x0, (byte) 0x10, (byte) 0x6c, (byte) 0x6f, (byte) 0x6e, (byte) 0x67, (byte) 0x55, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75,
- (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x5b, (byte) 0x0, (byte) 0xc, (byte) 0x75, (byte) 0x70, (byte) 0x64, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x15,
- (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x2e, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x1d, (byte) 0xa1, (byte) 0xe9, (byte) 0x30, (byte) 0xdb, (byte) 0x3e, (byte) 0x75, (byte) 0xdc, (byte) 0x2, (byte) 0x0, (byte) 0x3,
- (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x76, (byte) 0x65, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x72, (byte) 0x43, (byte) 0x6f, (byte) 0x64, (byte) 0x65, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x74, (byte) 0x0, (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) 0x4c, (byte) 0x0, (byte) 0x4, (byte) 0x6e, (byte) 0x65, (byte) 0x78, (byte) 0x74, (byte) 0x74, (byte) 0x0, (byte) 0x17, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x73, (byte) 0x71, (byte) 0x6c,
- (byte) 0x2f, (byte) 0x53, (byte) 0x51, (byte) 0x4c, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x3b, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65,
- (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0xd0, (byte) 0xfd, (byte) 0x1f, (byte) 0x3e, (byte) 0x1a, (byte) 0x3b, (byte) 0x1c, (byte) 0xc4, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x72, (byte) 0x0, (byte) 0x13, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x54, (byte) 0x68,
- (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0xd5, (byte) 0xc6, (byte) 0x35, (byte) 0x27, (byte) 0x39, (byte) 0x77, (byte) 0xb8, (byte) 0xcb, (byte) 0x3, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x5, (byte) 0x63, (byte) 0x61, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x4c, (byte) 0x6a, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x54, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0xd, (byte) 0x64, (byte) 0x65, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6c, (byte) 0x4d, (byte) 0x65, (byte) 0x73, (byte) 0x73, (byte) 0x61,
- (byte) 0x67, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x5b, (byte) 0x0, (byte) 0xa, (byte) 0x73, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x74, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (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) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x4c, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x75, (byte) 0x70, (byte) 0x70, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x73,
- (byte) 0x65, (byte) 0x64, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x73, (byte) 0x74, (byte) 0x0, (byte) 0x10, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f, (byte) 0x4c, (byte) 0x69, (byte) 0x73, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
- (byte) 0x70, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x7, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xc, (byte) 0x74, (byte) 0x0, (byte) 0x7, (byte) 0x74, (byte) 0x68, (byte) 0x72, (byte) 0x6f, (byte) 0x77, (byte) 0x20, (byte) 0x31, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x1e, (byte) 0x5b, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63, (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x3b, (byte) 0x2, (byte) 0x46, (byte) 0x2a, (byte) 0x3c, (byte) 0x3c, (byte) 0xfd, (byte) 0x22, (byte) 0x39,
- (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x72, (byte) 0x0, (byte) 0x1b, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2e, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x63, (byte) 0x6b, (byte) 0x54, (byte) 0x72, (byte) 0x61, (byte) 0x63,
- (byte) 0x65, (byte) 0x45, (byte) 0x6c, (byte) 0x65, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x9, (byte) 0xc5, (byte) 0x9a, (byte) 0x26, (byte) 0x36, (byte) 0xdd, (byte) 0x85, (byte) 0x2, (byte) 0x0, (byte) 0x4, (byte) 0x49, (byte) 0x0, (byte) 0xa, (byte) 0x6c, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x4e, (byte) 0x75, (byte) 0x6d, (byte) 0x62, (byte) 0x65, (byte) 0x72,
- (byte) 0x4c, (byte) 0x0, (byte) 0xe, (byte) 0x64, (byte) 0x65, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x43, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0x8, (byte) 0x66, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x4e, (byte) 0x61, (byte) 0x6d,
- (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x4c, (byte) 0x0, (byte) 0xa, (byte) 0x6d, (byte) 0x65, (byte) 0x74, (byte) 0x68, (byte) 0x6f, (byte) 0x64, (byte) 0x4e, (byte) 0x61, (byte) 0x6d, (byte) 0x65, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x4, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x23, (byte) 0x74, (byte) 0x0,
- (byte) 0x17, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x0, (byte) 0x1c, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x61, (byte) 0x74,
- (byte) 0x65, (byte) 0x42, (byte) 0x61, (byte) 0x74, (byte) 0x63, (byte) 0x68, (byte) 0x45, (byte) 0x78, (byte) 0x63, (byte) 0x65, (byte) 0x70, (byte) 0x74, (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x53, (byte) 0x65, (byte) 0x72, (byte) 0x2e, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x74, (byte) 0x0, (byte) 0x9, (byte) 0x77, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x65, (byte) 0x54,
- (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x74, (byte) 0x0, (byte) 0x4, (byte) 0x6d, (byte) 0x61, (byte) 0x69, (byte) 0x6e, (byte) 0x70, (byte) 0x78,
- (byte) 0x74, (byte) 0x0, (byte) 0x16, (byte) 0x54, (byte) 0x68, (byte) 0x69, (byte) 0x73, (byte) 0x20, (byte) 0x77, (byte) 0x61, (byte) 0x73, (byte) 0x20, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x20, (byte) 0x65, (byte) 0x72, (byte) 0x72, (byte) 0x6f, (byte) 0x72, (byte) 0x20, (byte) 0x6d, (byte) 0x73, (byte) 0x67, (byte) 0x75, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0xe, (byte) 0x0,
- (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x28, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x14, (byte) 0x73, (byte) 0x71, (byte) 0x0, (byte) 0x7e,
- (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1a, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x12, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x13, (byte) 0x71, (byte) 0x0, (byte) 0x7e, (byte) 0x0, (byte) 0x16, (byte) 0x70, (byte) 0x78, (byte) 0x0, (byte) 0x1, (byte) 0x86, (byte) 0x9f, (byte) 0x74, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x73,
- (byte) 0x65, (byte) 0x72, (byte) 0x20, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x69, (byte) 0x6e, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x73, (byte) 0x71, (byte) 0x6c, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x70, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x4a, (byte) 0x78, (byte) 0x20, (byte) 0x4, (byte) 0xb5, (byte) 0x12, (byte) 0xb1,
- (byte) 0x75, (byte) 0x93, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
- (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x75, (byte) 0x72, (byte) 0x0, (byte) 0x2, (byte) 0x5b, (byte) 0x49, (byte) 0x4d, (byte) 0xba, (byte) 0x60, (byte) 0x26, (byte) 0x76, (byte) 0xea, (byte) 0xb2, (byte) 0xa5, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x78, (byte) 0x70, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0,
- (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x78
- };
-}
--- a/jdk/test/java/sql/util/StubBlob.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.sql.Blob;
-import java.sql.SQLException;
-
-
-public class StubBlob implements Blob {
- public long length() throws SQLException {
- return 0;
- }
- public byte[] getBytes(long pos, int length)
- throws SQLException {
- return null;
- }
- public InputStream getBinaryStream()
- throws SQLException {
- return null;
- }
- public long position(byte[] pattern, long start)
- throws SQLException {
- return 0;
- }
- public long position(Blob pattern, long start)
- throws SQLException {
- return 0;
- }
- public int setBytes(long pos, byte[] bytes)
- throws SQLException {
- return 0;
- }
- public int setBytes(long pos, byte[] bytes, int offset, int len)
- throws SQLException {
- return 0;
- }
- public OutputStream setBinaryStream(long pos)
- throws SQLException {
- return null;
- }
- public void truncate(long len)
- throws SQLException {
- }
- /* 6.0 implementation */
-
- public void free() throws SQLException {}
-
- public InputStream getBinaryStream(long pos, long length) throws SQLException {
- return null;
- }
-}
--- a/jdk/test/java/sql/util/StubConnection.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,315 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.NClob;
-import java.sql.PreparedStatement;
-import java.sql.SQLClientInfoException;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Savepoint;
-import java.sql.Statement;
-import java.sql.Struct;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Executor;
-
-public class StubConnection implements Connection {
-
- @Override
- public Statement createStatement() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String nativeSQL(String sql) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setAutoCommit(boolean autoCommit) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean getAutoCommit() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void commit() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void rollback() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void close() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isClosed() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public DatabaseMetaData getMetaData() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setReadOnly(boolean readOnly) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isReadOnly() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setCatalog(String catalog) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getCatalog() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTransactionIsolation(int level) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getTransactionIsolation() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void clearWarnings() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Map<String, Class<?>> getTypeMap() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setHoldability(int holdability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Savepoint setSavepoint() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Savepoint setSavepoint(String name) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void rollback(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void releaseSavepoint(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Clob createClob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Blob createBlob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public NClob createNClob() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public SQLXML createSQLXML() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isValid(int timeout) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setClientInfo(String name, String value) throws SQLClientInfoException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setClientInfo(Properties properties) throws SQLClientInfoException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getClientInfo(String name) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Properties getClientInfo() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setSchema(String schema) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public String getSchema() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void abort(Executor executor) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getNetworkTimeout() throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public <T> T unwrap(Class<T> iface) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
--- a/jdk/test/java/sql/util/StubDriver.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-public class StubDriver implements Driver {
-
- public StubDriver() {
- }
-
- @Override
- public Connection connect(String url, Properties info) throws SQLException {
- if (acceptsURL(url)) {
- return new StubConnection();
- }
- return null;
- }
-
- @Override
- public boolean acceptsURL(String url) throws SQLException {
- return url.matches("^jdbc:tennis:.*");
- }
-
- @Override
- public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getMajorVersion() {
- return 1;
- }
-
- @Override
- public int getMinorVersion() {
- return 0;
- }
-
- @Override
- public boolean jdbcCompliant() {
- return true;
- }
-
- @Override
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}
--- a/jdk/test/java/sql/util/StubDriverDA.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.DriverAction;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple java.sql.Driver stub class that registers the driver via a static
- * block with a DriverAction Implementation
- * @author ljanders
- */
-public class StubDriverDA extends StubDriver {
-
- public static final String DriverActionCalled = "DriverActionCalled.txt";
-
- static DriverAction da;
-
- static {
- try {
- DriverManager.registerDriver(new StubDriverDA(), da);
- } catch (SQLException ex) {
- Logger.getLogger(StubDriverDA.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
-
- public StubDriverDA() {
- da = new DriverActionImpl(this);
- }
-
- @Override
- public boolean acceptsURL(String url) throws SQLException {
- return url.matches("^jdbc:luckydog:.*");
- }
-
- /**
- * This method will write out a text file when called by the
- * DriverActionImpl.release method when DriverManager.deregisterDriver
- * is called. This is used by DriverManagerTests to validate that
- * DriverAction.release was called
- */
- protected void release() {
- File file = new File(DriverActionCalled);
- try {
- file.createNewFile();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-}
--- a/jdk/test/java/sql/util/TestPolicy.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.FilePermission;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.sql.SQLPermission;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-import java.util.StringJoiner;
-
-/*
- * Simple Policy class that supports the required Permissions to validate the
- * JDBC concrete classes
- */
-public class TestPolicy extends Policy {
-
- final PermissionCollection permissions = new Permissions();
-
- /**
- * Constructor which sets the minimum permissions allowing testNG to work
- * with a SecurityManager
- */
- public TestPolicy() {
- setMinimalPermissions();
- }
-
- /*
- * Constructor which determines which permissions are defined for this
- * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
- * setLog (SQLPemission("setLog"), deregisterDriver
- * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
- * and setSyncFactory(SQLPermission(setSyncFactory),
- *
- * @param policy Permissions to set
- */
- public TestPolicy(String policy) {
-
- switch (policy) {
- case "all":
- permissions.add(new AllPermission());
- break;
- case "setLog":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setLog"));
- break;
- case "deregisterDriver":
- setMinimalPermissions();
- permissions.add(new SQLPermission("deregisterDriver"));
- break;
- case "setSyncFactory":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setSyncFactory"));
- break;
- default:
- setMinimalPermissions();
- }
- }
-
- /*
- * Defines the minimal permissions required by testNG when running these
- * tests
- */
- private void setMinimalPermissions() {
- permissions.add(new SecurityPermission("getPolicy"));
- permissions.add(new SecurityPermission("setPolicy"));
- permissions.add(new RuntimePermission("getClassLoader"));
- permissions.add(new RuntimePermission("setSecurityManager"));
- permissions.add(new RuntimePermission("createSecurityManager"));
- permissions.add(new PropertyPermission("testng.show.stack.frames",
- "read"));
- permissions.add(new PropertyPermission("line.separator", "read"));
- permissions.add(new PropertyPermission("fileStringBuffer", "read"));
- permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
- permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
- permissions.add(new FilePermission("<<ALL FILES>>",
- "read, write, delete"));
- }
-
- /*
- * Overloaded methods from the Policy class
- */
- @Override
- public String toString() {
- StringJoiner sj = new StringJoiner("\n", "policy: ", "");
- Enumeration<Permission> perms = permissions.elements();
- while (perms.hasMoreElements()) {
- sj.add(perms.nextElement().toString());
- }
- return sj.toString();
-
- }
-
- @Override
- public PermissionCollection getPermissions(ProtectionDomain domain) {
- return permissions;
- }
-
- @Override
- public PermissionCollection getPermissions(CodeSource codesource) {
- return permissions;
- }
-
- @Override
- public boolean implies(ProtectionDomain domain, Permission perm) {
- return permissions.implies(perm);
- }
-}
--- a/jdk/test/javax/sql/testng/TEST.properties Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/javax/sql/testng/TEST.properties Thu Oct 30 13:56:09 2014 -0700
@@ -1,3 +1,4 @@
# JDBC unit tests uses TestNG
TestNG.dirs= .
othervm.dirs= .
+lib.dirs = /java/sql/testng
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,555 @@
+/*
+ * Copyright (c) 2014, 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 test.rowset;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Types;
+import javax.sql.RowSetMetaData;
+import javax.sql.rowset.RowSetMetaDataImpl;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import util.BaseTest;
+
+public class RowSetMetaDataTests extends BaseTest {
+
+ // Max columns used in the tests
+ private final int MAX_COLUMNS = 5;
+ // Instance to be used within the tests
+ private RowSetMetaDataImpl rsmd;
+
+ @BeforeMethod
+ public void setUpMethod() throws Exception {
+ rsmd = new RowSetMetaDataImpl();
+ rsmd.setColumnCount(MAX_COLUMNS);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test(Integer col) throws Exception {
+ rsmd.getCatalogName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test01(Integer col) throws Exception {
+ rsmd.getColumnClassName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test02(Integer col) throws Exception {
+ rsmd.getColumnDisplaySize(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test03(Integer col) throws Exception {
+ rsmd.getColumnLabel(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test04(Integer col) throws Exception {
+ rsmd.getColumnName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test05(Integer col) throws Exception {
+ rsmd.getColumnType(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test06(Integer col) throws Exception {
+ rsmd.getColumnTypeName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test07(Integer col) throws Exception {
+ rsmd.getPrecision(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test08(Integer col) throws Exception {
+ rsmd.getScale(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test09(Integer col) throws Exception {
+ rsmd.getSchemaName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test10(Integer col) throws Exception {
+ rsmd.getTableName(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test11(Integer col) throws Exception {
+ rsmd.isAutoIncrement(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test12(Integer col) throws Exception {
+ rsmd.isCaseSensitive(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test13(Integer col) throws Exception {
+ rsmd.isCurrency(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test14(Integer col) throws Exception {
+ rsmd.isDefinitelyWritable(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test15(Integer col) throws Exception {
+ rsmd.isNullable(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test16(Integer col) throws Exception {
+ rsmd.isReadOnly(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test17(Integer col) throws Exception {
+ rsmd.isSearchable(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test18(Integer col) throws Exception {
+ rsmd.isSigned(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test19(Integer col) throws Exception {
+ rsmd.isWritable(col);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test20(Integer col) throws Exception {
+ rsmd.setAutoIncrement(col, true);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test21(Integer col) throws Exception {
+ rsmd.setCaseSensitive(col, true);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test22(Integer col) throws Exception {
+ rsmd.setCatalogName(col, null);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test23(Integer col) throws Exception {
+ rsmd.setColumnDisplaySize(col, 5);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test24(Integer col) throws Exception {
+ rsmd.setColumnLabel(col, "label");
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test25(Integer col) throws Exception {
+ rsmd.setColumnName(col, "F1");
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test26(Integer col) throws Exception {
+ rsmd.setColumnType(col, Types.CHAR);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test27(Integer col) throws Exception {
+ rsmd.setColumnTypeName(col, "F1");
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test28(Integer col) throws Exception {
+ rsmd.setCurrency(col, true);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test29(Integer col) throws Exception {
+ rsmd.setNullable(col, ResultSetMetaData.columnNoNulls);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test30(Integer col) throws Exception {
+ rsmd.setPrecision(col, 2);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test31(Integer col) throws Exception {
+ rsmd.setScale(col, 2);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test32(Integer col) throws Exception {
+ rsmd.setSchemaName(col, "Gotham");
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test33(Integer col) throws Exception {
+ rsmd.setSearchable(col, false);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test34(Integer col) throws Exception {
+ rsmd.setSigned(col, false);
+ }
+
+ /*
+ * Validate a SQLException is thrown for an invalid column index
+ */
+ @Test(dataProvider = "invalidColumnRanges",
+ expectedExceptions = SQLException.class)
+ public void test35(Integer col) throws Exception {
+ rsmd.setTableName(col, "SUPERHEROS");
+ }
+
+ /*
+ * Validate that the correct class name is returned for the column
+ * Note: Once setColumnClassName is added to RowSetMetaData, this
+ * method will need to change.
+ */
+ @Test(dataProvider = "columnClassNames")
+ public void test36(Integer type, String name) throws Exception {
+ rsmd.setColumnType(1, type);
+ assertTrue(rsmd.getColumnClassName(1).equals(name));
+ }
+
+ /*
+ * Validate that all of the methods are accessible and the correct value
+ * is returned for each column
+ */
+ @Test(dataProvider = "columnRanges")
+ public void test37(Integer col) throws Exception {
+ rsmd.setAutoIncrement(col, true);
+ assertTrue(rsmd.isAutoIncrement(col));
+ rsmd.setCaseSensitive(col, true);
+ assertTrue(rsmd.isCaseSensitive(col));
+ rsmd.setCatalogName(col, "Gotham");
+ assertTrue(rsmd.getCatalogName(col).equals("Gotham"));
+ rsmd.setColumnDisplaySize(col, 20);
+ assertTrue(rsmd.getColumnDisplaySize(col) == 20);
+ rsmd.setColumnLabel(col, "F1");
+ assertTrue(rsmd.getColumnLabel(col).equals("F1"));
+ rsmd.setColumnName(col, "F1");
+ assertTrue(rsmd.getColumnName(col).equals("F1"));
+ rsmd.setColumnType(col, Types.INTEGER);
+ assertTrue(rsmd.getColumnType(col) == Types.INTEGER);
+ assertTrue(rsmd.getColumnClassName(col).equals(Integer.class.getName()));
+ rsmd.setColumnTypeName(col, "INTEGER");
+ assertTrue(rsmd.getColumnTypeName(col).equals("INTEGER"));
+ rsmd.setCurrency(col, true);
+ assertTrue(rsmd.isCurrency(col));
+ rsmd.setNullable(col, ResultSetMetaData.columnNoNulls);
+ assertTrue(rsmd.isNullable(col) == ResultSetMetaData.columnNoNulls);
+ rsmd.setPrecision(col, 2);
+ assertTrue(rsmd.getPrecision(col) == 2);
+ rsmd.setScale(col, 2);
+ assertTrue(rsmd.getScale(col) == 2);
+ rsmd.setSchemaName(col, "GOTHAM");
+ assertTrue(rsmd.getSchemaName(col).equals("GOTHAM"));
+ rsmd.setSearchable(col, false);
+ assertFalse(rsmd.isSearchable(col));
+ rsmd.setSigned(col, false);
+ assertFalse(rsmd.isSigned(col));
+ rsmd.setTableName(col, "SUPERHEROS");
+ assertTrue(rsmd.getTableName(col).equals("SUPERHEROS"));
+ rsmd.isReadOnly(col);
+ rsmd.isDefinitelyWritable(col);
+ rsmd.isWritable(col);
+
+ }
+
+ /*
+ * Validate that the proper values are accepted by setNullable
+ */
+ @Test(dataProvider = "validSetNullableValues")
+ public void test38(Integer val) throws Exception {
+ rsmd.setNullable(1, val);
+ }
+
+ /*
+ * Validate that the correct type is returned for the column
+ */
+ @Test(dataProvider = "jdbcTypes")
+ public void test39(Integer type) throws Exception {
+ rsmd.setColumnType(1, type);
+ assertTrue(type == rsmd.getColumnType(1));
+ }
+
+ /*
+ * Validate that the correct value is returned from the isXXX methods
+ */
+ @Test(dataProvider = "trueFalse")
+ public void test40(Boolean b) throws Exception {
+ rsmd.setAutoIncrement(1, b);
+ rsmd.setCaseSensitive(1, b);
+ rsmd.setCurrency(1, b);
+ rsmd.setSearchable(1, b);
+ rsmd.setSigned(1, b);
+ assertTrue(rsmd.isAutoIncrement(1) == b);
+ assertTrue(rsmd.isCaseSensitive(1) == b);
+ assertTrue(rsmd.isCurrency(1) == b);
+ assertTrue(rsmd.isSearchable(1) == b);
+ assertTrue(rsmd.isSigned(1) == b);
+ }
+
+ /*
+ * Validate isWrapperFor and unwrap work correctly
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void test99() throws Exception {
+ RowSetMetaData rsmd1 = rsmd;
+ ResultSetMetaData rsmd2 = rsmd;
+ Class clzz = rsmd.getClass();
+ assertTrue(rsmd1.isWrapperFor(clzz));
+ assertTrue(rsmd2.isWrapperFor(clzz));
+ RowSetMetaDataImpl rsmdi = (RowSetMetaDataImpl) rsmd2.unwrap(clzz);
+
+ // False should be returned
+ assertFalse(rsmd1.isWrapperFor(this.getClass()));
+ assertFalse(rsmd2.isWrapperFor(this.getClass()));
+ }
+
+ /*
+ * DataProvider used to provide Date which are not valid and are used
+ * to validate that an IllegalArgumentException will be thrown from the
+ * valueOf method
+ */
+ @DataProvider(name = "validSetNullableValues")
+ private Object[][] validSetNullableValues() {
+ return new Object[][]{
+ {ResultSetMetaData.columnNoNulls},
+ {ResultSetMetaData.columnNullable},
+ {ResultSetMetaData.columnNullableUnknown}
+ };
+ }
+
+ /*
+ * DataProvider used to provide column indexes that are out of range so that
+ * SQLException is thrown
+ */
+ @DataProvider(name = "invalidColumnRanges")
+ private Object[][] invalidColumnRanges() {
+ return new Object[][]{
+ {-1},
+ {0},
+ {MAX_COLUMNS + 1}
+ };
+ }
+
+ /*
+ * DataProvider used to provide the valid column ranges for the
+ * RowSetMetaDataImpl object
+ */
+ @DataProvider(name = "columnRanges")
+ private Object[][] columnRanges() {
+ Object[][] o = new Object[MAX_COLUMNS][1];
+ for (int i = 1; i <= MAX_COLUMNS; i++) {
+ o[i - 1][0] = i;
+ }
+ return o;
+ }
+
+ /*
+ * DataProvider used to specify the value to set via setColumnType and
+ * the expected value to be returned from getColumnClassName
+ */
+ @DataProvider(name = "columnClassNames")
+ private Object[][] columnClassNames() {
+ return new Object[][]{
+ {Types.CHAR, "java.lang.String"},
+ {Types.NCHAR, "java.lang.String"},
+ {Types.VARCHAR, "java.lang.String"},
+ {Types.NVARCHAR, "java.lang.String"},
+ {Types.LONGVARCHAR, "java.lang.String"},
+ {Types.LONGNVARCHAR, "java.lang.String"},
+ {Types.NUMERIC, "java.math.BigDecimal"},
+ {Types.DECIMAL, "java.math.BigDecimal"},
+ {Types.BIT, "java.lang.Boolean"},
+ {Types.TINYINT, "java.lang.Byte"},
+ {Types.SMALLINT, "java.lang.Short"},
+ {Types.INTEGER, "java.lang.Integer"},
+ {Types.FLOAT, "java.lang.Double"},
+ {Types.DOUBLE, "java.lang.Double"},
+ {Types.BINARY, "byte[]"},
+ {Types.VARBINARY, "byte[]"},
+ {Types.LONGVARBINARY, "byte[]"},
+ {Types.DATE, "java.sql.Date"},
+ {Types.TIME, "java.sql.Time"},
+ {Types.TIMESTAMP, "java.sql.Timestamp"},
+ {Types.CLOB, "java.sql.Clob"},
+ {Types.BLOB, "java.sql.Blob"}
+
+ };
+
+ }
+
+}
--- a/jdk/test/javax/sql/testng/util/BaseTest.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Policy;
-import java.sql.SQLException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-
-public class BaseTest {
-
- protected final String reason = "reason";
- protected final String state = "SQLState";
- protected final String cause = "java.lang.Throwable: cause";
- protected final Throwable t = new Throwable("cause");
- protected final Throwable t1 = new Throwable("cause 1");
- protected final Throwable t2 = new Throwable("cause 2");
- protected final int errorCode = 21;
- protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
- "Exception 3", "cause 2"};
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @BeforeMethod
- public void setUpMethod() throws Exception {
- }
-
- @AfterMethod
- public void tearDownMethod() throws Exception {
- }
-
- /*
- * Take some form of SQLException, serialize and deserialize it
- */
- @SuppressWarnings("unchecked")
- protected <T extends SQLException> T
- createSerializedException(T ex)
- throws IOException, ClassNotFoundException {
- return (T) serializeDeserializeObject(ex);
- }
-
- /*
- * Utility method to serialize and deserialize an object
- */
- @SuppressWarnings("unchecked")
- protected <T> T serializeDeserializeObject(T o)
- throws IOException, ClassNotFoundException {
- T o1;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
- oos.writeObject(o);
- }
- try (ObjectInputStream ois
- = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
- o1 = (T) ois.readObject();
- }
- return o1;
- }
-
- /*
- * Utility Method used to set the current Policy
- */
- protected static void setPolicy(Policy p) {
- Policy.setPolicy(p);
- }
-}
--- a/jdk/test/javax/sql/testng/util/TestPolicy.java Thu Oct 30 08:35:01 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2014, 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 util;
-
-import java.io.FilePermission;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.sql.SQLPermission;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-import java.util.StringJoiner;
-
-/*
- * Simple Policy class that supports the required Permissions to validate the
- * JDBC concrete classes
- */
-public class TestPolicy extends Policy {
-
- final PermissionCollection permissions = new Permissions();
-
- /**
- * Constructor which sets the minimum permissions allowing testNG to work
- * with a SecurityManager
- */
- public TestPolicy() {
- setMinimalPermissions();
- }
-
- /*
- * Constructor which determines which permissions are defined for this
- * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
- * setLog (SQLPemission("setLog"), deregisterDriver
- * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
- * and setSyncFactory(SQLPermission(setSyncFactory),
- *
- * @param policy Permissions to set
- */
- public TestPolicy(String policy) {
-
- switch (policy) {
- case "all":
- permissions.add(new AllPermission());
- break;
- case "setLog":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setLog"));
- break;
- case "deregisterDriver":
- setMinimalPermissions();
- permissions.add(new SQLPermission("deregisterDriver"));
- break;
- case "setSyncFactory":
- setMinimalPermissions();
- permissions.add(new SQLPermission("setSyncFactory"));
- break;
- default:
- setMinimalPermissions();
- }
- }
-
- /*
- * Defines the minimal permissions required by testNG when running these
- * tests
- */
- private void setMinimalPermissions() {
- permissions.add(new SecurityPermission("getPolicy"));
- permissions.add(new SecurityPermission("setPolicy"));
- permissions.add(new RuntimePermission("getClassLoader"));
- permissions.add(new RuntimePermission("setSecurityManager"));
- permissions.add(new RuntimePermission("createSecurityManager"));
- permissions.add(new PropertyPermission("testng.show.stack.frames",
- "read"));
- permissions.add(new PropertyPermission("line.separator", "read"));
- permissions.add(new PropertyPermission("fileStringBuffer", "read"));
- permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
- permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
- permissions.add(new FilePermission("<<ALL FILES>>",
- "read, write, delete"));
- }
-
- /*
- * Overloaded methods from the Policy class
- */
- @Override
- public String toString() {
- StringJoiner sj = new StringJoiner("\n", "policy: ", "");
- Enumeration<Permission> perms = permissions.elements();
- while (perms.hasMoreElements()) {
- sj.add(perms.nextElement().toString());
- }
- return sj.toString();
-
- }
-
- @Override
- public PermissionCollection getPermissions(ProtectionDomain domain) {
- return permissions;
- }
-
- @Override
- public PermissionCollection getPermissions(CodeSource codesource) {
- return permissions;
- }
-
- @Override
- public boolean implies(ProtectionDomain domain, Permission perm) {
- return permissions.implies(perm);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JLayer/8054543/bug8054543.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014, 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
+ * @summary Setting a border on a JLayer causes an Exceptions
+ * @author Alexander Potochkin
+ * @run main bug8054543
+ */
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import java.awt.*;
+
+public class bug8054543 {
+
+ public bug8054543() {
+ JLayer<JComponent> layer = new JLayer<>();
+ Border border = BorderFactory.createLineBorder(Color.GREEN);
+ JButton view = new JButton("JButton");
+
+ layer.setBorder(border);
+ check(layer.getBorder(), null);
+
+ layer.setBorder(null);
+ check(layer.getBorder(), null);
+
+ layer.setView(view);
+ check(layer.getBorder(), view.getBorder());
+
+ layer.setBorder(border);
+ check(border, view.getBorder());
+
+ layer.setBorder(null);
+ check(layer.getBorder(), view.getBorder());
+ }
+
+ private void check(Object o1, Object o2) {
+ if (o1 != o2) {
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ new bug8054543();
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JRadioButton/8033699/bug8033699.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2014, 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
+ * @library ../../regtesthelpers
+ * @build Util
+ * @bug 8033699
+ * @summary Incorrect radio button behavior when pressing tab key
+ * @author Vivi An
+ * @run main bug8033699
+ */
+
+import javax.swing.*;
+import javax.swing.event.*;
+import java.awt.event.*;
+import java.awt.*;
+import sun.awt.SunToolkit;
+
+public class bug8033699 {
+ private static Robot robot;
+ private static SunToolkit toolkit;
+
+ private static JButton btnStart;
+ private static ButtonGroup btnGrp;
+ private static JButton btnEnd;
+ private static JButton btnMiddle;
+ private static JRadioButton radioBtn1;
+ private static JRadioButton radioBtn2;
+ private static JRadioButton radioBtn3;
+ private static JRadioButton radioBtnSingle;
+
+ public static void main(String args[]) throws Throwable {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ robot = new Robot();
+ Thread.sleep(100);
+
+ robot.setAutoDelay(100);
+ toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ // tab key test grouped radio button
+ runTest1();
+
+ // tab key test non-grouped radio button
+ runTest2();
+
+ // shift tab key test grouped and non grouped radio button
+ runTest3();
+
+ // left/up key test in grouped radio button
+ runTest4();
+
+ // down/right key test in grouped radio button
+ runTest5();
+
+ // tab from radio button in group to next component in the middle of button group layout
+ runTest6();
+
+ // tab to radio button in group from component in the middle of button group layout
+ runTest7();
+
+ // down key circle back to first button in grouped radio button
+ runTest8();
+ }
+
+ private static void createAndShowGUI() {
+ JFrame mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
+
+ btnStart = new JButton("Start");
+ btnEnd = new JButton("End");
+ btnMiddle = new JButton("Middle");
+
+ JPanel box = new JPanel();
+ box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
+ box.setBorder(BorderFactory.createTitledBorder("Grouped Radio Buttons"));
+ radioBtn1 = new JRadioButton("A");
+ radioBtn2 = new JRadioButton("B");
+ radioBtn3 = new JRadioButton("C");
+
+ ButtonGroup btnGrp = new ButtonGroup();
+ btnGrp.add(radioBtn1);
+ btnGrp.add(radioBtn2);
+ btnGrp.add(radioBtn3);
+ radioBtn1.setSelected(true);
+
+ box.add(radioBtn1);
+ box.add(radioBtn2);
+ box.add(btnMiddle);
+ box.add(radioBtn3);
+
+ radioBtnSingle = new JRadioButton("Not Grouped");
+ radioBtnSingle.setSelected(true);
+
+ mainFrame.getContentPane().add(btnStart);
+ mainFrame.getContentPane().add(box);
+ mainFrame.getContentPane().add(radioBtnSingle);
+ mainFrame.getContentPane().add(btnEnd);
+
+ mainFrame.getRootPane().setDefaultButton(btnStart);
+ btnStart.requestFocus();
+
+ mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ mainFrame.setLayout(new BoxLayout(mainFrame.getContentPane(), BoxLayout.Y_AXIS));
+
+ mainFrame.setSize(300, 300);
+ mainFrame.setLocation(200, 200);
+ mainFrame.setVisible(true);
+ mainFrame.toFront();
+ }
+
+ // Radio button Group as a single component when traversing through tab key
+ private static void runTest1() throws Exception{
+ hitKey(robot, KeyEvent.VK_TAB);
+ hitKey(robot, KeyEvent.VK_TAB);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
+ System.out.println("Radio Button Group Go To Next Component through Tab Key failed");
+ throw new RuntimeException("Focus is not on Radio Button Single as Expected");
+ }
+ }
+ });
+ }
+
+ // Non-Grouped Radio button as a single component when traversing through tab key
+ private static void runTest2() throws Exception{
+ hitKey(robot, KeyEvent.VK_TAB);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) {
+ System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed");
+ throw new RuntimeException("Focus is not on Button End as Expected");
+ }
+ }
+ });
+ }
+
+ // Non-Grouped Radio button and Group Radio button as a single component when traversing through shift-tab key
+ private static void runTest3() throws Exception{
+ hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
+ hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+ System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed");
+ throw new RuntimeException("Focus is not on Radio Button C as Expected");
+ }
+ }
+ });
+ }
+
+ // Using arrow key to move focus in radio button group
+ private static void runTest4() throws Exception{
+ hitKey(robot, KeyEvent.VK_UP);
+ hitKey(robot, KeyEvent.VK_LEFT);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
+ System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed");
+ throw new RuntimeException("Focus is not on Radio Button A as Expected");
+ }
+ }
+ });
+ }
+
+ private static void runTest5() throws Exception{
+ hitKey(robot, KeyEvent.VK_DOWN);
+ hitKey(robot, KeyEvent.VK_RIGHT);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+ System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed");
+ throw new RuntimeException("Focus is not on Radio Button C as Expected");
+ }
+ }
+ });
+ }
+
+ private static void runTest6() throws Exception{
+ hitKey(robot, KeyEvent.VK_DOWN);
+ hitKey(robot, KeyEvent.VK_DOWN);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) {
+ System.out.println("Radio button Group Circle Back To First Button Test");
+ throw new RuntimeException("Focus is not on Radio Button A as Expected");
+ }
+ }
+ });
+ }
+
+ private static void runTest7() throws Exception{
+ hitKey(robot, KeyEvent.VK_TAB);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) {
+ System.out.println("Separate Component added in button group layout");
+ throw new RuntimeException("Focus is not on Middle Button as Expected");
+ }
+ }
+ });
+ }
+
+ private static void runTest8() throws Exception{
+ hitKey(robot, KeyEvent.VK_TAB);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
+ System.out.println("Separate Component added in button group layout");
+ throw new RuntimeException("Focus is not on Radio Button C as Expected");
+ }
+ }
+ });
+ }
+
+ private static void hitKey(Robot robot, int keycode) {
+ robot.keyPress(keycode);
+ robot.keyRelease(keycode);
+ toolkit.realSync();
+ }
+
+ private static void hitKey(Robot robot, int mode, int keycode) {
+ robot.keyPress(mode);
+ robot.keyPress(keycode);
+ robot.keyRelease(mode);
+ robot.keyRelease(keycode);
+ toolkit.realSync();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2014, 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.awt.Component;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.JViewport;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 7170310
+ * @author Alexey Ivanov
+ * @summary Selected tab should be scrolled into view.
+ * @run main bug7170310
+ */
+public class bug7170310 {
+ private static final int TABS_NUMBER = 3;
+
+ private static volatile JTabbedPane tabbedPane;
+ private static volatile int count = 1;
+
+ private static volatile JFrame frame;
+
+ private static volatile Exception exception = null;
+
+ public static void main(String[] args) throws Exception {
+ try {
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ toolkit.realSync();
+
+ for (int i = 0; i < TABS_NUMBER; i++) {
+ SwingUtilities.invokeAndWait(bug7170310::addTab);
+ toolkit.realSync();
+ }
+
+ SwingUtilities.invokeAndWait(bug7170310::check);
+
+ if (exception != null) {
+ System.out.println("Test failed: " + exception.getMessage());
+ throw exception;
+ } else {
+ System.out.printf("Test passed");
+ }
+ } finally {
+ frame.dispose();
+ }
+ }
+
+ private static void createAndShowUI() {
+ frame = new JFrame("bug7170310");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(200, 100);
+
+ tabbedPane = new JTabbedPane();
+ tabbedPane.addTab("Main Tab", new JPanel());
+
+ tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+
+ frame.getContentPane().add(tabbedPane);
+ frame.setVisible(true);
+ }
+
+ private static void addTab() {
+ tabbedPane.addTab("Added Tab " + count++, new JPanel());
+ tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
+ }
+
+ private static void check() {
+ try {
+ JViewport vp = null;
+ for (Component c : tabbedPane.getComponents()) {
+ if (c instanceof JViewport) {
+ vp = (JViewport) c;
+ break;
+ }
+ }
+
+ JComponent v = (JComponent) vp.getView();
+ Rectangle vr = vp.getViewRect();
+ Dimension vs = v.getSize();
+
+ // The tab view must be scrolled to the end so that the last tab is visible
+ if (vs.width != (vr.x + vr.width)) {
+ throw new RuntimeException("tabScroller.tabPanel view is positioned incorrectly: "
+ + vs.width + " vs " + (vr.x + vr.width));
+ }
+ } catch (Exception e) {
+ exception = e;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 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 8058120
+ * @summary Rendering / caret errors with HTMLDocument
+ * @author Dmitry Markov
+ * @run main bug8058120
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.text.Element;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
+import java.awt.*;
+
+public class bug8058120 {
+ private static SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ private static HTMLDocument document = null;
+ private static final String text = "<p id = 'ab'>ab</p>";
+ private static final String textToInsert = "c";
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ document.insertAfterEnd(document.getElement("ab"), textToInsert);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+
+ toolkit.realSync();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Element parent = document.getElement("ab").getParentElement();
+ int count = parent.getElementCount();
+ if (count != 2) {
+ throw new RuntimeException("Test Failed! Unexpected Element count = "+count);
+ }
+ Element insertedElement = parent.getElement(count - 1);
+ if (!HTML.Tag.IMPLIED.toString().equals(insertedElement.getName())) {
+ throw new RuntimeException("Test Failed! Inserted text is not wrapped by " + HTML.Tag.IMPLIED + " tag");
+ }
+ }
+ });
+ }
+
+ private static void createAndShowGUI() {
+ try {
+ UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+
+ JFrame frame = new JFrame("bug8058120");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JEditorPane editorPane = new JEditorPane();
+ editorPane.setContentType("text/html");
+ editorPane.setEditorKit(new HTMLEditorKit());
+
+ document = (HTMLDocument) editorPane.getDocument();
+
+ editorPane.setText(text);
+
+ frame.add(editorPane);
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+ }
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/testng/parse/jdk7156085/UTF8ReaderBug.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2014 Google, Inc. 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 parse.jdk7156085;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.DefaultHandler;
+import org.testng.annotations.Test;
+
+/**
+ * JDK-7156085: ArrayIndexOutOfBoundsException throws in UTF8Reader of SAXParser
+ * https://bugs.openjdk.java.net/browse/JDK-7156085
+ *
+ * XERCESJ-1257: buffer overflow in UTF8Reader for characters out of BMP
+ * https://issues.apache.org/jira/browse/XERCESJ-1257
+ */
+public class UTF8ReaderBug {
+ @Test
+ public void shouldAcceptSupplementaryCharacters() throws Throwable {
+ StringBuilder b = new StringBuilder("<xml>");
+ for(int i = 5; i < 8223; i++) {
+ b.append(' ');
+ }
+ // Add surrogate characters which overflow the buffer. This shows the need to place an
+ // overflow check at --
+ // com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:544)
+ b.append("\uD835\uDC37");
+ b.append("</xml>");
+ sendToParser(b.toString());
+ }
+
+ private static void sendToParser(String b) throws Throwable {
+ byte[] input = b.getBytes("UTF-8");
+ ByteArrayInputStream in = new ByteArrayInputStream(input);
+
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ SAXParser p = spf.newSAXParser();
+ p.parse(new InputSource(in), new DefaultHandler());
+ }
+}
--- a/jdk/test/jdk/nio/zipfs/Basic.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/Basic.java Thu Oct 30 13:56:09 2014 -0700
@@ -35,7 +35,7 @@
* @summary Basic test for zip provider
*
* @run main Basic
- * @run main/othervm/policy=test.policy Basic
+ * @run main/othervm/java.security.policy=test.policy Basic
*/
public class Basic {
--- a/jdk/test/jdk/nio/zipfs/PathOps.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/PathOps.java Thu Oct 30 13:56:09 2014 -0700
@@ -33,7 +33,7 @@
* @summary Tests path operations for zip provider.
*
* @run main PathOps
- * @run main/othervm/policy=test.policy.readonly PathOps
+ * @run main/othervm/java.security.policy=test.policy.readonly PathOps
*/
public class PathOps {
--- a/jdk/test/jdk/nio/zipfs/ZFSTests.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/ZFSTests.java Thu Oct 30 13:56:09 2014 -0700
@@ -26,7 +26,7 @@
* @summary ZipFileSystem regression tests
*
* @run main ZFSTests
- * @run main/othervm/policy=test.policy ZFSTests
+ * @run main/othervm/java.security.policy=test.policy ZFSTests
*/
--- a/jdk/test/jdk/nio/zipfs/ZipFSTester.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/ZipFSTester.java Thu Oct 30 13:56:09 2014 -0700
@@ -43,7 +43,7 @@
* 7157656 8002390 7012868 7012856 8015728 8038500 8040059
* @summary Test Zip filesystem provider
* @run main ZipFSTester
- * @run main/othervm/policy=test.policy ZipFSTester
+ * @run main/othervm/java.security.policy=test.policy ZipFSTester
*/
public class ZipFSTester {
--- a/jdk/test/jdk/nio/zipfs/test.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/test.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,9 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
- permission java.io.FilePermission "<<ALL FILES>>", "read,write";
- permission java.lang.RuntimePermission "fileSystemProvider";
- permission java.util.PropertyPermission "*", "read";
-};
-
grant {
permission java.io.FilePermission "<<ALL FILES>>","read,write,delete";
permission java.util.PropertyPermission "test.jdk","read";
--- a/jdk/test/jdk/nio/zipfs/test.policy.readonly Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/jdk/nio/zipfs/test.policy.readonly Thu Oct 30 13:56:09 2014 -0700
@@ -1,9 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
- permission java.io.FilePermission "<<ALL FILES>>", "read,write";
- permission java.lang.RuntimePermission "fileSystemProvider";
- permission java.util.PropertyPermission "*", "read";
-};
-
grant {
permission java.io.FilePermission "<<ALL FILES>>","read";
permission java.util.PropertyPermission "test.jdk","read";
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Thu Oct 30 13:56:09 2014 -0700
@@ -319,13 +319,14 @@
return output;
} catch (Throwable t) {
+ if (p != null) {
+ p.destroyForcibly().waitFor();
+ }
+
failed = true;
System.out.println("executeProcess() failed: " + t);
throw t;
} finally {
- if (p != null) {
- p.destroyForcibly().waitFor();
- }
if (failed) {
System.err.println(getProcessLog(pb, output));
}
--- a/jdk/test/sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java Thu Oct 30 13:56:09 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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
@@ -89,8 +89,13 @@
public void update(Graphics g) {}
};
frame.setBackground(bgColor);
+ frame.setUndecorated(true);
frame.pack();
- frame.setSize(FRAME_W, FRAME_H);
+
+ GraphicsConfiguration gc = frame.getGraphicsConfiguration();
+ Rectangle gcBounds = gc.getBounds();
+ frame.setBounds(gcBounds.width / 4, gcBounds.height / 4, FRAME_W, FRAME_H);
+
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
done = true;
@@ -108,9 +113,8 @@
ex.printStackTrace();
}
- GraphicsConfiguration gc = frame.getGraphicsConfiguration();
- int maxW = gc.getBounds().width /2;
- int maxH = gc.getBounds().height/2;
+ int maxW = gcBounds.width /2;
+ int maxH = gcBounds.height/2;
int minW = frame.getWidth();
int minH = frame.getHeight();
int incW = 10, incH = 10, cnt = 0;
@@ -155,6 +159,7 @@
Insets in = frame.getInsets();
frame.getGraphics().drawImage(output, in.left, in.top, null);
if (cnt == 90 && robot != null) {
+ robot.waitForIdle();
// area where we blitted to should be either white or green
Point p = frame.getLocationOnScreen();
p.translate(in.left+10, in.top+10);
@@ -172,7 +177,7 @@
frame.getWidth()-in.left-in.right,
frame.getHeight()-in.top-in.bottom-5-IMAGE_H));
int accepted2[] = { Color.white.getRGB() };
- checkBI(bi, accepted1);
+ checkBI(bi, accepted2);
}
Thread.yield();
--- a/jdk/test/sun/nio/cs/TestUTF_16.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/nio/cs/TestUTF_16.java Thu Oct 30 13:56:09 2014 -0700
@@ -150,7 +150,7 @@
if (CoderResult.OVERFLOW !=
Charset.forName("UTF_16")
.newDecoder()
- .decode((ByteBuffer)(ByteBuffer.allocate(4)
+ .decode((ByteBuffer.allocate(4)
.put(new byte[]
{(byte)0xd8,(byte)0x00,
(byte)0xdc,(byte)0x01})
--- a/jdk/test/sun/nio/cs/TestUTF_32.java Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/nio/cs/TestUTF_32.java Thu Oct 30 13:56:09 2014 -0700
@@ -184,7 +184,7 @@
if (CoderResult.OVERFLOW !=
Charset.forName("UTF_32")
.newDecoder()
- .decode((ByteBuffer)(ByteBuffer.allocate(4)
+ .decode((ByteBuffer.allocate(4)
.put(new byte[]
{(byte)0,(byte)1, (byte)0,(byte)01})
.flip()),
--- a/jdk/test/sun/security/pkcs11/KeyStore/Basic.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/security/pkcs11/KeyStore/Basic.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,17 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
grant codebase "file:${user.dir}${/}loader.jar" {
permission java.security.AllPermission;
};
--- a/jdk/test/sun/security/pkcs11/Provider/Login.policy Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/security/pkcs11/Provider/Login.policy Thu Oct 30 13:56:09 2014 -0700
@@ -1,18 +1,3 @@
-grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
- permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
- permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
- permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
- permission java.util.PropertyPermission "*", "read";
- permission java.security.SecurityPermission "putProviderProperty.*";
- permission java.security.SecurityPermission "clearProviderProperties.*";
- permission java.security.SecurityPermission "removeProviderProperty.*";
- permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
-
- permission java.security.SecurityPermission "authProvider.*";
- // Needed for reading PKCS11 config file and NSS library check
- permission java.io.FilePermission "<<ALL FILES>>", "read";
-};
-
grant {
permission java.util.PropertyPermission "*", "read, write";
permission java.lang.RuntimePermission "loadLibrary.*";
@@ -23,6 +8,5 @@
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.security.SecurityPermission "setProperty.auth.login.defaultCallbackHandler";
- permission java.security.SecurityPermission "authProvider.SunPKCS11-NSS"
-;
+ permission java.security.SecurityPermission "authProvider.SunPKCS11-NSS";
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java Thu Oct 30 13:56:09 2014 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014, 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.*;
+
+/*
+ * Export a private key from the named keychain entry without supplying a
+ * password. See JDK-8062264.
+ *
+ * NOTE: Keychain access controls must already have been lowered to permit
+ * the target entry to be accessed.
+ */
+public class ExportPrivateKeyNoPwd {
+
+ public static final void main(String[] args) throws Exception {
+
+ if (args.length != 1) {
+ throw new Exception(
+ "ExportPrivateKeyNoPwd: must supply name of a keystore entry");
+ }
+ String alias = args[0];
+
+ KeyStore ks = KeyStore.getInstance("KeychainStore");
+ System.out.println("ExportPrivateKeyNoPwd: loading keychains...");
+ ks.load(null, null);
+
+ System.out.println("ExportPrivateKeyNoPwd: exporting key...");
+ Key key = ks.getKey(alias, null);
+ if (key instanceof PrivateKey) {
+ System.out.println("ExportPrivateKeyNoPwd: exported " +
+ key.getAlgorithm() + " private key from '" + alias + "'");
+ } else {
+ throw new Exception("Error exporting private key from keychain");
+ }
+ }
+}
+
--- a/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh Thu Oct 30 08:35:01 2014 -0700
+++ b/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh Thu Oct 30 13:56:09 2014 -0700
@@ -22,7 +22,7 @@
#
# @test
-# @bug 7133495 8041740
+# @bug 7133495 8041740 8062264
# @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
if [ "${TESTJAVA}" = "" ] ; then
@@ -30,6 +30,9 @@
TESTJAVA=`dirname $JAVAC_CMD`/..
fi
+if [ "${TESTSRC}" = "" ] ; then
+ TESTSRC="."
+fi
if [ "${TESTCLASSES}" = "" ] ; then
TESTCLASSES=`pwd`
fi
@@ -59,10 +62,6 @@
COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
echo "Found $COUNT private key entries in the Keychain keystores"
-if [ $COUNT -gt 1 ]; then
- exit 0
-fi
-
# Create a temporary PKCS12 keystore containing 3 public/private keypairs
RESULT=`$CLEANUP_P12`
@@ -107,8 +106,9 @@
echo "Unlocked the temporary keychain"
# Import the keypairs from the PKCS12 keystore into the keychain
+# (The '-A' option is used to lower the temporary keychain's access controls)
-security import $TEMPORARY_P12 -k $TEMPORARY_KC -f pkcs12 -P $PWD
+security import $TEMPORARY_P12 -k $TEMPORARY_KC -f pkcs12 -P $PWD -A
if [ $? -ne 0 ]; then
echo "Error: cannot import keypairs from PKCS12 keystore into the keychain"
RESULT=`$CLEANUP_P12`
@@ -128,26 +128,39 @@
# Recount the number of private key entries in the Keychain keystores
-COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
-echo "Found $COUNT private key entries in the Keychain keystore"
-if [ $COUNT -lt 3 ]; then
- echo "Error: expected >2 private key entries in the Keychain keystores"
+RECOUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
+echo "Found $RECOUNT private key entries in the Keychain keystore"
+if [ $RECOUNT -lt `expr $COUNT + 3` ]; then
+ echo "Error: expected >$COUNT private key entries in the Keychain keystores"
RESULT=`$CLEANUP_P12`
RESULT=`$CLEANUP_KC`
exit 5
fi
+# Export a private key from the keychain (without supplying a password)
+# Access controls have already been lowered (see 'security import ... -A' above)
+
+${TESTJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/ExportPrivateKeyNoPwd.java || exit 6
+echo | ${TESTJAVA}/bin/java ${TESTVMOPTS} ExportPrivateKeyNoPwd x
+if [ $? -ne 0 ]; then
+ echo "Error exporting private key from the temporary keychain"
+ RESULT=`$CLEANUP_P12`
+ RESULT=`$CLEANUP_KC`
+ exit 6
+fi
+echo "Exported a private key from the temporary keychain"
+
RESULT=`$CLEANUP_P12`
if [ $? -ne 0 ]; then
echo "Error: cannot remove the temporary PKCS12 keystore"
- exit 6
+ exit 7
fi
echo "Removed the temporary PKCS12 keystore"
RESULT=`$CLEANUP_KC`
if [ $? -ne 0 ]; then
echo "Error: cannot remove the temporary keychain"
- exit 7
+ exit 8
fi
echo "Removed the temporary keychain"