diff --git a/make/CompileJavaClasses.gmk b/make/CompileJavaClasses.gmk index 0bc3d636f158332dca6c792168f473c1e30b4587..a3fe9dde677b36cfa7cdc025a28620f1caea70e3 100644 --- a/make/CompileJavaClasses.gmk +++ b/make/CompileJavaClasses.gmk @@ -384,7 +384,7 @@ $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin: JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \ SRC := $(JDK_OUTPUTDIR)/gensrc_ab/32bit, \ BIN := $(JDK_OUTPUTDIR)/classes_ab/32bit, \ - HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers)) + HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers_ab/32)) $(BUILD_ACCESSBRIDGE_32): $(BUILD_JDK) @@ -393,7 +393,7 @@ $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin: JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \ SRC := $(JDK_OUTPUTDIR)/gensrc_ab/legacy, \ BIN := $(JDK_OUTPUTDIR)/classes_ab/legacy, \ - HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers)) + HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers_ab/legacy)) $(BUILD_ACCESSBRIDGE_LEGACY): $(BUILD_JDK) @@ -404,7 +404,7 @@ $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin: JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \ SRC := $(JDK_OUTPUTDIR)/gensrc_ab/64bit, \ BIN := $(JDK_OUTPUTDIR)/classes_ab/64bit, \ - HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers)) + HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers_ab/64)) $(BUILD_ACCESSBRIDGE_64): $(BUILD_JDK) diff --git a/make/lib/PlatformLibraries.gmk b/make/lib/PlatformLibraries.gmk index 88dae8c0470ae61d1053d0d31e642d9e4acbf9eb..6ee5501b7b4ae2e6b9f535d264ecfd0a94e9910b 100644 --- a/make/lib/PlatformLibraries.gmk +++ b/make/lib/PlatformLibraries.gmk @@ -134,7 +134,8 @@ endif define SetupAccessBridge # Parameter 1 Suffix # Parameter 2 Machine - # Parameter 3 ACCESSBRIDGE_ARCH_ suffix + # Parameter 3 ACCESSBRIDGE_ARCH_ suffix and name of directory where gensrc headers + # are found. $(call SetupNativeCompilation,BUILD_JAWTACCESSBRIDGE$1, \ LIBRARY = JAWTAccessBridge$1, \ @@ -144,7 +145,8 @@ endif LANG := C++, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -DACCESSBRIDGE_ARCH_$3, \ + -DACCESSBRIDGE_ARCH_$3 \ + -I$(JDK_OUTPUTDIR)/gensrc_headers_ab/$3, \ LDFLAGS := $(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ @@ -170,7 +172,8 @@ endif LANG := C++, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -DACCESSBRIDGE_ARCH_$3, \ + -DACCESSBRIDGE_ARCH_$3 \ + -I$(JDK_OUTPUTDIR)/gensrc_headers_ab/$3, \ LDFLAGS := $(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ winspool.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ @@ -194,7 +197,8 @@ endif LANG := C++, \ OPTIMIZATION := LOW, \ CFLAGS := $(filter-out -MD, $(CFLAGS_JDKLIB)) -MT \ - -DACCESSBRIDGE_ARCH_$3, \ + -DACCESSBRIDGE_ARCH_$3 \ + -I$(JDK_OUTPUTDIR)/gensrc_headers_ab/$3, \ LDFLAGS := $(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ winspool.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ @@ -215,7 +219,7 @@ endif ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) $(eval $(call SetupAccessBridge,-32,I386,32)) - $(eval $(call SetupAccessBridge,,I386,LEGACY)) + $(eval $(call SetupAccessBridge,,I386,legacy)) else $(eval $(call SetupAccessBridge,-64,X64,64)) endif diff --git a/src/macosx/classes/sun/font/CFont.java b/src/macosx/classes/sun/font/CFont.java index 0173bfc9d2396c4412e771400a8e7fb7fff5498a..c88e53c06633e281a2830640b0048f40bff9b162 100644 --- a/src/macosx/classes/sun/font/CFont.java +++ b/src/macosx/classes/sun/font/CFont.java @@ -77,14 +77,72 @@ public final class CFont extends PhysicalFont { } private static native long createNativeFont(final String nativeFontName, - final int style, - final boolean isFakeItalic); + final int style); private static native void disposeNativeFont(final long nativeFontPtr); private boolean isFakeItalic; private String nativeFontName; private long nativeFontPtr; + private native float getWidthNative(final long nativeFontPtr); + private native float getWeightNative(final long nativeFontPtr); + + private int fontWidth = -1; + private int fontWeight = -1; + + @Override + public int getWidth() { + if (fontWidth == -1) { + // Apple use a range of -1 -> +1, where 0.0 is normal + // OpenType uses a % range from 50% -> 200% where 100% is normal + // and maps these onto the integer values 1->9. + // Since that is what Font2D.getWidth() expects, remap to that. + float fw = getWidthNative(getNativeFontPtr()); + if (fw == 0.0) { // short cut the common case + fontWidth = Font2D.FWIDTH_NORMAL; + return fontWidth; + } + fw += 1.0; fw *= 100.0; + if (fw <= 50.0) { + fontWidth = 1; + } else if (fw <= 62.5) { + fontWidth = 2; + } else if (fw <= 75.0) { + fontWidth = 3; + } else if (fw <= 87.5) { + fontWidth = 4; + } else if (fw <= 100.0) { + fontWidth = 5; + } else if (fw <= 112.5) { + fontWidth = 6; + } else if (fw <= 125.0) { + fontWidth = 7; + } else if (fw <= 150.0) { + fontWidth = 8; + } else { + fontWidth = 9; + } + } + return fontWidth; + } + + @Override + public int getWeight() { + if (fontWeight == -1) { + // Apple use a range of -1 -> +1, where 0 is medium/regular + // Map this on to the OpenType range of 100->900 where + // 500 is medium/regular. + // We'll actually map to 0->1000 but that's close enough. + float fw = getWeightNative(getNativeFontPtr()); + if (fw == 0) { + return Font2D.FWEIGHT_NORMAL; + } + fw += 1.0; fw *= 500; + fontWeight = (int)fw; + } + return fontWeight; + } + // this constructor is called from CFontWrapper.m public CFont(String name) { this(name, name); @@ -94,10 +152,11 @@ public final class CFont extends PhysicalFont { handle = new Font2DHandle(this); fullName = name; familyName = inFamilyName; - nativeFontName = inFamilyName; + nativeFontName = fullName; setStyle(); } + /* Called from CFontManager too */ public CFont(CFont other, String logicalFamilyName) { handle = new Font2DHandle(this); fullName = logicalFamilyName; @@ -109,6 +168,7 @@ public final class CFont extends PhysicalFont { public CFont createItalicVariant() { CFont font = new CFont(this, familyName); + font.nativeFontName = fullName; font.fullName = fullName + (style == Font.BOLD ? "" : "-") + "Italic-Derived"; font.style |= Font.ITALIC; @@ -118,7 +178,7 @@ public final class CFont extends PhysicalFont { protected synchronized long getNativeFontPtr() { if (nativeFontPtr == 0L) { - nativeFontPtr = createNativeFont(nativeFontName, style, isFakeItalic); + nativeFontPtr = createNativeFont(nativeFontName, style); } return nativeFontPtr; } diff --git a/src/macosx/classes/sun/font/CFontManager.java b/src/macosx/classes/sun/font/CFontManager.java index f589efcbec07304be16595c1ef6e4b50db0d1aca..d05f549bc37da3ead41de50f93ac5d7d1a277200 100644 --- a/src/macosx/classes/sun/font/CFontManager.java +++ b/src/macosx/classes/sun/font/CFontManager.java @@ -252,13 +252,42 @@ public final class CFontManager extends SunFontManager { final CFont font = new CFont(fontName, fontFamilyName); registerGenericFont(font); + } - if ((font.getStyle() & Font.ITALIC) == 0) { - registerGenericFont(font.createItalicVariant(), true); + void registerItalicDerived() { + FontFamily[] famArr = FontFamily.getAllFontFamilies(); + for (int i=0; i() { public Object run() { - loadNativeFonts(); + if (!loadedAllFonts) { + loadNativeFonts(); + registerItalicDerived(); + loadedAllFonts = true; + } return null; } } diff --git a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java index 5db1b6ca296e346945ce1a94cdc26bff229d3ddf..f313c46664316d4f84114655259bf400dfd1d727 100644 --- a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java +++ b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ * questions. */ - package sun.lwawt; import java.awt.Component; @@ -40,7 +39,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.ScrollPaneConstants; import javax.swing.text.Document; -import javax.swing.text.JTextComponent; /** * Lightweight implementation of {@link TextAreaPeer}. Delegates most of the @@ -75,12 +73,13 @@ final class LWTextAreaPeer super.initializeImpl(); final int visibility = getTarget().getScrollbarVisibility(); synchronized (getDelegateLock()) { + getTextComponent().setWrapStyleWord(true); setScrollBarVisibility(visibility); } } @Override - JTextComponent getTextComponent() { + JTextArea getTextComponent() { return getDelegate().getView(); } @@ -165,7 +164,7 @@ final class LWTextAreaPeer // JTextArea.replaceRange() is called. final Document document = getTextComponent().getDocument(); document.removeDocumentListener(this); - getDelegate().getView().replaceRange(text, start, end); + getTextComponent().replaceRange(text, start, end); revalidate(); postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED)); document.addDocumentListener(this); diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 5e0d78ef2591d4a906e9c67bb5a52058a7914239..2bf594ece3e0da60e71a5d25d07cadb064624cf3 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -366,8 +366,7 @@ public final class LWCToolkit extends LWToolkit { protected void initializeDesktopProperties() { super.initializeDesktopProperties(); Map fontHints = new HashMap<>(); - fontHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - fontHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + fontHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, fontHints); desktopProperties.put("awt.mouse.numButtons", BUTTONS); diff --git a/src/macosx/native/sun/awt/CFRetainedResource.m b/src/macosx/native/sun/awt/CFRetainedResource.m index 463c6bcc49800d908fdb428c56f48708f9e86317..1371189b83f85f1510e92678a6b288ea3a4939f9 100644 --- a/src/macosx/native/sun/awt/CFRetainedResource.m +++ b/src/macosx/native/sun/awt/CFRetainedResource.m @@ -23,6 +23,7 @@ * questions. */ +#import #import #import "sun_lwawt_macosx_CFRetainedResource.h" @@ -37,7 +38,10 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CFRetainedResource_nativeCFRelease (JNIEnv *env, jclass clazz, jlong ptr, jboolean releaseOnAppKitThread) { if (releaseOnAppKitThread) { - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + // Releasing resources on the main AppKit message loop only + // Releasing resources on the nested loops may cause dangling + // pointers after the nested loop is exited + [NSApp postRunnableEvent:^(){ CFRelease(jlong_to_ptr(ptr)); }]; } else { diff --git a/src/macosx/native/sun/awt/LWCToolkit.m b/src/macosx/native/sun/awt/LWCToolkit.m index 3dd759ad0e38a489cf2e1880aa9afe8fee021a98..b16760b98b50b6deb6f547b7ba6ebe1d0b5b0b91 100644 --- a/src/macosx/native/sun/awt/LWCToolkit.m +++ b/src/macosx/native/sun/awt/LWCToolkit.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -124,61 +124,6 @@ JNF_COCOA_ENTER(env); JNF_COCOA_EXIT(env); } -static JNF_CLASS_CACHE(jc_Component, "java/awt/Component"); -static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;"); -static JNF_CLASS_CACHE(jc_MenuComponent, "java/awt/MenuComponent"); -static JNF_MEMBER_CACHE(jf_MenuComponent_appContext, jc_MenuComponent, "appContext", "Lsun/awt/AppContext;"); - -/* - * Class: sun_awt_SunToolkit - * Method: getAppContext - * Signature: (Ljava/awt/Object;)Lsun/awt/AppContext; - */ -JNIEXPORT jobject JNICALL -Java_sun_awt_SunToolkit_getAppContext -(JNIEnv *env, jclass cls, jobject obj) -{ - jobject appContext = NULL; - -JNF_COCOA_ENTER(env); - - if (JNFIsInstanceOf(env, obj, &jc_Component)) { - appContext = JNFGetObjectField(env, obj, jf_Component_appContext); - } else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) { - appContext = JNFGetObjectField(env, obj, jf_MenuComponent_appContext); - } - -JNF_COCOA_EXIT(env); - - return appContext; -} - -/* - * Class: sun_awt_SunToolkit - * Method: setAppContext - * Signature: (Ljava/lang/Object;Lsun/awt/AppContext;)Z - */ -JNIEXPORT jboolean JNICALL -Java_sun_awt_SunToolkit_setAppContext -(JNIEnv *env, jclass cls, jobject obj, jobject appContext) -{ - jboolean isComponent; - -JNF_COCOA_ENTER(env); - - if (JNFIsInstanceOf(env, obj, &jc_Component)) { - JNFSetObjectField(env, obj, jf_Component_appContext, appContext); - isComponent = JNI_TRUE; - } else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) { - JNFSetObjectField(env, obj, jf_MenuComponent_appContext, appContext); - isComponent = JNI_FALSE; - } - -JNF_COCOA_EXIT(env); - - return isComponent; -} - /* * Class: sun_lwawt_macosx_LWCToolkit * Method: beep @@ -339,8 +284,10 @@ JNF_COCOA_ENTER(env); beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]]; if (processEvents) { //We do not spin a runloop here as date is nil, so does not matter which mode to use + // Processing all events excluding NSApplicationDefined which need to be processed + // on the main loop only (those events are intended for disposing resources) NSEvent *event; - if ((event = [NSApp nextEventMatchingMask:NSAnyEventMask + if ((event = [NSApp nextEventMatchingMask:(NSAnyEventMask & ~NSApplicationDefined) untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]) != nil) { diff --git a/src/macosx/native/sun/font/AWTFont.m b/src/macosx/native/sun/font/AWTFont.m index 0adeff0de06a4e0abc07125f85163447d0ad4906..bfb90ec6a59defb2b2d7a469b8d4a7b4ab547a00 100644 --- a/src/macosx/native/sun/font/AWTFont.m +++ b/src/macosx/native/sun/font/AWTFont.m @@ -35,15 +35,11 @@ #import "AWTStrike.h" #import "CoreTextSupport.h" - -#define DEBUG - @implementation AWTFont -- (id) initWithFont:(NSFont *)font isFakeItalic:(BOOL)isFakeItalic { +- (id) initWithFont:(NSFont *)font { self = [super init]; if (self) { - fIsFakeItalic = isFakeItalic; fFont = [font retain]; fNativeCGFont = CTFontCopyGraphicsFont((CTFontRef)font, NULL); } @@ -72,7 +68,6 @@ + (AWTFont *) awtFontForName:(NSString *)name style:(int)style - isFakeItalic:(BOOL)isFakeItalic { // create font with family & size NSFont *nsFont = [NSFont fontWithName:name size:1.0]; @@ -95,7 +90,7 @@ nsFont = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSBoldFontMask]; } - return [[[AWTFont alloc] initWithFont:nsFont isFakeItalic:isFakeItalic] autorelease]; + return [[[AWTFont alloc] initWithFont:nsFont] autorelease]; } + (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env { @@ -354,7 +349,7 @@ JNF_COCOA_EXIT(env); JNIEXPORT jlong JNICALL Java_sun_font_CFont_createNativeFont (JNIEnv *env, jclass clazz, - jstring nativeFontName, jint style, jboolean isFakeItalic) + jstring nativeFontName, jint style) { AWTFont *awtFont = nil; @@ -362,8 +357,7 @@ JNF_COCOA_ENTER(env); awtFont = [AWTFont awtFontForName:JNFJavaToNSString(env, nativeFontName) - style:style - isFakeItalic:isFakeItalic]; // autoreleased + style:style]; // autoreleased if (awtFont) { CFRetain(awtFont); // GC @@ -374,6 +368,52 @@ JNF_COCOA_EXIT(env); return ptr_to_jlong(awtFont); } +/* + * Class: sun_font_CFont + * Method: getWidthNative + * Signature: (J)F + */ +JNIEXPORT jfloat JNICALL +Java_sun_font_CFont_getWidthNative + (JNIEnv *env, jobject cfont, jlong awtFontPtr) +{ + float widthVal; +JNF_COCOA_ENTER(env); + + AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr); + NSFont* nsFont = awtFont->fFont; + NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor; + NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute]; + NSNumber *width = [fontTraits objectForKey : NSFontWidthTrait]; + widthVal = (float)[width floatValue]; + +JNF_COCOA_EXIT(env); + return (jfloat)widthVal; +} + +/* + * Class: sun_font_CFont + * Method: getWeightNative + * Signature: (J)F + */ +JNIEXPORT jfloat JNICALL +Java_sun_font_CFont_getWeightNative + (JNIEnv *env, jobject cfont, jlong awtFontPtr) +{ + float weightVal; +JNF_COCOA_ENTER(env); + + AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr); + NSFont* nsFont = awtFont->fFont; + NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor; + NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute]; + NSNumber *weight = [fontTraits objectForKey : NSFontWeightTrait]; + weightVal = (float)[weight floatValue]; + +JNF_COCOA_EXIT(env); + return (jfloat)weightVal; +} + /* * Class: sun_font_CFont * Method: disposeNativeFont diff --git a/src/macosx/native/sun/font/AWTStrike.m b/src/macosx/native/sun/font/AWTStrike.m index 490033d81f9e00b853c82d5fc64d199b3c6d6e88..e55a267d5fe076e44b13fe9c38236e37cab51954 100644 --- a/src/macosx/native/sun/font/AWTStrike.m +++ b/src/macosx/native/sun/font/AWTStrike.m @@ -311,21 +311,26 @@ JNF_COCOA_ENTER(env); jlong *glyphInfos = (*env)->GetPrimitiveArrayCritical(env, glyphInfoLongArray, NULL); - if (glyphInfos != NULL) { - jint *rawGlyphCodes = - (*env)->GetPrimitiveArrayCritical(env, glyphCodes, NULL); + jint *rawGlyphCodes = + (*env)->GetPrimitiveArrayCritical(env, glyphCodes, NULL); + @try { + if (rawGlyphCodes != NULL && glyphInfos != NULL) { + CGGlyphImages_GetGlyphImagePtrs(glyphInfos, awtStrike, + rawGlyphCodes, len); + } + } + @finally { if (rawGlyphCodes != NULL) { - CGGlyphImages_GetGlyphImagePtrs(glyphInfos, awtStrike, - rawGlyphCodes, len); - - (*env)->ReleasePrimitiveArrayCritical(env, glyphCodes, - rawGlyphCodes, JNI_ABORT); + (*env)->ReleasePrimitiveArrayCritical(env, glyphCodes, + rawGlyphCodes, JNI_ABORT); + } + if (glyphInfos != NULL) { + // Do not use JNI_COMMIT, as that will not free the buffer copy + // when +ProtectJavaHeap is on. + (*env)->ReleasePrimitiveArrayCritical(env, glyphInfoLongArray, + glyphInfos, 0); } - // Do not use JNI_COMMIT, as that will not free the buffer copy - // when +ProtectJavaHeap is on. - (*env)->ReleasePrimitiveArrayCritical(env, glyphInfoLongArray, - glyphInfos, 0); } JNF_COCOA_EXIT(env); diff --git a/src/macosx/native/sun/font/CGGlyphImages.m b/src/macosx/native/sun/font/CGGlyphImages.m index 1901c1fc5cbd63b272c793e2532d15f7d4844d12..c762fac61a37211d5b969da740ac3b548a82a0a0 100644 --- a/src/macosx/native/sun/font/CGGlyphImages.m +++ b/src/macosx/native/sun/font/CGGlyphImages.m @@ -195,19 +195,41 @@ DUMP_GLYPHINFO(const GlyphInfo *info) #pragma mark --- Font Rendering Mode Descriptors --- +static Int32 reverseGamma = 0; + +static UInt8 reverseGammaLut[256] = { 0 }; + +static inline UInt8* getReverseGammaLut() { + if (reverseGamma == 0) { + // initialize gamma lut + double gamma; + int i; + const char* pGammaEnv = getenv("J2D_LCD_REVERSE_GAMMA"); + if (pGammaEnv != NULL) { + reverseGamma = atol(pGammaEnv); + } + + if (reverseGamma < 100 || reverseGamma > 250) { + reverseGamma = 180; + } + + gamma = 100.0 / reverseGamma; + for (i = 0; i < 256; i++) { + double x = ((double)i) / 255.0; + reverseGammaLut[i] = (UInt8)(255 * pow(x, gamma)); + } + } + return reverseGammaLut; +} static inline void CGGI_CopyARGBPixelToRGBPixel(const UInt32 p, UInt8 *dst) { -#if __LITTLE_ENDIAN__ - *(dst + 2) = 0xFF - (p >> 24 & 0xFF); - *(dst + 1) = 0xFF - (p >> 16 & 0xFF); - *(dst) = 0xFF - (p >> 8 & 0xFF); -#else - *(dst) = 0xFF - (p >> 16 & 0xFF); - *(dst + 1) = 0xFF - (p >> 8 & 0xFF); - *(dst + 2) = 0xFF - (p & 0xFF); -#endif + UInt8* lut = getReverseGammaLut(); + + *(dst + 0) = lut[0xFF - (p >> 16 & 0xFF)]; // red + *(dst + 1) = lut[0xFF - (p >> 8 & 0xFF)]; // green + *(dst + 2) = lut[0xFF - (p & 0xFF)]; // blue } static void @@ -222,17 +244,14 @@ CGGI_CopyImageFromCanvasToRGBInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info) size_t height = info->height; size_t y; + + // fill empty glyph image with black-on-white glyph for (y = 0; y < height; y++) { size_t destRow = y * destRowWidth * 3; size_t srcRow = y * srcRowWidth; size_t x; for (x = 0; x < destRowWidth; x++) { - // size_t x3 = x * 3; - // UInt32 p = src[srcRow + x]; - // dest[destRow + x3] = 0xFF - (p >> 16 & 0xFF); - // dest[destRow + x3 + 1] = 0xFF - (p >> 8 & 0xFF); - // dest[destRow + x3 + 2] = 0xFF - (p & 0xFF); CGGI_CopyARGBPixelToRGBPixel(src[srcRow + x], dest + destRow + x * 3); } @@ -260,13 +279,9 @@ CGGI_CopyImageFromCanvasToRGBInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info) //} static inline UInt8 -CGGI_ConvertPixelToGreyBit(UInt32 p) +CGGI_ConvertBWPixelToByteGray(UInt32 p) { -#ifdef __LITTLE_ENDIAN__ - return 0xFF - ((p >> 24 & 0xFF) + (p >> 16 & 0xFF) + (p >> 8 & 0xFF)) / 3; -#else - return 0xFF - ((p >> 16 & 0xFF) + (p >> 8 & 0xFF) + (p & 0xFF)) / 3; -#endif + return 0xFF - (((p >> 24 & 0xFF) + (p >> 16 & 0xFF) + (p >> 8 & 0xFF)) / 3); } static void @@ -281,14 +296,15 @@ CGGI_CopyImageFromCanvasToAlphaInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info) size_t height = info->height; size_t y; + + // fill empty glyph image with black-on-white glyph for (y = 0; y < height; y++) { size_t destRow = y * destRowWidth; size_t srcRow = y * srcRowWidth; - size_t x; for (x = 0; x < destRowWidth; x++) { UInt32 p = src[srcRow + x]; - dest[destRow + x] = CGGI_ConvertPixelToGreyBit(p); + dest[destRow + x] = CGGI_ConvertBWPixelToByteGray(p); } } } @@ -316,13 +332,11 @@ CGGI_GetRenderingMode(const AWTStrike *strike) { CGGI_RenderingMode mode; mode.cgFontMode = strike->fStyle; + NSException *e = nil; switch (strike->fAAStyle) { - case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_DEFAULT: case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_OFF: case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_ON: - case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_GASP: - default: mode.glyphDescriptor = &grey; break; case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_HRGB: @@ -331,6 +345,17 @@ CGGI_GetRenderingMode(const AWTStrike *strike) case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_VBGR: mode.glyphDescriptor = &rgb; break; + case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_GASP: + case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_DEFAULT: + default: + /* we expect that text antialiasing hint has been already + * evaluated. Report an error if we get 'unevaluated' hint here. + */ + e = [NSException + exceptionWithName:@"IllegalArgumentException" + reason:@"Invalid hint value" + userInfo:nil]; + @throw e; } return mode; @@ -345,7 +370,8 @@ CGGI_GetRenderingMode(const AWTStrike *strike) */ static inline void CGGI_InitCanvas(CGGI_GlyphCanvas *canvas, - const vImagePixelCount width, const vImagePixelCount height) + const vImagePixelCount width, const vImagePixelCount height, + const CGGI_RenderingMode* mode) { // our canvas is *always* 4-byte ARGB size_t bytesPerRow = width * sizeof(UInt32); @@ -356,19 +382,26 @@ CGGI_InitCanvas(CGGI_GlyphCanvas *canvas, canvas->image->height = height; canvas->image->rowBytes = bytesPerRow; - canvas->image->data = (void *)calloc(byteCount, sizeof(UInt32)); + canvas->image->data = (void *)calloc(byteCount, sizeof(UInt8)); if (canvas->image->data == NULL) { [[NSException exceptionWithName:NSMallocException reason:@"Failed to allocate memory for the buffer which backs the CGContext for glyph strikes." userInfo:nil] raise]; } - CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + uint32_t bmpInfo = kCGImageAlphaPremultipliedFirst; + if (mode->glyphDescriptor == &rgb) { + bmpInfo |= kCGBitmapByteOrder32Host; + } + + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); canvas->context = CGBitmapContextCreate(canvas->image->data, width, height, 8, bytesPerRow, colorSpace, - kCGImageAlphaPremultipliedFirst); + bmpInfo); + // set foreground color CGContextSetRGBFillColor(canvas->context, 0.0f, 0.0f, 0.0f, 1.0f); + CGContextSetFontSize(canvas->context, 1); CGContextSaveGState(canvas->context); @@ -404,7 +437,9 @@ CGGI_FreeCanvas(CGGI_GlyphCanvas *canvas) * Quick and easy inline to check if this canvas is big enough. */ static inline void -CGGI_SizeCanvas(CGGI_GlyphCanvas *canvas, const vImagePixelCount width, const vImagePixelCount height, const JRSFontRenderingStyle style) +CGGI_SizeCanvas(CGGI_GlyphCanvas *canvas, const vImagePixelCount width, + const vImagePixelCount height, + const CGGI_RenderingMode* mode) { if (canvas->image != NULL && width < canvas->image->width && @@ -418,8 +453,9 @@ CGGI_SizeCanvas(CGGI_GlyphCanvas *canvas, const vImagePixelCount width, const vI CGGI_FreeCanvas(canvas); CGGI_InitCanvas(canvas, width * CGGI_GLYPH_CANVAS_SLACK, - height * CGGI_GLYPH_CANVAS_SLACK); - JRSFontSetRenderingStyleOnContext(canvas->context, style); + height * CGGI_GLYPH_CANVAS_SLACK, + mode); + JRSFontSetRenderingStyleOnContext(canvas->context, mode->cgFontMode); } /* @@ -443,6 +479,7 @@ CGGI_ClearCanvas(CGGI_GlyphCanvas *canvas, GlyphInfo *info) Pixel_8888 opaqueWhite = { 0xFF, 0xFF, 0xFF, 0xFF }; #endif + // clear canvas background and set foreground color vImageBufferFill_ARGB8888(&canvasRectToClear, opaqueWhite, kvImageNoFlags); } @@ -577,7 +614,7 @@ CGGI_CreateImageForUnicode GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode); // fix the context size, just in case the substituted character is unexpectedly large - CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode); + CGGI_SizeCanvas(canvas, info->width, info->height, mode); // align the transform for the real CoreText strike CGContextSetTextMatrix(canvas->context, strike->fAltTx); @@ -653,8 +690,11 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas, #endif } -static NSString *threadLocalCanvasKey = - @"Java CoreGraphics Text Renderer Cached Canvas"; +static NSString *threadLocalAACanvasKey = + @"Java CoreGraphics Text Renderer Cached Canvas for AA"; + +static NSString *threadLocalLCDCanvasKey = + @"Java CoreGraphics Text Renderer Cached Canvas for LCD"; /* * This is the maximum length and height times the above slack squared @@ -678,25 +718,28 @@ CGGI_FillImagesForGlyphs(jlong *glyphInfos, const AWTStrike *strike, CGGI_GLYPH_CANVAS_MAX*CGGI_GLYPH_CANVAS_MAX*CGGI_GLYPH_CANVAS_SLACK*CGGI_GLYPH_CANVAS_SLACK) { CGGI_GlyphCanvas *tmpCanvas = [[CGGI_GlyphCanvas alloc] init]; - CGGI_InitCanvas(tmpCanvas, maxWidth, maxHeight); + CGGI_InitCanvas(tmpCanvas, maxWidth, maxHeight, mode); CGGI_FillImagesForGlyphsWithSizedCanvas(tmpCanvas, strike, - mode, glyphInfos, uniChars, - glyphs, len); + mode, glyphInfos, uniChars, + glyphs, len); CGGI_FreeCanvas(tmpCanvas); [tmpCanvas release]; return; } - NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary]; - CGGI_GlyphCanvas *canvas = [threadDict objectForKey:threadLocalCanvasKey]; + + NSString* theKey = (mode->glyphDescriptor == &rgb) ? + threadLocalLCDCanvasKey : threadLocalAACanvasKey; + + CGGI_GlyphCanvas *canvas = [threadDict objectForKey:theKey]; if (canvas == nil) { canvas = [[CGGI_GlyphCanvas alloc] init]; - [threadDict setObject:canvas forKey:threadLocalCanvasKey]; + [threadDict setObject:canvas forKey:theKey]; } - CGGI_SizeCanvas(canvas, maxWidth, maxHeight, mode->cgFontMode); + CGGI_SizeCanvas(canvas, maxWidth, maxHeight, mode); CGGI_FillImagesForGlyphsWithSizedCanvas(canvas, strike, mode, glyphInfos, uniChars, glyphs, len); } diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.h b/src/macosx/native/sun/osxapp/NSApplicationAWT.h index 9269295060861858e16d99a7985e2f2d789cf24b..99c7d63175a25b25712c5d57bcad3b0b2493b121 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.h +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h @@ -37,6 +37,7 @@ - (void) registerWithProcessManager; - (void) setDockIconWithEnv:(JNIEnv *)env; - (void) postDummyEvent; +- (void) postRunnableEvent:(void (^)())block; - (void) waitForDummyEvent; + (void) runAWTLoopWithApp:(NSApplication*)app; diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.m b/src/macosx/native/sun/osxapp/NSApplicationAWT.m index b55f1b76c21a7fd051f249c931559158c3094a72..5df99a4b8cd6721ae3ccddb3a69ec2f3a33c2cbc 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.m +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m @@ -338,9 +338,13 @@ AWT_ASSERT_APPKIT_THREAD; - (void)sendEvent:(NSEvent *)event { - if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp)) { + if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp) && [event subtype] == 0) { [seenDummyEventLock lockWhenCondition:NO]; [seenDummyEventLock unlockWithCondition:YES]; + } else if ([event type] == NSApplicationDefined && [event subtype] == 777) { + void (^block)() = (void (^)()) [event data1]; + block(); + [block release]; } else if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) { // Cocoa won't send us key up event when releasing a key while Cmd is down, // so we have to do it ourselves. @@ -350,6 +354,33 @@ AWT_ASSERT_APPKIT_THREAD; } } +/* + * Posts the block to the AppKit event queue which will be executed + * on the main AppKit loop. + * While running nested loops this event will be ignored. + */ +- (void)postRunnableEvent:(void (^)())block +{ + void (^copy)() = [block copy]; + NSInteger encode = (NSInteger) copy; + [copy retain]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined + location: NSMakePoint(0,0) + modifierFlags: 0 + timestamp: 0 + windowNumber: 0 + context: nil + subtype: 777 + data1: encode + data2: 0]; + + [NSApp postEvent: event atStart: NO]; + [pool drain]; +} + + + - (void)postDummyEvent { seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO]; dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime; diff --git a/src/share/classes/com/sun/jndi/ldap/Connection.java b/src/share/classes/com/sun/jndi/ldap/Connection.java index 359fd78286c3765c4512fdc9cb58757162b7baac..d9881248101312859c959b8672e87a874ca1b3a3 100644 --- a/src/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java @@ -439,9 +439,14 @@ public final class Connection implements Runnable { BerDecoder readReply(LdapRequest ldr) throws IOException, NamingException { BerDecoder rber; - boolean waited = false; - while (((rber = ldr.getReplyBer()) == null) && !waited) { + // Track down elapsed time to workaround spurious wakeups + long elapsedMilli = 0; + long elapsedNano = 0; + + while (((rber = ldr.getReplyBer()) == null) && + (readTimeout <= 0 || elapsedMilli < readTimeout)) + { try { // If socket closed, don't even try synchronized (this) { @@ -455,11 +460,15 @@ public final class Connection implements Runnable { rber = ldr.getReplyBer(); if (rber == null) { if (readTimeout > 0) { // Socket read timeout is specified + long beginNano = System.nanoTime(); - // will be woken up before readTimeout only if reply is + // will be woken up before readTimeout if reply is // available - ldr.wait(readTimeout); - waited = true; + ldr.wait(readTimeout - elapsedMilli); + elapsedNano += (System.nanoTime() - beginNano); + elapsedMilli += elapsedNano / 1000_000; + elapsedNano %= 1000_000; + } else { // no timeout is set so we wait infinitely until // a response is received @@ -476,7 +485,7 @@ public final class Connection implements Runnable { } } - if ((rber == null) && waited) { + if ((rber == null) && (elapsedMilli >= readTimeout)) { abandonRequest(ldr, null); throw new NamingException("LDAP response read timed out, timeout used:" + readTimeout + "ms." ); diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index c77c5f2efa237daec93aaa790d6b1fe966a30976..e826787316f91062b7093c630a7028c3f8b4bbbd 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -1301,6 +1301,25 @@ public abstract class Component implements ImageObserver, MenuContainer, return visible && (parent == null || parent.isRecursivelyVisible()); } + /** + * Determines the bounds of a visible part of the component relative to its + * parent. + * + * @return the visible part of bounds + */ + private Rectangle getRecursivelyVisibleBounds() { + final Component container = getContainer(); + final Rectangle bounds = getBounds(); + if (container == null) { + // we are top level window or haven't a container, return our bounds + return bounds; + } + // translate the container's bounds to our coordinate space + final Rectangle parentsBounds = container.getRecursivelyVisibleBounds(); + parentsBounds.setLocation(0, 0); + return parentsBounds.intersection(bounds); + } + /** * Translates absolute coordinates into coordinates in the coordinate * space of this component. @@ -1473,7 +1492,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ComponentPeer peer = this.peer; if (peer != null) { peer.setEnabled(true); - if (visible) { + if (visible && !getRecursivelyVisibleBounds().isEmpty()) { updateCursorImmediately(); } } @@ -1522,7 +1541,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ComponentPeer peer = this.peer; if (peer != null) { peer.setEnabled(false); - if (visible) { + if (visible && !getRecursivelyVisibleBounds().isEmpty()) { updateCursorImmediately(); } } diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index ee8ba9114f7f524623dde1c4df52b52539555652..47e580bc1ae5f816e1342592cb21fa5a82367109 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -44,6 +44,7 @@ import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.security.AccessController; +import java.util.ArrayList; import java.util.EventListener; import java.util.HashSet; import java.util.Set; @@ -100,7 +101,7 @@ public class Container extends Component { * @see #add * @see #getComponents */ - private java.util.List component = new java.util.ArrayList(); + private java.util.List component = new ArrayList<>(); /** * Layout manager for this container. @@ -2545,28 +2546,24 @@ public class Container extends Component { if (!contains(x, y)) { return null; } + Component lightweight = null; synchronized (getTreeLock()) { - // Two passes: see comment in sun.awt.SunGraphicsCallback - for (int i = 0; i < component.size(); i++) { - Component comp = component.get(i); - if (comp != null && - !(comp.peer instanceof LightweightPeer)) { - if (comp.contains(x - comp.x, y - comp.y)) { + // Optimized version of two passes: + // see comment in sun.awt.SunGraphicsCallback + for (final Component comp : component) { + if (comp.contains(x - comp.x, y - comp.y)) { + if (!comp.isLightweight()) { + // return heavyweight component as soon as possible return comp; } - } - } - for (int i = 0; i < component.size(); i++) { - Component comp = component.get(i); - if (comp != null && - comp.peer instanceof LightweightPeer) { - if (comp.contains(x - comp.x, y - comp.y)) { - return comp; + if (lightweight == null) { + // save and return later the first lightweight component + lightweight = comp; } } } } - return this; + return lightweight != null ? lightweight : this; } /** @@ -2670,52 +2667,54 @@ public class Container extends Component { return null; } - final Component findComponentAtImpl(int x, int y, boolean ignoreEnabled){ - checkTreeLock(); + final Component findComponentAtImpl(int x, int y, boolean ignoreEnabled) { + // checkTreeLock(); commented for a performance reason if (!(contains(x, y) && visible && (ignoreEnabled || enabled))) { return null; } - - // Two passes: see comment in sun.awt.SunGraphicsCallback - for (int i = 0; i < component.size(); i++) { - Component comp = component.get(i); - if (comp != null && - !(comp.peer instanceof LightweightPeer)) { - if (comp instanceof Container) { - comp = ((Container)comp).findComponentAtImpl(x - comp.x, - y - comp.y, - ignoreEnabled); - } else { - comp = comp.getComponentAt(x - comp.x, y - comp.y); - } - if (comp != null && comp.visible && - (ignoreEnabled || comp.enabled)) - { - return comp; - } + Component lightweight = null; + // Optimized version of two passes: + // see comment in sun.awt.SunGraphicsCallback + for (final Component comp : component) { + final int x1 = x - comp.x; + final int y1 = y - comp.y; + if (!comp.contains(x1, y1)) { + continue; // fast path } - } - for (int i = 0; i < component.size(); i++) { - Component comp = component.get(i); - if (comp != null && - comp.peer instanceof LightweightPeer) { - if (comp instanceof Container) { - comp = ((Container)comp).findComponentAtImpl(x - comp.x, - y - comp.y, - ignoreEnabled); - } else { - comp = comp.getComponentAt(x - comp.x, y - comp.y); + if (!comp.isLightweight()) { + final Component child = getChildAt(comp, x1, y1, ignoreEnabled); + if (child != null) { + // return heavyweight component as soon as possible + return child; } - if (comp != null && comp.visible && - (ignoreEnabled || comp.enabled)) - { - return comp; + } else { + if (lightweight == null) { + // save and return later the first lightweight component + lightweight = getChildAt(comp, x1, y1, ignoreEnabled); } } } + return lightweight != null ? lightweight : this; + } - return this; + /** + * Helper method for findComponentAtImpl. Finds a child component using + * findComponentAtImpl for Container and getComponentAt for Component. + */ + private static Component getChildAt(Component comp, int x, int y, + boolean ignoreEnabled) { + if (comp instanceof Container) { + comp = ((Container) comp).findComponentAtImpl(x, y, + ignoreEnabled); + } else { + comp = comp.getComponentAt(x, y); + } + if (comp != null && comp.visible && + (ignoreEnabled || comp.enabled)) { + return comp; + } + return null; } /** @@ -4402,6 +4401,18 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.LightweightDispatcher"); + private static final int BUTTONS_DOWN_MASK; + + static { + int[] buttonsDownMask = AWTAccessor.getInputEventAccessor(). + getButtonDownMasks(); + int mask = 0; + for (int buttonDownMask : buttonsDownMask) { + mask |= buttonDownMask; + } + BUTTONS_DOWN_MASK = mask; + } + LightweightDispatcher(Container nativeContainer) { this.nativeContainer = nativeContainer; mouseEventTarget = new WeakReference<>(null); @@ -4470,25 +4481,12 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { private boolean isMouseGrab(MouseEvent e) { int modifiers = e.getModifiersEx(); - if(e.getID() == MouseEvent.MOUSE_PRESSED - || e.getID() == MouseEvent.MOUSE_RELEASED) - { - switch (e.getButton()) { - case MouseEvent.BUTTON1: - modifiers ^= InputEvent.BUTTON1_DOWN_MASK; - break; - case MouseEvent.BUTTON2: - modifiers ^= InputEvent.BUTTON2_DOWN_MASK; - break; - case MouseEvent.BUTTON3: - modifiers ^= InputEvent.BUTTON3_DOWN_MASK; - break; - } + if (e.getID() == MouseEvent.MOUSE_PRESSED + || e.getID() == MouseEvent.MOUSE_RELEASED) { + modifiers ^= InputEvent.getMaskForButton(e.getButton()); } /* modifiers now as just before event */ - return ((modifiers & (InputEvent.BUTTON1_DOWN_MASK - | InputEvent.BUTTON2_DOWN_MASK - | InputEvent.BUTTON3_DOWN_MASK)) != 0); + return ((modifiers & BUTTONS_DOWN_MASK) != 0); } /** diff --git a/src/share/classes/java/awt/ScrollPane.java b/src/share/classes/java/awt/ScrollPane.java index 70ca48f4d7498c6012861de1cedab8237f62a9c2..8952b77fc6a9e725feae58281e130d951b09c030 100644 --- a/src/share/classes/java/awt/ScrollPane.java +++ b/src/share/classes/java/awt/ScrollPane.java @@ -496,9 +496,8 @@ public class ScrollPane extends Container implements Accessible { Point p = getScrollPosition(); Dimension cs = calculateChildSize(); Dimension vs = getViewportSize(); - Insets i = getInsets(); - c.reshape(i.left - p.x, i.top - p.y, cs.width, cs.height); + c.reshape(- p.x, - p.y, cs.width, cs.height); ScrollPanePeer peer = (ScrollPanePeer)this.peer; if (peer != null) { peer.childResized(cs.width, cs.height); diff --git a/src/share/classes/java/security/ProtectionDomain.java b/src/share/classes/java/security/ProtectionDomain.java index 5a5ed352e885a0c130f887336af6038d0e25b2be..b1778490f5a6dacc18e2250ff5e9999472bf5f7c 100644 --- a/src/share/classes/java/security/ProtectionDomain.java +++ b/src/share/classes/java/security/ProtectionDomain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -25,7 +25,6 @@ package java.security; -import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -457,37 +456,24 @@ public class ProtectionDomain { /** * Used for storing ProtectionDomains as keys in a Map. */ - final static class Key {} - - // A cache of ProtectionDomains and their Permissions - private static class PDCache implements ProtectionDomainCache { - // We must wrap the PermissionCollection in a WeakReference as there - // are some PermissionCollections which contain strong references - // back to a ProtectionDomain and otherwise would never be removed - // from the WeakHashMap - private final Map> - map = new WeakHashMap<>(); - - @Override - public synchronized void put(ProtectionDomain pd, - PermissionCollection pc) { - map.put(pd == null ? null : pd.key, new WeakReference<>(pc)); - } - - @Override - public synchronized PermissionCollection get(ProtectionDomain pd) { - WeakReference ref = - map.get(pd == null ? null : pd.key); - return ref == null ? null : ref.get(); - } - } + final class Key {} static { SharedSecrets.setJavaSecurityProtectionDomainAccess( new JavaSecurityProtectionDomainAccess() { - @Override public ProtectionDomainCache getProtectionDomainCache() { - return new PDCache(); + return new ProtectionDomainCache() { + private final Map map = + Collections.synchronizedMap + (new WeakHashMap()); + public void put(ProtectionDomain pd, + PermissionCollection pc) { + map.put((pd == null ? null : pd.key), pc); + } + public PermissionCollection get(ProtectionDomain pd) { + return pd == null ? map.get(null) : map.get(pd.key); + } + }; } }); } diff --git a/src/share/classes/javax/sql/rowset/BaseRowSet.java b/src/share/classes/javax/sql/rowset/BaseRowSet.java index 8fcfbbf612d8f6cef59019af2f1c3223dfc09e45..0c1825aca0d901bcd56bac62e6b0fe86986c8272 100644 --- a/src/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/src/share/classes/javax/sql/rowset/BaseRowSet.java @@ -461,7 +461,7 @@ public abstract class BaseRowSet implements Serializable, Cloneable { * false that it is not. The default is true. * @serial */ - private boolean escapeProcessing; + private boolean escapeProcessing = true; /** * A constant indicating the isolation level of the connection diff --git a/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java b/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java index da1e05785038c0ec3feca1e8db45a15d35c4d5e1..a1230a2da731075cf6be928023fd2f41f740c5a6 100644 --- a/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java +++ b/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -48,6 +48,8 @@ import java.lang.reflect.*; * Therefore, any RowSetMetaDataImpl method that retrieves information * is defined as having unspecified behavior when it is called * before the RowSet object contains data. + * + * @since 1.5 */ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { @@ -579,7 +581,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * * @param columnIndex the first column is 1, the second is 2, and so on; * must be between 1 and the number of columns, inclusive - * @return true if if a value in the designated column is a signed + * @return true if a value in the designated column is a signed * number; false otherwise * @throws SQLException if a database access error occurs * or the given column number is out of bounds @@ -605,7 +607,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { } /** - * Retrieves the the suggested column title for the designated + * Retrieves the suggested column title for the designated * column for use in printouts and displays. * * @param columnIndex the first column is 1, the second is 2, and so on; @@ -801,8 +803,10 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { * @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 @@ -1071,7 +1075,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { public int colType; /** - * The field that holds the the type name used by this particular data source + * The field that holds the type name used by this particular data source * for the value stored in this column. * * @serial @@ -1079,7 +1083,7 @@ public class RowSetMetaDataImpl implements RowSetMetaData, Serializable { public String colTypeName; /** - * The field that holds the updatablity boolean per column of a RowSet + * The field that holds the updatability boolean per column of a RowSet * * @serial */ diff --git a/src/share/classes/javax/sql/rowset/RowSetWarning.java b/src/share/classes/javax/sql/rowset/RowSetWarning.java index c110834c2cffcce372648ba515caa6584865b598..311c74ad8fdb62042c760919810880650881022e 100644 --- a/src/share/classes/javax/sql/rowset/RowSetWarning.java +++ b/src/share/classes/javax/sql/rowset/RowSetWarning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -50,14 +50,11 @@ import java.sql.SQLException; * The inherited methods getMessage, getSQLState, * and getErrorCode retrieve information contained in a * RowSetWarning object. + * + * @since 1.5 */ public class RowSetWarning extends SQLException { - /** - * RowSetWarning object handle. - */ - private RowSetWarning rwarning; - /** * Constructs a RowSetWarning object * with the given value for the reason; SQLState defaults to null, @@ -109,7 +106,7 @@ public class RowSetWarning extends SQLException { * @param reason a String giving a description of the * warning; * @param SQLState an XOPEN code identifying the warning; if a non standard - * XPOEN SQLState is supplied, no exception is thrown. + * XOPEN SQLState is supplied, no exception is thrown. * @param vendorCode a database vendor-specific warning code */ public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) { @@ -126,7 +123,15 @@ public class RowSetWarning extends SQLException { * @see #setNextWarning */ public RowSetWarning getNextWarning() { - return rwarning; + SQLException warning = getNextException(); + if ( warning == null || warning instanceof RowSetWarning) { + return (RowSetWarning)warning; + } else { + // The chained value isn't a RowSetWarning. + // This is a programming error by whoever added it to + // the RowSetWarning chain. We throw a Java "Error". + throw new Error("RowSetWarning chain holds value that is not a RowSetWarning: "); + } } /** @@ -139,7 +144,7 @@ public class RowSetWarning extends SQLException { * @see #getNextWarning */ public void setNextWarning(RowSetWarning warning) { - rwarning = warning; + setNextException(warning); } static final long serialVersionUID = 6678332766434564774L; diff --git a/src/share/classes/javax/swing/JInternalFrame.java b/src/share/classes/javax/swing/JInternalFrame.java index 9783d01398c3caabde65928286c0cff7dab36b19..03bb2bd78885ad81262d528bd785795aaf903448 100644 --- a/src/share/classes/javax/swing/JInternalFrame.java +++ b/src/share/classes/javax/swing/JInternalFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -38,7 +38,6 @@ import javax.accessibility.*; import java.io.ObjectOutputStream; import java.io.IOException; -import java.lang.StringBuilder; import java.beans.PropertyChangeListener; import sun.awt.AppContext; import sun.swing.SwingUtilities2; @@ -1650,7 +1649,7 @@ public class JInternalFrame extends JComponent implements *
DO_NOTHING_ON_CLOSE *
Do nothing. * This requires the program to handle the operation - * in the windowClosing method + * in the internalFrameClosing method * of a registered InternalFrameListener object. *
HIDE_ON_CLOSE *
Automatically make the internal frame invisible. diff --git a/src/share/classes/javax/swing/JSpinner.java b/src/share/classes/javax/swing/JSpinner.java index b079b49553c0654d3cd23fe5bcacfaa34ada6322..de032f289121bef9107a6282ecde72c5cd0be626 100644 --- a/src/share/classes/javax/swing/JSpinner.java +++ b/src/share/classes/javax/swing/JSpinner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, 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 @@ -42,8 +42,6 @@ import java.text.spi.NumberFormatProvider; import javax.accessibility.*; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; -import sun.util.locale.provider.LocaleServiceProviderPool; - /** * A single line input field that lets the user select a @@ -77,12 +75,12 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * try { * spinner.commitEdit(); * } - * catch (ParseException pe) {{ + * catch (ParseException pe) { * // Edited value is invalid, spinner.getValue() will return * // the last valid value, you could revert the spinner to show that: - * JComponent editor = spinner.getEditor() + * JComponent editor = spinner.getEditor(); * if (editor instanceof DefaultEditor) { - * ((DefaultEditor)editor).getTextField().setValue(spinner.getValue(); + * ((DefaultEditor)editor).getTextField().setValue(spinner.getValue()); * } * // reset the value to some known value: * spinner.setValue(fallbackValue); diff --git a/src/share/classes/javax/swing/RepaintManager.java b/src/share/classes/javax/swing/RepaintManager.java index c65c826eb459d1954058442616ac2a2d76ef6af7..9f98050dabc52874d35626641ace410f3b9bc15e 100644 --- a/src/share/classes/javax/swing/RepaintManager.java +++ b/src/share/classes/javax/swing/RepaintManager.java @@ -181,9 +181,16 @@ public class RepaintManager */ private final ProcessingRunnable processingRunnable; - private final static JavaSecurityAccess javaSecurityAccess = - SharedSecrets.getJavaSecurityAccess(); + private static final JavaSecurityAccess javaSecurityAccess = + SharedSecrets.getJavaSecurityAccess(); + /** + * Listener installed to detect display changes. When display changes, + * schedules a callback to notify all RepaintManagers of the display + * changes. + */ + private static final DisplayChangedListener displayChangedHandler = + new DisplayChangedHandler(); static { SwingAccessor.setRepaintManagerAccessor(new SwingAccessor.RepaintManagerAccessor() { @@ -225,8 +232,8 @@ public class RepaintManager GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); if (ge instanceof SunGraphicsEnvironment) { - ((SunGraphicsEnvironment)ge).addDisplayChangedListener( - new DisplayChangedHandler()); + ((SunGraphicsEnvironment) ge).addDisplayChangedListener( + displayChangedHandler); } Toolkit tk = Toolkit.getDefaultToolkit(); if ((tk instanceof SunToolkit) @@ -1649,6 +1656,12 @@ public class RepaintManager */ private static final class DisplayChangedHandler implements DisplayChangedListener { + // Empty non private constructor was added because access to this + // class shouldn't be generated by the compiler using synthetic + // accessor method + DisplayChangedHandler() { + } + public void displayChanged() { scheduleDisplayChanges(); } @@ -1656,11 +1669,10 @@ public class RepaintManager public void paletteChanged() { } - private void scheduleDisplayChanges() { + private static void scheduleDisplayChanges() { // To avoid threading problems, we notify each RepaintManager // on the thread it was created on. - for (Object c : AppContext.getAppContexts()) { - AppContext context = (AppContext) c; + for (AppContext context : AppContext.getAppContexts()) { synchronized(context) { if (!context.isDisposed()) { EventQueue eventQueue = (EventQueue)context.get( diff --git a/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/src/share/classes/sun/awt/datatransfer/DataTransferer.java index 79c2792800fb7d250c0b1dcd8e0da661258d63fc..99e684d9a7b02f62744a03e268d7fbe215081fa9 100644 --- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java +++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java @@ -2905,13 +2905,13 @@ search: return comp; } - if (flavor1.isFlavorTextType()) { - return 1; - } - - if (flavor2.isFlavorTextType()) { - return -1; - } +// if (flavor1.isFlavorTextType()) { +// return 1; +// } +// +// if (flavor2.isFlavorTextType()) { +// return -1; +// } // Next, look for application/x-java-* types. Prefer unknown // MIME types because if the user provides his own data flavor, diff --git a/src/share/classes/sun/font/Font2D.java b/src/share/classes/sun/font/Font2D.java index 903b3804764fcaf5348d7d815aec3dc569a05c79..ae67a30aa854fcaf2e6a56263a48b2f5afe64072 100644 --- a/src/share/classes/sun/font/Font2D.java +++ b/src/share/classes/sun/font/Font2D.java @@ -157,6 +157,21 @@ public abstract class Font2D { } } + public static final int FWIDTH_NORMAL = 5; // OS/2 usWidthClass + public static final int FWEIGHT_NORMAL = 400; // OS/2 usWeightClass + public static final int FWEIGHT_BOLD = 700; // OS/2 usWeightClass + + public int getWidth() { + return FWIDTH_NORMAL; + } + + public int getWeight() { + if ((style & Font.BOLD) !=0) { + return FWEIGHT_BOLD; + } else { + return FWEIGHT_NORMAL; + } + } int getRank() { return fontRank; diff --git a/src/share/classes/sun/font/FontFamily.java b/src/share/classes/sun/font/FontFamily.java index 6a4cd2552f9fee566b088584e822d906a8276e65..31f14254e93038b176c38a43f0f2082cbfd4891c 100644 --- a/src/share/classes/sun/font/FontFamily.java +++ b/src/share/classes/sun/font/FontFamily.java @@ -27,6 +27,7 @@ package sun.font; import java.io.File; import java.awt.Font; +import java.util.Collection; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.Locale; @@ -134,7 +135,104 @@ public class FontFamily { return java.util.Objects.equals(newDir, existDir); } + /* + * We want a family to be of the same width and prefer medium/normal width. + * Once we find a particular width we accept more of the same width + * until we find one closer to normal when we 'evict' all existing fonts. + * So once we see a 'normal' width font we evict all members that are not + * normal width and then accept only new ones that are normal width. + * + * Once a font passes the width test we subject it to the weight test. + * For Plain we target the weight the closest that is <= NORMAL (400) + * For Bold we target the weight that is closest to BOLD (700). + * + * In the future, rather than discarding these fonts, we should + * extend the family to include these so lookups on these properties + * can locate them, as presently they will only be located by full name + * based lookup. + */ + + private int familyWidth = 0; + private boolean preferredWidth(Font2D font) { + + int newWidth = font.getWidth(); + + if (familyWidth == 0) { + familyWidth = newWidth; + return true; + } + + if (newWidth == familyWidth) { + return true; + } + + if (Math.abs(Font2D.FWIDTH_NORMAL - newWidth) < + Math.abs(Font2D.FWIDTH_NORMAL - familyWidth)) + { + if (FontUtilities.debugFonts()) { + FontUtilities.getLogger().info( + "Found more preferred width. New width = " + newWidth + + " Old width = " + familyWidth + " in font " + font + + " nulling out fonts plain: " + plain + " bold: " + bold + + " italic: " + italic + " bolditalic: " + bolditalic); + } + familyWidth = newWidth; + plain = bold = italic = bolditalic = null; + return true; + } else if (FontUtilities.debugFonts()) { + FontUtilities.getLogger().info( + "Family rejecting font " + font + + " of less preferred width " + newWidth); + } + return false; + } + + private boolean closerWeight(Font2D currFont, Font2D font, int style) { + if (familyWidth != font.getWidth()) { + return false; + } + + if (currFont == null) { + return true; + } + + if (FontUtilities.debugFonts()) { + FontUtilities.getLogger().info( + "New weight for style " + style + ". Curr.font=" + currFont + + " New font="+font+" Curr.weight="+ + currFont.getWeight()+ + " New weight="+font.getWeight()); + } + + int newWeight = font.getWeight(); + switch (style) { + case Font.PLAIN: + case Font.ITALIC: + return (newWeight <= Font2D.FWEIGHT_NORMAL && + newWeight > currFont.getWeight()); + + case Font.BOLD: + case Font.BOLD|Font.ITALIC: + return (Math.abs(newWeight - Font2D.FWEIGHT_BOLD) < + Math.abs(currFont.getWeight() - Font2D.FWEIGHT_BOLD)); + + default: + return false; + } + } + public void setFont(Font2D font, int style) { + + if (FontUtilities.isLogging()) { + String msg; + if (font instanceof CompositeFont) { + msg = "Request to add " + font.getFamilyName(null) + + " with style " + style + " to family " + familyName; + } else { + msg = "Request to add " + font + + " with style " + style + " to family " + this; + } + FontUtilities.getLogger().info(msg); + } /* Allow a lower-rank font only if its a file font * from the exact same source as any previous font. */ @@ -152,19 +250,27 @@ public class FontFamily { switch (style) { case Font.PLAIN: - plain = font; + if (preferredWidth(font) && closerWeight(plain, font, style)) { + plain = font; + } break; case Font.BOLD: - bold = font; + if (preferredWidth(font) && closerWeight(bold, font, style)) { + bold = font; + } break; case Font.ITALIC: - italic = font; + if (preferredWidth(font) && closerWeight(italic, font, style)) { + italic = font; + } break; case Font.BOLD|Font.ITALIC: - bolditalic = font; + if (preferredWidth(font) && closerWeight(bolditalic, font, style)) { + bolditalic = font; + } break; default: @@ -316,6 +422,11 @@ public class FontFamily { return allLocaleNames.get(name.toLowerCase()); } + public static FontFamily[] getAllFontFamilies() { + Collection families = familyNameMap.values(); + return families.toArray(new FontFamily[0]); + } + public String toString() { return "Font family: " + familyName + diff --git a/src/share/classes/sun/font/StandardTextSource.java b/src/share/classes/sun/font/StandardTextSource.java index 25f5443882ac46196c1c37d07f137579711061f3..d44ba5eb13dc5bade54568b68e37b5c9aec37746 100644 --- a/src/share/classes/sun/font/StandardTextSource.java +++ b/src/share/classes/sun/font/StandardTextSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, 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 @@ -33,42 +33,43 @@ import java.awt.Font; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; -public class StandardTextSource extends TextSource { - char[] chars; - int start; - int len; - int cstart; - int clen; - int level; // assumed all uniform - int flags; // see GlyphVector.java - Font font; - FontRenderContext frc; - CoreMetrics cm; - - /** - * Create a simple implementation of a TextSource. - * - * Chars is an array containing clen chars in the context, in - * logical order, contiguously starting at cstart. Start and len - * represent that portion of the context representing the true - * source; start, like cstart, is relative to the start of the - * character array. - * - * Level is the bidi level (0-63 for the entire context. Flags is - * the layout flags. Font is the font, frc is the render context, - * and lm is the line metrics for the entire source text, but not - * necessarily the context. - */ - public StandardTextSource(char[] chars, - int start, - int len, - int cstart, - int clen, - int level, - int flags, - Font font, - FontRenderContext frc, - CoreMetrics cm) { +final class StandardTextSource extends TextSource { + + private final char[] chars; + private final int start; + private final int len; + private final int cstart; + private final int clen; + private final int level; // assumed all uniform + private final int flags; // see GlyphVector.java + private final Font font; + private final FontRenderContext frc; + private final CoreMetrics cm; + + /** + * Create a simple implementation of a TextSource. + * + * Chars is an array containing clen chars in the context, in + * logical order, contiguously starting at cstart. Start and len + * represent that portion of the context representing the true + * source; start, like cstart, is relative to the start of the + * character array. + * + * Level is the bidi level (0-63 for the entire context. Flags is + * the layout flags. Font is the font, frc is the render context, + * and lm is the line metrics for the entire source text, but not + * necessarily the context. + */ + StandardTextSource(char[] chars, + int start, + int len, + int cstart, + int clen, + int level, + int flags, + Font font, + FontRenderContext frc, + CoreMetrics cm) { if (chars == null) { throw new IllegalArgumentException("bad chars: null"); } @@ -97,7 +98,7 @@ public class StandardTextSource extends TextSource { throw new IllegalArgumentException("bad frc: null"); } - this.chars = chars.clone(); + this.chars = chars; this.start = start; this.len = len; this.cstart = cstart; @@ -115,40 +116,10 @@ public class StandardTextSource extends TextSource { } } - /** Create a StandardTextSource whose context is coextensive with the source. */ - public StandardTextSource(char[] chars, - int start, - int len, - int level, - int flags, - Font font, - FontRenderContext frc, - CoreMetrics cm) { - this(chars, start, len, start, len, level, flags, font, frc, cm); - } - - /** Create a StandardTextSource whose context and source are coextensive with the entire char array. */ - public StandardTextSource(char[] chars, - int level, - int flags, - Font font, - FontRenderContext frc) { - this(chars, 0, chars.length, 0, chars.length, level, flags, font, frc, null); - } - - /** Create a StandardTextSource whose context and source are all the text in the String. */ - public StandardTextSource(String str, - int level, - int flags, - Font font, - FontRenderContext frc) { - this(str.toCharArray(), 0, str.length(), 0, str.length(), level, flags, font, frc, null); - } - // TextSource API public char[] getChars() { - return chars.clone(); + return chars; } public int getStart() { diff --git a/src/share/classes/sun/font/TextLabelFactory.java b/src/share/classes/sun/font/TextLabelFactory.java index a42b396c0874e0eeb7c20331613f539c31e5787e..1f9ba94159cb6f8f0696199c7ab7855db724797c 100644 --- a/src/share/classes/sun/font/TextLabelFactory.java +++ b/src/share/classes/sun/font/TextLabelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, 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 @@ -48,12 +48,12 @@ import java.text.Bidi; * @see TextLayout */ -public class TextLabelFactory { - private FontRenderContext frc; - private char[] text; - private Bidi bidi; +public final class TextLabelFactory { + private final FontRenderContext frc; + private final char[] text; + private final Bidi bidi; private Bidi lineBidi; - private int flags; + private final int flags; private int lineStart; private int lineLimit; diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java index 2c7593f97047ca768d37df491d3902516e18c9f6..d106edf1e49e0b971607b675955f9418f7515b0a 100644 --- a/src/share/classes/sun/font/TrueTypeFont.java +++ b/src/share/classes/sun/font/TrueTypeFont.java @@ -959,6 +959,18 @@ public class TrueTypeFont extends FileFont { setStyle(getTableBuffer(os_2Tag)); } + private int fontWidth = 0; + @Override + public int getWidth() { + return (fontWidth > 0) ? fontWidth : super.getWidth(); + } + + private int fontWeight = 0; + @Override + public int getWeight() { + return (fontWeight > 0) ? fontWeight : super.getWeight(); + } + /* TrueTypeFont can use the fsSelection fields of OS/2 table * to determine the style. In the unlikely case that doesn't exist, * can use macStyle in the 'head' table but simpler to @@ -974,8 +986,15 @@ public class TrueTypeFont extends FileFont { private static final int fsSelectionBoldBit = 0x00020; private static final int fsSelectionRegularBit = 0x00040; private void setStyle(ByteBuffer os_2Table) { + if (os_2Table == null) { + return; + } + if (os_2Table.capacity() >= 8) { + fontWeight = os_2Table.getChar(4) & 0xffff; + fontWidth = os_2Table.getChar(6) & 0xffff; + } /* fsSelection is unsigned short at buffer offset 62 */ - if (os_2Table == null || os_2Table.capacity() < 64) { + if (os_2Table.capacity() < 64) { super.setStyle(); return; } diff --git a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java index e40ee731a6550ea4ef3f96c808dfa13f37145ff1..5605dc0fee9f2ac44661034e23cd84f82d33cff1 100644 --- a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java +++ b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, 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 @@ -59,6 +59,10 @@ final class OGLBlitLoops { TransformBlit transformBlitIntArgbPreToSurface = new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE); + OGLSurfaceToSwBlit blitSurfaceToIntArgbPre = + new OGLSurfaceToSwBlit(SurfaceType.IntArgbPre, + OGLSurfaceData.PF_INT_ARGB_PRE); + GraphicsPrimitive[] primitives = { // surface->surface ops new OGLSurfaceToSurfaceBlit(), @@ -73,8 +77,7 @@ final class OGLBlitLoops { // surface->sw ops new OGLSurfaceToSwBlit(SurfaceType.IntArgb, OGLSurfaceData.PF_INT_ARGB), - new OGLSurfaceToSwBlit(SurfaceType.IntArgbPre, - OGLSurfaceData.PF_INT_ARGB_PRE), + blitSurfaceToIntArgbPre, // sw->surface ops blitIntArgbPreToSurface, @@ -102,7 +105,14 @@ final class OGLBlitLoops { CompositeType.AnyAlpha, blitIntArgbPreToSurface), - new OGLAnyCompositeBlit(), + new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLSurface, + blitSurfaceToIntArgbPre, + blitSurfaceToIntArgbPre, + blitIntArgbPreToSurface), + new OGLAnyCompositeBlit(SurfaceType.Any, + null, + blitSurfaceToIntArgbPre, + blitIntArgbPreToSurface), new OGLSwToSurfaceScale(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), @@ -869,11 +879,26 @@ final class OGLGeneralTransformedBlit extends TransformBlit { } } +/** + * This general OGLAnyCompositeBlit implementation can convert any source/target + * surface to an intermediate surface using convertsrc/convertdst loops, applies + * necessary composite operation, and then uses convertresult loop to get the + * intermediate surface down to OpenGL. + */ final class OGLAnyCompositeBlit extends Blit { + private WeakReference dstTmp; + private WeakReference srcTmp; + private final Blit convertsrc; + private final Blit convertdst; + private final Blit convertresult; - OGLAnyCompositeBlit() { - super(SurfaceType.Any, CompositeType.Any, OGLSurfaceData.OpenGLSurface); + OGLAnyCompositeBlit(SurfaceType srctype, Blit convertsrc, Blit convertdst, + Blit convertresult) { + super(srctype, CompositeType.Any, OGLSurfaceData.OpenGLSurface); + this.convertsrc = convertsrc; + this.convertdst = convertdst; + this.convertresult = convertresult; } public synchronized void Blit(SurfaceData src, SurfaceData dst, @@ -881,9 +906,20 @@ final class OGLAnyCompositeBlit extends Blit { int sx, int sy, int dx, int dy, int w, int h) { - Blit convertdst = Blit.getFromCache(dst.getSurfaceType(), - CompositeType.SrcNoEa, - SurfaceType.IntArgbPre); + if (convertsrc != null) { + SurfaceData cachedSrc = null; + if (srcTmp != null) { + // use cached intermediate surface, if available + cachedSrc = srcTmp.get(); + } + // convert source to IntArgbPre + src = convertFrom(convertsrc, src, sx, sy, w, h, cachedSrc, + BufferedImage.TYPE_INT_ARGB_PRE); + if (src != cachedSrc) { + // cache the intermediate surface + srcTmp = new WeakReference<>(src); + } + } SurfaceData cachedDst = null; @@ -906,12 +942,8 @@ final class OGLAnyCompositeBlit extends Blit { // cache the intermediate surface dstTmp = new WeakReference(dstBuffer); } - // now blit the buffer back to the destination - convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(), - CompositeType.SrcNoEa, - dst.getSurfaceType()); - convertdst.Blit(dstBuffer, dst, AlphaComposite.Src, - clip, 0, 0, dx, dy, w, h); + convertresult.Blit(dstBuffer, dst, AlphaComposite.Src, clip, 0, 0, dx, + dy, w, h); } } diff --git a/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java b/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java index 4e588b60ac19dc1237ef9630ec2d6047ca351104..a0529bdd76f561f0b789ba6ca2a04ec2d7a8cea8 100644 --- a/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java +++ b/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java @@ -26,6 +26,7 @@ package sun.java2d.opengl; import java.awt.AlphaComposite; +import java.awt.Composite; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.Transparency; @@ -400,8 +401,8 @@ public abstract class OGLSurfaceData extends SurfaceData /** * For now, we can only render LCD text if: * - the fragment shader extension is available, and - * - blending is disabled, and - * - the source color is opaque + * - the source color is opaque, and + * - blending is SrcOverNoEa or disabled * - and the destination is opaque * * Eventually, we could enhance the native OGL text rendering code @@ -411,9 +412,19 @@ public abstract class OGLSurfaceData extends SurfaceData public boolean canRenderLCDText(SunGraphics2D sg2d) { return graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) && - sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && + sg2d.surfaceData.getTransparency() == Transparency.OPAQUE && sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR && - sg2d.surfaceData.getTransparency() == Transparency.OPAQUE; + (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY || + (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA && canHandleComposite(sg2d.composite))); + } + + private boolean canHandleComposite(Composite c) { + if (c instanceof AlphaComposite) { + AlphaComposite ac = (AlphaComposite)c; + + return ac.getRule() == AlphaComposite.SRC_OVER && ac.getAlpha() >= 1f; + } + return false; } public void validatePipe(SunGraphics2D sg2d) { diff --git a/src/share/demo/jfc/Font2DTest/FontPanel.java b/src/share/demo/jfc/Font2DTest/FontPanel.java index 01a956e2968e65c5cff89b79b3c0afd535d2c5d4..a53d56cfd25a92609535a51d203325f76634ad5a 100644 --- a/src/share/demo/jfc/Font2DTest/FontPanel.java +++ b/src/share/demo/jfc/Font2DTest/FontPanel.java @@ -515,6 +515,7 @@ public final class FontPanel extends JPanel implements AdjustmentListener { /// Sets the font, hints, according to the set parameters private void setParams( Graphics2D g2 ) { +System.out.println("USING FONT " + testFont + " "+testFont.getPSName()); g2.setFont( testFont ); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType); g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType); diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c index c1a52fe955e83974859d3bb6b874094c3f5d99fc..1e417cb86fdbf5bd2d616542b98d6bda8205b5e3 100644 --- a/src/share/native/sun/font/freetypeScaler.c +++ b/src/share/native/sun/font/freetypeScaler.c @@ -411,7 +411,6 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( jobject metrics; jfloat ax, ay, dx, dy, bx, by, lx, ly, mx, my; jfloat f0 = 0.0; - FT_Pos bmodifier = 0; FTScalerContext *context = (FTScalerContext*) jlong_to_ptr(pScalerContext); FTScalerInfo *scalerInfo = @@ -444,43 +443,38 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( So, we have to do adust them explicitly and stay consistent with what freetype does to outlines. */ - /* For bolding glyphs are not just widened. Height is also changed - (see ftsynth.c). - - TODO: In vertical direction we could do better job and adjust metrics - proportionally to glyoh shape. */ - if (context->doBold) { - bmodifier = FT_MulFix( - scalerInfo->face->units_per_EM, - scalerInfo->face->size->metrics.y_scale)/24; - } - /**** Note: only some metrics are affected by styling ***/ + /* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657854 */ +#define FT_MulFixFloatShift6(a, b) (((float) (a)) * ((float) (b)) / 65536.0 / 64.0) + + /* + * See FreeType source code: src/base/ftobjs.c ft_recompute_scaled_metrics() + * http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1659 + */ /* ascent */ ax = 0; - ay = -(jfloat) FT26Dot6ToFloat(FT_MulFix( - ((jlong) scalerInfo->face->ascender + bmodifier/2), + ay = -(jfloat) (FT_MulFixFloatShift6( + ((jlong) scalerInfo->face->ascender), (jlong) scalerInfo->face->size->metrics.y_scale)); /* descent */ dx = 0; - dy = -(jfloat) FT26Dot6ToFloat(FT_MulFix( - ((jlong) scalerInfo->face->descender + bmodifier/2), + dy = -(jfloat) (FT_MulFixFloatShift6( + ((jlong) scalerInfo->face->descender), (jlong) scalerInfo->face->size->metrics.y_scale)); /* baseline */ bx = by = 0; /* leading */ lx = 0; - ly = (jfloat) FT26Dot6ToFloat(FT_MulFix( - (jlong) scalerInfo->face->height + bmodifier, + ly = (jfloat) (FT_MulFixFloatShift6( + (jlong) scalerInfo->face->height, (jlong) scalerInfo->face->size->metrics.y_scale)) + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance + - 2*bmodifier + OBLIQUE_MODIFIER(scalerInfo->face->size->metrics.height)); my = 0; diff --git a/src/share/native/sun/java2d/opengl/OGLContext.c b/src/share/native/sun/java2d/opengl/OGLContext.c index af1eb9c1adfd114a4b1f7182e826941d49721f81..dcd17a86fa839767400b95d0a247b766a8d3cc09 100644 --- a/src/share/native/sun/java2d/opengl/OGLContext.c +++ b/src/share/native/sun/java2d/opengl/OGLContext.c @@ -748,7 +748,7 @@ OGLContext_IsLCDShaderSupportAvailable(JNIEnv *env, // finally, check to see if the hardware supports the required number // of texture units j2d_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &maxTexUnits); - if (maxTexUnits < 4) { + if (maxTexUnits < 2) { J2dRlsTraceLn1(J2D_TRACE_INFO, "OGLContext_IsLCDShaderSupportAvailable: not enough tex units (%d)", maxTexUnits); diff --git a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c index f9c8350bd990239f199077f9de3708135866f9fe..015dbae5f13f4bb9442c6d1c0cf8eec9992826d2 100644 --- a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c +++ b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c @@ -94,23 +94,10 @@ static GlyphCacheInfo *glyphCache = NULL; */ static GLhandleARB lcdTextProgram = 0; -/** - * The size of one of the gamma LUT textures in any one dimension along - * the edge, in texels. - */ -#define LUT_EDGE 16 - -/** - * These are the texture object handles for the gamma and inverse gamma - * lookup tables. - */ -static GLuint gammaLutTextureID = 0; -static GLuint invGammaLutTextureID = 0; - /** * This value tracks the previous LCD contrast setting, so if the contrast - * value hasn't changed since the last time the lookup tables were - * generated (not very common), then we can skip updating the tables. + * value hasn't changed since the last time the gamma uniforms were + * updated (not very common), then we can skip updating the unforms. */ static jint lastLCDContrast = -1; @@ -275,12 +262,9 @@ OGLTR_AddToGlyphCache(GlyphInfo *glyph, jboolean rgbOrder) * changes, we will modify the "src_adj" value in OGLTR_UpdateLCDTextColor()). * * The "main" function is executed for each "fragment" (or pixel) in the - * glyph image. We have determined that the pow() function can be quite - * slow and it only operates on scalar values, not vectors as we require. - * So instead we build two 3D textures containing gamma (and inverse gamma) - * lookup tables that allow us to approximate a component-wise pow() function - * with a single 3D texture lookup. This approach is at least 2x faster - * than the equivalent pow() calls. + * glyph image. The pow() routine operates on vectors, gives precise results, + * and provides acceptable level of performance, so we use it to perform + * the gamma adjustment. * * The variables involved in the equation can be expressed as follows: * @@ -299,8 +283,8 @@ static const char *lcdTextShaderSource = "uniform vec3 src_adj;" "uniform sampler2D glyph_tex;" "uniform sampler2D dst_tex;" - "uniform sampler3D invgamma_tex;" - "uniform sampler3D gamma_tex;" + "uniform vec3 gamma;" + "uniform vec3 invgamma;" "" "void main(void)" "{" @@ -312,12 +296,12 @@ static const char *lcdTextShaderSource = " }" // load the RGB value from the corresponding destination pixel " vec3 dst_clr = vec3(texture2D(dst_tex, gl_TexCoord[1].st));" - // gamma adjust the dest color using the invgamma LUT - " vec3 dst_adj = vec3(texture3D(invgamma_tex, dst_clr.stp));" + // gamma adjust the dest color + " vec3 dst_adj = pow(dst_clr.rgb, gamma);" // linearly interpolate the three color values " vec3 result = mix(dst_adj, src_adj, glyph_clr);" // gamma re-adjust the resulting color (alpha is always set to 1.0) - " gl_FragColor = vec4(vec3(texture3D(gamma_tex, result.stp)), 1.0);" + " gl_FragColor = vec4(pow(result.rgb, invgamma), 1.0);" "}"; /** @@ -348,10 +332,6 @@ OGLTR_CreateLCDTextProgram() j2d_glUniform1iARB(loc, 0); // texture unit 0 loc = j2d_glGetUniformLocationARB(lcdTextProgram, "dst_tex"); j2d_glUniform1iARB(loc, 1); // texture unit 1 - loc = j2d_glGetUniformLocationARB(lcdTextProgram, "invgamma_tex"); - j2d_glUniform1iARB(loc, 2); // texture unit 2 - loc = j2d_glGetUniformLocationARB(lcdTextProgram, "gamma_tex"); - j2d_glUniform1iARB(loc, 3); // texture unit 3 // "unuse" the program object; it will be re-bound later as needed j2d_glUseProgramObjectARB(0); @@ -360,108 +340,26 @@ OGLTR_CreateLCDTextProgram() } /** - * Initializes a 3D texture object for use as a three-dimensional gamma - * lookup table. Note that the wrap mode is initialized to GL_LINEAR so - * that the table will interpolate adjacent values when the index falls - * somewhere in between. - */ -static GLuint -OGLTR_InitGammaLutTexture() -{ - GLuint lutTextureID; - - j2d_glGenTextures(1, &lutTextureID); - j2d_glBindTexture(GL_TEXTURE_3D, lutTextureID); - j2d_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - j2d_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - j2d_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - j2d_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - j2d_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - - return lutTextureID; -} - -/** - * Updates the lookup table in the given texture object with the float - * values in the given system memory buffer. Note that we could use - * glTexSubImage3D() when updating the texture after its first - * initialization, but since we're updating the entire table (with - * power-of-two dimensions) and this is a relatively rare event, we'll - * just stick with glTexImage3D(). - */ -static void -OGLTR_UpdateGammaLutTexture(GLuint texID, GLfloat *lut, jint size) -{ - j2d_glBindTexture(GL_TEXTURE_3D, texID); - j2d_glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB8, - size, size, size, 0, GL_RGB, GL_FLOAT, lut); -} - -/** - * (Re)Initializes the gamma lookup table textures. + * (Re)Initializes the gamma related uniforms. * * The given contrast value is an int in the range [100, 250] which we will - * then scale to fit in the range [1.0, 2.5]. We create two LUTs, one - * that essentially calculates pow(x, gamma) and the other calculates - * pow(x, 1/gamma). These values are replicated in all three dimensions, so - * given a single 3D texture coordinate (typically this will be a triplet - * in the form (r,g,b)), the 3D texture lookup will return an RGB triplet: - * - * (pow(r,g), pow(y,g), pow(z,g) - * - * where g is either gamma or 1/gamma, depending on the table. + * then scale to fit in the range [1.0, 2.5]. */ static jboolean OGLTR_UpdateLCDTextContrast(jint contrast) { - double gamma = ((double)contrast) / 100.0; - double ig = gamma; - double g = 1.0 / ig; - GLfloat lut[LUT_EDGE][LUT_EDGE][LUT_EDGE][3]; - GLfloat invlut[LUT_EDGE][LUT_EDGE][LUT_EDGE][3]; - int min = 0; - int max = LUT_EDGE - 1; - int x, y, z; + double g = ((double)contrast) / 100.0; + double ig = 1.0 / g; + GLint loc; J2dTraceLn1(J2D_TRACE_INFO, "OGLTR_UpdateLCDTextContrast: contrast=%d", contrast); - for (z = min; z <= max; z++) { - double zval = ((double)z) / max; - GLfloat gz = (GLfloat)pow(zval, g); - GLfloat igz = (GLfloat)pow(zval, ig); - - for (y = min; y <= max; y++) { - double yval = ((double)y) / max; - GLfloat gy = (GLfloat)pow(yval, g); - GLfloat igy = (GLfloat)pow(yval, ig); + loc = j2d_glGetUniformLocationARB(lcdTextProgram, "gamma"); + j2d_glUniform3fARB(loc, g, g, g); - for (x = min; x <= max; x++) { - double xval = ((double)x) / max; - GLfloat gx = (GLfloat)pow(xval, g); - GLfloat igx = (GLfloat)pow(xval, ig); - - lut[z][y][x][0] = gx; - lut[z][y][x][1] = gy; - lut[z][y][x][2] = gz; - - invlut[z][y][x][0] = igx; - invlut[z][y][x][1] = igy; - invlut[z][y][x][2] = igz; - } - } - } - - if (gammaLutTextureID == 0) { - gammaLutTextureID = OGLTR_InitGammaLutTexture(); - } - OGLTR_UpdateGammaLutTexture(gammaLutTextureID, (GLfloat *)lut, LUT_EDGE); - - if (invGammaLutTextureID == 0) { - invGammaLutTextureID = OGLTR_InitGammaLutTexture(); - } - OGLTR_UpdateGammaLutTexture(invGammaLutTextureID, - (GLfloat *)invlut, LUT_EDGE); + loc = j2d_glGetUniformLocationARB(lcdTextProgram, "invgamma"); + j2d_glUniform3fARB(loc, ig, ig, ig); return JNI_TRUE; } @@ -562,14 +460,6 @@ OGLTR_EnableLCDGlyphModeState(GLuint glyphTextureID, jint contrast) return JNI_FALSE; } - // bind the gamma LUT textures - j2d_glActiveTextureARB(GL_TEXTURE2_ARB); - j2d_glBindTexture(GL_TEXTURE_3D, invGammaLutTextureID); - j2d_glEnable(GL_TEXTURE_3D); - j2d_glActiveTextureARB(GL_TEXTURE3_ARB); - j2d_glBindTexture(GL_TEXTURE_3D, gammaLutTextureID); - j2d_glEnable(GL_TEXTURE_3D); - return JNI_TRUE; } @@ -629,10 +519,6 @@ OGLTR_DisableGlyphModeState() j2d_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 4); j2d_glUseProgramObjectARB(0); - j2d_glActiveTextureARB(GL_TEXTURE3_ARB); - j2d_glDisable(GL_TEXTURE_3D); - j2d_glActiveTextureARB(GL_TEXTURE2_ARB); - j2d_glDisable(GL_TEXTURE_3D); j2d_glActiveTextureARB(GL_TEXTURE1_ARB); j2d_glDisable(GL_TEXTURE_2D); j2d_glActiveTextureARB(GL_TEXTURE0_ARB); diff --git a/src/solaris/classes/sun/awt/X11/XClipboard.java b/src/solaris/classes/sun/awt/X11/XClipboard.java index 0bad274f5e2ccc4cec61cb1a9f4419023f3ef8cb..08b006b1e68ad726aa2405ad02e532eb055a6ca0 100644 --- a/src/solaris/classes/sun/awt/X11/XClipboard.java +++ b/src/solaris/classes/sun/awt/X11/XClipboard.java @@ -156,19 +156,29 @@ public final class XClipboard extends SunClipboard implements OwnershipListener isSelectionNotifyProcessed = true; boolean mustSchedule = false; - synchronized (XClipboard.classLock) { - if (targetsAtom2Clipboard == null) { - targetsAtom2Clipboard = new HashMap(2); + XToolkit.awtLock(); + try { + synchronized (XClipboard.classLock) { + try { + Thread.sleep(70); + } catch (InterruptedException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + if (targetsAtom2Clipboard == null) { + targetsAtom2Clipboard = new HashMap(2); + } + mustSchedule = targetsAtom2Clipboard.isEmpty(); + targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this); + if (mustSchedule) { + XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), + new SelectionNotifyHandler()); + } } - mustSchedule = targetsAtom2Clipboard.isEmpty(); - targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this); if (mustSchedule) { - XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), - new SelectionNotifyHandler()); + XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval()); } - } - if (mustSchedule) { - XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval()); + } finally { + XToolkit.awtUnlock(); } } diff --git a/src/solaris/classes/sun/awt/X11/XRootWindow.java b/src/solaris/classes/sun/awt/X11/XRootWindow.java index 6b8b1620da28aa548023eae50262e09f41794033..bd77b61f7aa249e650697077286850948ae417bb 100644 --- a/src/solaris/classes/sun/awt/X11/XRootWindow.java +++ b/src/solaris/classes/sun/awt/X11/XRootWindow.java @@ -31,18 +31,22 @@ package sun.awt.X11; * common logical ancestor */ class XRootWindow extends XBaseWindow { - private static XRootWindow xawtRootWindow = null; - static XRootWindow getInstance() { - XToolkit.awtLock(); - try { - if (xawtRootWindow == null) { + private static class LazyHolder { + private static final XRootWindow xawtRootWindow; + + static { + XToolkit.awtLock(); + try { xawtRootWindow = new XRootWindow(); xawtRootWindow.init(xawtRootWindow.getDelayedParams().delete(DELAYED)); + } finally { + XToolkit.awtUnlock(); } - return xawtRootWindow; - } finally { - XToolkit.awtUnlock(); } + + } + static XRootWindow getInstance() { + return LazyHolder.xawtRootWindow; } private XRootWindow() { diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java index f8673f81c6e32336df61c9e8d9267bb752d0abcf..655679ef0b67a29c883edd0449a98bc444d34ec6 100644 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -598,14 +598,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } } } - if( keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { - keyEventLog.fine("before XFilterEvent:"+ev); + if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && ( + ev.get_type() == XConstants.KeyPress + || ev.get_type() == XConstants.KeyRelease)) { + keyEventLog.fine("before XFilterEvent:" + ev); } if (XlibWrapper.XFilterEvent(ev.getPData(), w)) { continue; } - if( keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) { - keyEventLog.fine("after XFilterEvent:"+ev); // IS THIS CORRECT? + if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && ( + ev.get_type() == XConstants.KeyPress + || ev.get_type() == XConstants.KeyRelease)) { + keyEventLog.fine( + "after XFilterEvent:" + ev); // IS THIS CORRECT? } dispatchEvent(ev); @@ -621,21 +626,28 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } } + /** + * Listener installed to detect display changes. + */ + private static final DisplayChangedListener displayChangedHandler = + new DisplayChangedListener() { + @Override + public void displayChanged() { + // 7045370: Reset the cached values + XToolkit.screenWidth = -1; + XToolkit.screenHeight = -1; + } + + @Override + public void paletteChanged() { + } + }; + static { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (ge instanceof SunGraphicsEnvironment) { - ((SunGraphicsEnvironment)ge).addDisplayChangedListener( - new DisplayChangedListener() { - @Override - public void displayChanged() { - // 7045370: Reset the cached values - XToolkit.screenWidth = -1; - XToolkit.screenHeight = -1; - } - - @Override - public void paletteChanged() {} - }); + ((SunGraphicsEnvironment) ge).addDisplayChangedListener( + displayChangedHandler); } } @@ -645,7 +657,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable { try { XWindowAttributes pattr = new XWindowAttributes(); try { - XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData); + XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), + XToolkit.getDefaultRootWindow(), + pattr.pData); screenWidth = (int) pattr.get_width(); screenHeight = (int) pattr.get_height(); } finally { diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp index 6ac3c5f603bf86ca2a02486e89c2f97f33819727..2c25e975d39e5e95fd2d997c87f80eaff9c8282a 100644 --- a/src/windows/native/sun/windows/awt_Frame.cpp +++ b/src/windows/native/sun/windows/awt_Frame.cpp @@ -1864,6 +1864,7 @@ Java_sun_awt_windows_WEmbeddedFrame_initIDs(JNIEnv *env, jclass cls) AwtFrame::activateEmbeddingTopLevelMID = env->GetMethodID(cls, "activateEmbeddingTopLevel", "()V"); DASSERT(AwtFrame::activateEmbeddingTopLevelMID != NULL); + CHECK_NULL(AwtFrame::activateEmbeddingTopLevelMID); AwtFrame::isEmbeddedInIEID = env->GetFieldID(cls, "isEmbeddedInIE", "Z"); DASSERT(AwtFrame::isEmbeddedInIEID != NULL); diff --git a/test/TEST.groups b/test/TEST.groups index a70c50908b6ca56ea9a1ea5c43073716ba5f4772..be800ee054bf8cc0a4cc6fe472b71c26ed6692d7 100644 --- a/test/TEST.groups +++ b/test/TEST.groups @@ -484,6 +484,10 @@ needs_compact3 = \ sun/security/jgss \ sun/security/krb5 \ java/lang/annotation/AnnotationType/AnnotationTypeDeadlockTest.java \ + java/lang/invoke/lambda/LambdaStackTrace.java \ + java/lang/invoke/LFCaching/LFGarbageCollectedTest.java \ + java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java \ + java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java \ java/lang/System/MacEncoding/TestFileEncoding.java \ java/nio/channels/AsynchronousSocketChannel/Leaky.java \ java/security/PermissionCollection/Concurrent.java \ diff --git a/test/java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java b/test/java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java new file mode 100644 index 0000000000000000000000000000000000000000..c898ef7ef4be0ff209c79537f17cd1fc3501e130 --- /dev/null +++ b/test/java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2015, 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.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; + +import javax.swing.JButton; +import javax.swing.SwingUtilities; + +/** + * @test + * @bug 8071306 + * @author Sergey Bylokhov + */ +public final class SetEnabledPerformance { + + private static Frame frame; + + private static void createAndShowGUI() { + frame = new Frame(); + frame.setLayout(new FlowLayout(FlowLayout.CENTER, 25, 0)); + frame.setSize(600, 600); + frame.setLocationRelativeTo(null); + for (int i = 1; i < 10001; ++i) { + frame.add(new JButton("Button " + i)); + } + frame.setVisible(true); + } + + public static void main(final String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); + final Robot robot = new Robot(); + robot.waitForIdle(); + robot.mouseMove(frame.getX() + 15, frame.getY() + 300); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(() -> { + long m = System.currentTimeMillis(); + for (final Component comp : frame.getComponents()) { + comp.setEnabled(false); + } + m = System.currentTimeMillis() - m; + System.err.println("Disabled in " + m + " ms"); + frame.dispose(); + // we should be much faster, but leaves 1000 for the slow systems + if (m > 1000) { + throw new RuntimeException("Too slow"); + } + }); + } +} \ No newline at end of file diff --git a/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java b/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java deleted file mode 100644 index aa074e70152f08148235bc2cd5d5296bcb648736..0000000000000000000000000000000000000000 --- a/test/java/awt/Component/isLightweightCrash/StubPeerCrash.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2007, 2008, 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 6255653 - @summary REGRESSION: Override isLightweight() causes access violation in awt.dll - @author Andrei Dmitriev: area=awt-component - @run main StubPeerCrash -*/ - -/* - * The test may not crash for several times so iteratively continue up to some limit. - */ - -import java.awt.*; -import java.awt.peer.*; -import java.awt.event.PaintEvent; -import java.awt.image.ImageProducer; -import java.awt.image.ImageObserver; -import java.awt.image.ColorModel; -import java.awt.image.VolatileImage; -import java.awt.GraphicsConfiguration; -import sun.awt.CausedFocusEvent; -import sun.java2d.pipe.Region; - -public class StubPeerCrash { - public static int ITERATIONS = 20; - - public static void main(String []s) - { - for (int i = 0; i < ITERATIONS; i++){ - showFrame(i); - } - } - - private static void showFrame(int i){ - System.out.println("iteration = "+i); - Frame f = new Frame(); - f.add(new AHeavyweightComponent()); - f.setVisible(true); - f.setVisible(false); - } -} - -class AHeavyweightComponent extends Component { - private ComponentPeer peer = new StubComponentPeer(); - - public AHeavyweightComponent(){ - } - - public boolean isLightweight() { - return false; - } - - public ComponentPeer getPeer(){ - return peer; - } -} - -class StubComponentPeer implements ComponentPeer { - public boolean isObscured(){return true;}; - public boolean canDetermineObscurity(){return true;}; - public void setVisible(boolean b){}; - public void setEnabled(boolean b){}; - public void paint(Graphics g){}; - public void repaint(long tm, int x, int y, int width, int height){}; - public void print(Graphics g){}; - public void setBounds(int x, int y, int width, int height, int op){}; - public void handleEvent(AWTEvent e){}; - public void coalescePaintEvent(PaintEvent e){}; - public Point getLocationOnScreen(){return null;}; - public Dimension getPreferredSize(){return null;}; - public Dimension getMinimumSize(){return null;}; - public ColorModel getColorModel(){return null;}; - public Toolkit getToolkit(){return null;}; - public Graphics getGraphics(){return null;}; - public FontMetrics getFontMetrics(Font font){return null;}; - public void dispose(){}; - public void setForeground(Color c){}; - public void setBackground(Color c){}; - public void setFont(Font f){}; - public void updateCursorImmediately(){}; - public boolean requestFocus(Component lightweightChild, - boolean temporary, - boolean focusedWindowChangeAllowed, - long time, CausedFocusEvent.Cause cause){ - return true; - }; - public boolean isFocusable(){return true;}; - - public Image createImage(ImageProducer producer){return null;}; - public Image createImage(int width, int height){return null;}; - public VolatileImage createVolatileImage(int width, int height){return null;}; - public boolean prepareImage(Image img, int w, int h, ImageObserver o){return true;}; - public int checkImage(Image img, int w, int h, ImageObserver o){return 0;}; - public GraphicsConfiguration getGraphicsConfiguration(){return null;}; - public boolean handlesWheelScrolling(){return true;}; - public void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException{}; - public Image getBackBuffer(){return null;}; - public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction){}; - public void destroyBuffers(){}; - - /** - * Reparents this peer to the new parent referenced by newContainer peer - * Implementation depends on toolkit and container. - * @param newContainer peer of the new parent container - * @since 1.5 - */ - public void reparent(ContainerPeer newContainer){}; - /** - * Returns whether this peer supports reparenting to another parent withour destroying the peer - * @return true if appropriate reparent is supported, false otherwise - * @since 1.5 - */ - public boolean isReparentSupported(){return true;}; - - /** - * Used by lightweight implementations to tell a ComponentPeer to layout - * its sub-elements. For instance, a lightweight Checkbox needs to layout - * the box, as well as the text label. - */ - public void layout(){}; - - - public Rectangle getBounds(){return null;}; - - /** - * Applies the shape to the native component window. - * @since 1.7 - */ - public void applyShape(Region shape){}; - - /** - * DEPRECATED: Replaced by getPreferredSize(). - */ - public Dimension preferredSize(){return null;}; - - /** - * DEPRECATED: Replaced by getMinimumSize(). - */ - public Dimension minimumSize(){return null;}; - - /** - * DEPRECATED: Replaced by setVisible(boolean). - */ - public void show(){}; - - /** - * DEPRECATED: Replaced by setVisible(boolean). - */ - public void hide(){}; - - /** - * DEPRECATED: Replaced by setEnabled(boolean). - */ - public void enable(){}; - - /** - * DEPRECATED: Replaced by setEnabled(boolean). - */ - public void disable(){}; - - /** - * DEPRECATED: Replaced by setBounds(int, int, int, int). - */ - public void reshape(int x, int y, int width, int height){}; -} diff --git a/test/java/awt/FontClass/DebugFonts.java b/test/java/awt/FontClass/DebugFonts.java new file mode 100644 index 0000000000000000000000000000000000000000..ce0eb4bb359b13b0cbcb4988390daf932f4743e8 --- /dev/null +++ b/test/java/awt/FontClass/DebugFonts.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2003, 2015, 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 4956241 80769790 + * @summary NPE debugging fonts + * @run main/othervm DebugFonts + */ + +import java.awt.Font; + +public class DebugFonts { + + public static void main(String [] args) { + System.setProperty("sun.java2d.debugfonts", "true"); + Font font = new Font("dialog", Font.PLAIN, 14); + System.out.println(font); + String s1 = font.getFamily(); + String s2 = font.getFontName(); + } +} diff --git a/test/java/awt/FontClass/HelvLtOblTest.java b/test/java/awt/FontClass/HelvLtOblTest.java new file mode 100644 index 0000000000000000000000000000000000000000..80f976a76f4e6f7602041048cf48ff67626ae7da --- /dev/null +++ b/test/java/awt/FontClass/HelvLtOblTest.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2015, 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 8064833 + * @summary Test correct font is obtained via family+style + * @run main HelvLtOblTest + */ + +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.image.BufferedImage; + +public class HelvLtOblTest extends JComponent { + + static Font helvFont = null; + + static int[] codes = { 0x23, 0x4a, 0x48, 0x3, 0x4a, 0x55, 0x42, 0x4d, + 0x4a, 0x44, 0x3, + 0x53, 0x46, 0x45, 0x3, 0x55, 0x46, 0x59, 0x55, }; + + static String str = "Big italic red text"; + + public static void main(String[] args) throws Exception { + String os = System.getProperty("os.name"); + if (!os.startsWith("Mac")) { + return; + } + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Font[] fonts = ge.getAllFonts(); + for (int i=0; i { + JFrame f = new JFrame(); + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + f.add("Center", test); + f.pack(); + f.setVisible(true); + }); + test.compareImages(); + } + + public Dimension getPreferredSize() { + return new Dimension(400,400); + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D)g; + FontRenderContext frc = new FontRenderContext(null, true, true); + Font f = helvFont.deriveFont(Font.PLAIN, 40); + System.out.println("font = " +f.getFontName()); + GlyphVector gv = f.createGlyphVector(frc, codes); + g.setFont(f); + g.setColor(Color.white); + g.fillRect(0,0,400,400); + g.setColor(Color.black); + g2.drawGlyphVector(gv, 5,200); + g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + g2.drawString(str, 5, 250); + } + + void compareImages() { + BufferedImage bi0 = drawText(false); + BufferedImage bi1 = drawText(true); + compare(bi0, bi1); + } + + BufferedImage drawText(boolean doGV) { + int w = 400; + int h = 50; + BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = bi.createGraphics(); + g.setColor(Color.white); + g.fillRect(0,0,w,h); + g.setColor(Color.black); + Font f = helvFont.deriveFont(Font.PLAIN, 40); + g.setFont(f); + int x = 5; + int y = h - 10; + if (doGV) { + FontRenderContext frc = new FontRenderContext(null, true, true); + GlyphVector gv = f.createGlyphVector(frc, codes); + g.drawGlyphVector(gv, 5, y); + } else { + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + g.drawString(str, x, y); + } + return bi; + } + + // Need to allow for minimal rounding error, so allow each component + // to differ by 1. + void compare(BufferedImage bi0, BufferedImage bi1) { + int wid = bi0.getWidth(); + int hgt = bi0.getHeight(); + for (int x=0; x> 16; + int r1 = (rgb1 & 0xff0000) >> 16; + int rdiff = r0-r1; if (rdiff<0) rdiff = -rdiff; + int g0 = (rgb0 & 0x00ff00) >> 8; + int g1 = (rgb1 & 0x00ff00) >> 8; + int gdiff = g0-g1; if (gdiff<0) gdiff = -gdiff; + int b0 = (rgb0 & 0x0000ff); + int b1 = (rgb1 & 0x0000ff); + int bdiff = b0-b1; if (bdiff<0) bdiff = -bdiff; + if (rdiff > 1 || gdiff > 1 || bdiff > 1) { + throw new RuntimeException( + "Images differ at x=" + x + " y="+ y + " " + + Integer.toHexString(rgb0) + " vs " + + Integer.toHexString(rgb1)); + } + } + } + } + +} diff --git a/test/java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java b/test/java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..272b21144d3e1b26965e587208a4aa9df15467f4 --- /dev/null +++ b/test/java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015, 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.*; +import java.awt.event.*; +import javax.swing.*; +/* + * @test + * @bug 8080137 + * @summary Dragged events for extra mouse buttons (4,5,6) are not generated + * on JSplitPane + * @author alexandr.scherbatiy area=awt.event + * @run main MouseDraggedTest + */ +public class MouseDraggedTest { + + private static JFrame frame; + private static Rectangle frameBounds; + private static volatile boolean mouseDragged; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(MouseDraggedTest::createAndShowGUI); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> frameBounds = frame.getBounds()); + robot.waitForIdle(); + + for (int i = 1; i <= MouseInfo.getNumberOfButtons(); i++) { + testMouseDrag(i, robot); + } + } finally { + SwingUtilities.invokeLater(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void testMouseDrag(int button, Robot robot) { + + mouseDragged = false; + int x1 = frameBounds.x + frameBounds.width / 4; + int y1 = frameBounds.y + frameBounds.height / 4; + int x2 = frameBounds.x + frameBounds.width / 2; + int y2 = frameBounds.y + frameBounds.height / 2; + + robot.mouseMove(x1, y1); + robot.waitForIdle(); + + int buttonMask = InputEvent.getMaskForButton(button); + robot.mousePress(buttonMask); + robot.mouseMove(x2, y2); + robot.mouseRelease(buttonMask); + robot.waitForIdle(); + + if (!mouseDragged) { + throw new RuntimeException("Mouse button " + button + + " is not dragged"); + } + } + + static void createAndShowGUI() { + + frame = new JFrame(); + frame.setSize(400, 400); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel panel = new JPanel(new BorderLayout()); + panel.addMouseMotionListener(new MouseAdapter() { + + @Override + public void mouseDragged(MouseEvent e) { + mouseDragged = true; + } + }); + frame.add(panel, BorderLayout.CENTER); + frame.setVisible(true); + } +} \ No newline at end of file diff --git a/test/java/awt/ScrollPane/bug8077409Test.java b/test/java/awt/ScrollPane/bug8077409Test.java new file mode 100644 index 0000000000000000000000000000000000000000..a3a7a951360eaad23f2be35f06b5b381edbb793c --- /dev/null +++ b/test/java/awt/ScrollPane/bug8077409Test.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2015, 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 8077409 + @summary Drawing deviates when validate() is invoked on java.awt.ScrollPane + @author mikhail.cherkasov@oracle.com + @run main bug8077409Test +*/ + + +import java.awt.*; +import java.awt.event.*; + +public class bug8077409Test extends Frame { + ScrollPane pane; + MyCanvas myCanvas; + + class MyCanvas extends Canvas { + public Dimension getPreferredSize() { + return new Dimension(400, 800); + } + + public void paint(Graphics g) { + g.setColor(Color.BLACK); + g.drawLine(0, 0, 399, 0); + g.setColor(Color.RED); + g.drawLine(0, 1, 399, 1); + g.setColor(Color.BLUE); + g.drawLine(0, 2, 399, 2); + g.setColor(Color.GREEN); + g.drawLine(0, 3, 399, 3); + } + + } + + public bug8077409Test() { + super(); + setLayout(new BorderLayout()); + pane = new ScrollPane(); + + myCanvas = new MyCanvas(); + pane.add(myCanvas); + + add(pane, BorderLayout.CENTER); + setSize(320, 480); + + } + + @Override + protected void processKeyEvent(KeyEvent e) { + super.processKeyEvent(e); + + } + + public static void main(String[] args) throws AWTException, InterruptedException { + final bug8077409Test obj = new bug8077409Test(); + obj.setVisible(true); + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + @Override + public void eventDispatched(AWTEvent e) { + KeyEvent keyEvent = (KeyEvent) e; + if(keyEvent.getID() == KeyEvent.KEY_RELEASED) { + if (keyEvent.getKeyCode() == KeyEvent.VK_1) { + System.out.println(obj.pane.toString()); + System.out.println("obj.myCanvas.pos: " + obj.myCanvas.getBounds()); + System.out.println(obj.myCanvas.toString()); + } else if (keyEvent.getKeyCode() == KeyEvent.VK_2) { + obj.repaint(); + } else if (keyEvent.getKeyCode() == KeyEvent.VK_DOWN) { + Point scrollPosition = obj.pane.getScrollPosition(); + scrollPosition.translate(0, 1); + obj.pane.setScrollPosition(scrollPosition); + } else if (keyEvent.getKeyCode() == KeyEvent.VK_UP) { + Point scrollPosition = obj.pane.getScrollPosition(); + scrollPosition.translate(0, -1); + obj.pane.setScrollPosition(scrollPosition); + } else if (keyEvent.getKeyCode() == KeyEvent.VK_SPACE) { + obj.pane.validate(); + } + } + } + }, AWTEvent.KEY_EVENT_MASK); + Point scrollPosition = obj.pane.getScrollPosition(); + scrollPosition.translate(0, 1); + obj.pane.setScrollPosition(scrollPosition); + + int y = obj.pane.getComponent(0).getLocation().y; + obj.pane.validate(); + if(y != obj.pane.getComponent(0).getLocation().y){ + throw new RuntimeException("Wrong position of component in ScrollPane"); + } + } + +} \ No newline at end of file diff --git a/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java b/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java new file mode 100644 index 0000000000000000000000000000000000000000..8a9b1bd1ae79e16faaeb5a7cfe9bfd36b95b970d --- /dev/null +++ b/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2015, 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.VolatileImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import static java.awt.geom.Rectangle2D.Double; + +/** + * @test + * @bug 8061831 + * @summary Tests drawing volatile image to volatile image using different + * clips + xor mode. Results of the blit compatibleImage to + * compatibleImage is used for comparison. + */ +public final class IncorrectClipXorModeSurface2Surface { + + 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; + VolatileImage source = getVolatileImage(gc, size); + VolatileImage target = getVolatileImage(gc, size); + int attempt = 0; + while (true) { + if (++attempt > 10) { + throw new RuntimeException("Too many attempts: " + attempt); + } + // Prepare source images + source.validate(gc); + Graphics2D g2d = source.createGraphics(); + g2d.setColor(Color.RED); + g2d.fillRect(0, 0, size, size); + g2d.dispose(); + if (source.validate(gc) != VolatileImage.IMAGE_OK) { + continue; + } + // Prepare target images + target.validate(gc); + g2d = target.createGraphics(); + g2d.setColor(Color.GREEN); + g2d.fillRect(0, 0, size, size); + g2d.dispose(); + if (target.validate(gc) != VolatileImage.IMAGE_OK) { + continue; + } + + draw(clip, to, source, target); + snapshot = target.getSnapshot(); + if (source.contentsLost() || target.contentsLost()) { + continue; + } + break; + } + // Prepare gold images + BufferedImage goldS = getSourceGold(gc, size); + BufferedImage goldT = getTargetGold(gc, size); + draw(clip, to, goldS, goldT); + validate(snapshot, goldT); + source.flush(); + target.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 getSourceGold(GraphicsConfiguration gc, + int size) { + final BufferedImage bi = gc.createCompatibleImage(size, size); + Graphics2D g2d = bi.createGraphics(); + g2d.setColor(Color.RED); + g2d.fillRect(0, 0, size, size); + g2d.dispose(); + return bi; + } + + private static BufferedImage getTargetGold(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 VolatileImage getVolatileImage(GraphicsConfiguration gc, + int size) { + return gc.createCompatibleVolatileImage(size, size); + } + + 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."); + } + } + } + } +} diff --git a/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java index 9d4a748aa78c66e5eef699e4a00efb52d4aac0b5..a60d46044066b8ea0ba1aaa2dfdcc72bc8d6dddc 100644 --- a/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java +++ b/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -24,6 +24,7 @@ /* * @test LFGarbageCollectedTest * @bug 8046703 + * @ignore 8078602 * @summary Test verifies that lambda forms are garbage collected * @author kshefov * @library /lib/testlibrary/jsr292 /lib/testlibrary diff --git a/test/java/sql/testng/TEST.properties b/test/java/sql/testng/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..295505b905a9f1a4091d66cc897b289e7137bbd1 --- /dev/null +++ b/test/java/sql/testng/TEST.properties @@ -0,0 +1,3 @@ +# JDBC unit tests uses TestNG +TestNG.dirs = . + diff --git a/test/java/sql/testng/test/sql/BatchUpdateExceptionTests.java b/test/java/sql/testng/test/sql/BatchUpdateExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..2b1111b7526ed7c776d9f581917389c30c4c3b65 --- /dev/null +++ b/test/java/sql/testng/test/sql/BatchUpdateExceptionTests.java @@ -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(); + } + } + +} diff --git a/test/java/sql/testng/test/sql/DataTruncationTests.java b/test/java/sql/testng/test/sql/DataTruncationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..fbf7eebe90a90e00f08a758d531d81ff43d3cabd --- /dev/null +++ b/test/java/sql/testng/test/sql/DataTruncationTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/DateTests.java b/test/java/sql/testng/test/sql/DateTests.java new file mode 100644 index 0000000000000000000000000000000000000000..ae6c276c4f63f2bc44e7f9d17295175cd57e0d27 --- /dev/null +++ b/test/java/sql/testng/test/sql/DateTests.java @@ -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"} + + }; + } +} diff --git a/test/java/sql/testng/test/sql/DriverManagerPermissionsTests.java b/test/java/sql/testng/test/sql/DriverManagerPermissionsTests.java new file mode 100644 index 0000000000000000000000000000000000000000..73a8923d82fc1727053602ce6d526d5401eff09e --- /dev/null +++ b/test/java/sql/testng/test/sql/DriverManagerPermissionsTests.java @@ -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()); + } +} diff --git a/test/java/sql/testng/test/sql/DriverManagerTests.java b/test/java/sql/testng/test/sql/DriverManagerTests.java new file mode 100644 index 0000000000000000000000000000000000000000..938f23e38a96d8c1a489c8bbcb397b039fc8603d --- /dev/null +++ b/test/java/sql/testng/test/sql/DriverManagerTests.java @@ -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())); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java b/test/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..84230b867581cb4c6be6504e1011366019d4f80e --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLClientInfoExceptionTests.java @@ -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 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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLDataExceptionTests.java b/test/java/sql/testng/test/sql/SQLDataExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..8a5f8d1a2c1d7a25337c3764c47c445dea7604bb --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLDataExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLExceptionTests.java b/test/java/sql/testng/test/sql/SQLExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..e3643ef119c903861c63117914d938b35e4cf036 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLExceptionTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java b/test/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..5b95894412c7742abd1bf8b39a1eb63046412acf --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLFeatureNotSupportedExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java b/test/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..082e0af15c83d0fc518026b94b5397570d8a6abe --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLIntegrityConstraintViolationExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java b/test/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..6e4eaa567ee2279871b7523edac660c7831f978b --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLInvalidAuthorizationSpecExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java b/test/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..dbd8b685844b696b524c79cba4b3e76149fba845 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLNonTransientConnectionExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java b/test/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..061ffe208406cc0861eaa8c909a51aeded12586d --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLNonTransientExceptionTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java b/test/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..d23a131dbcd15abc8ddf197efa582d90b3676f22 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLRecoverableExceptionTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java b/test/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..863213cfcb81680dd9b17181b7314e3ef744ee62 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLSyntaxErrorExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java b/test/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..dfe341545e4427229a62ccbd65ec680080718dfa --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLTimeoutExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java b/test/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..8453ebe1364afd8c03c13ece167d861d8de6bbb8 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLTransactionRollbackExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java b/test/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..7999253b1fa99f8d8ab91adc588a8ecf2306340c --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLTransientConnectionExceptionTests.java @@ -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); + } +} diff --git a/test/java/sql/testng/test/sql/SQLTransientExceptionTests.java b/test/java/sql/testng/test/sql/SQLTransientExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..d86f86b8fc68cf08db7e970b4a6f094a6ac380b6 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLTransientExceptionTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/SQLWarningTests.java b/test/java/sql/testng/test/sql/SQLWarningTests.java new file mode 100644 index 0000000000000000000000000000000000000000..2856742dc5cd37e1c64b013f70c1f04dd0f09562 --- /dev/null +++ b/test/java/sql/testng/test/sql/SQLWarningTests.java @@ -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(); + } + } +} diff --git a/test/java/sql/testng/test/sql/TimeTests.java b/test/java/sql/testng/test/sql/TimeTests.java new file mode 100644 index 0000000000000000000000000000000000000000..7b99679754b2256be8904225aafe7002f06945e7 --- /dev/null +++ b/test/java/sql/testng/test/sql/TimeTests.java @@ -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"} + }; + } +} diff --git a/test/java/sql/testng/test/sql/TimestampTests.java b/test/java/sql/testng/test/sql/TimestampTests.java new file mode 100644 index 0000000000000000000000000000000000000000..7766b5a2b4c69eb708aa086f069669074117167c --- /dev/null +++ b/test/java/sql/testng/test/sql/TimestampTests.java @@ -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} + }; + } +} diff --git a/test/java/sql/testng/util/BaseTest.java b/test/java/sql/testng/util/BaseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6821940b7cea2a5ad454803dc284d3118b56d8cf --- /dev/null +++ b/test/java/sql/testng/util/BaseTest.java @@ -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 + createSerializedException(T ex) + throws IOException, ClassNotFoundException { + return (T) serializeDeserializeObject(ex); + } + + /* + * Utility method to serialize and deserialize an object + */ + @SuppressWarnings("unchecked") + protected 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; + } +} diff --git a/test/java/sql/testng/util/DriverActionImpl.java b/test/java/sql/testng/util/DriverActionImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4a286ad8f3c4fb00319704fc2cde9b9352f30ad1 --- /dev/null +++ b/test/java/sql/testng/util/DriverActionImpl.java @@ -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(); + } +} diff --git a/test/java/sql/testng/util/SerializedBatchUpdateException.java b/test/java/sql/testng/util/SerializedBatchUpdateException.java new file mode 100644 index 0000000000000000000000000000000000000000..00efc5275a73cc3d0e477d71e99f41f4dbdfd224 --- /dev/null +++ b/test/java/sql/testng/util/SerializedBatchUpdateException.java @@ -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 + }; +} diff --git a/test/java/sql/testng/util/StubConnection.java b/test/java/sql/testng/util/StubConnection.java new file mode 100644 index 0000000000000000000000000000000000000000..88c44262f61f944eec38d3b16161f7ce51f3cae1 --- /dev/null +++ b/test/java/sql/testng/util/StubConnection.java @@ -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> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> 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 unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/test/java/sql/testng/util/StubDriver.java b/test/java/sql/testng/util/StubDriver.java new file mode 100644 index 0000000000000000000000000000000000000000..1225308037752f27ea0d74098f14dec74e5a8ce9 --- /dev/null +++ b/test/java/sql/testng/util/StubDriver.java @@ -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."); + } +} diff --git a/test/java/sql/testng/util/StubDriverDA.java b/test/java/sql/testng/util/StubDriverDA.java new file mode 100644 index 0000000000000000000000000000000000000000..5b23f0846d87dd196d8598e0403ef26a0e2910fb --- /dev/null +++ b/test/java/sql/testng/util/StubDriverDA.java @@ -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); + } + } +} diff --git a/test/java/sql/testng/util/TestPolicy.java b/test/java/sql/testng/util/TestPolicy.java new file mode 100644 index 0000000000000000000000000000000000000000..af21cc8fc15e3ecbeae29a62e4252615654184b2 --- /dev/null +++ b/test/java/sql/testng/util/TestPolicy.java @@ -0,0 +1,142 @@ +/* + * 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; +import java.util.logging.LoggingPermission; + +/* + * 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"), + * setSyncFactory(SQLPermission(setSyncFactory), and also + * LoggerPermission("control", null) when setting a Level + * + * @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; + case "setSyncFactoryLogger": + setMinimalPermissions(); + permissions.add(new SQLPermission("setSyncFactory")); + permissions.add(new LoggingPermission("control", null)); + 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("<>", + "read, write, delete")); + } + + /* + * Overloaded methods from the Policy class + */ + @Override + public String toString() { + StringJoiner sj = new StringJoiner("\n", "policy: ", ""); + Enumeration 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); + } +} diff --git a/test/javax/sql/testng/TEST.properties b/test/javax/sql/testng/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..cb97c16050755c57b50ab667c9abc10dfa6fe742 --- /dev/null +++ b/test/javax/sql/testng/TEST.properties @@ -0,0 +1,7 @@ +# JDBC unit tests uses TestNG +TestNG.dirs= . +othervm.dirs= . +lib.dirs = /java/sql/testng +modules = java.sql.rowset/com.sun.rowset \ + java.sql.rowset/com.sun.rowset.internal \ + java.sql.rowset/com.sun.rowset.providers diff --git a/test/javax/sql/testng/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory b/test/javax/sql/testng/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory new file mode 100644 index 0000000000000000000000000000000000000000..6cb88d5a35ce8e1a8b5e8b55a7abf83c6606c859 --- /dev/null +++ b/test/javax/sql/testng/jars/badFactory/META-INF/services/javax.sql.rowset.RowSetFactory @@ -0,0 +1 @@ +invalid.RowSetFactoryImpl diff --git a/test/javax/sql/testng/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory b/test/javax/sql/testng/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory new file mode 100644 index 0000000000000000000000000000000000000000..ac3a8187e4e2a866424ba2f941dc5abe6abf2ab5 --- /dev/null +++ b/test/javax/sql/testng/jars/goodFactory/META-INF/services/javax.sql.rowset.RowSetFactory @@ -0,0 +1 @@ +util.StubRowSetFactory diff --git a/test/javax/sql/testng/test/rowset/BaseRowSetTests.java b/test/javax/sql/testng/test/rowset/BaseRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..95883556a057ead3ec21c4201219494b9c93960e --- /dev/null +++ b/test/javax/sql/testng/test/rowset/BaseRowSetTests.java @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2014, 2015, 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.io.InputStream; +import java.io.Reader; +import java.io.StringBufferInputStream; +import java.io.StringReader; +import java.math.BigDecimal; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.Ref; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Calendar; +import javax.sql.RowSet; +import javax.sql.rowset.serial.SerialArray; +import javax.sql.rowset.serial.SerialBlob; +import javax.sql.rowset.serial.SerialClob; +import javax.sql.rowset.serial.SerialRef; +import static org.testng.Assert.*; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import util.StubArray; +import util.StubBaseRowSet; +import util.StubBlob; +import util.StubClob; +import util.StubRef; +import util.TestRowSetListener; + +public class BaseRowSetTests extends CommonRowSetTests { + + private StubBaseRowSet brs; + + @Override + protected RowSet newInstance() throws SQLException { + return new StubBaseRowSet(); + } + + /* + * Create a RowSetListener and validate that notifyCursorMoved is called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0000(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + } + + /* + * Create a RowSetListener and validate that notifyRowChanged is called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0001(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyRowChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0002(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + } + + /* + * Create multiple RowSetListeners and validate that notifyRowSetChanged + * is called on all listeners + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0003(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowSetChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(rsl2.isNotified(TestRowSetListener.ROWSET_CHANGED)); + } + + /* + * Create multiple RowSetListeners and validate that notifyRowChanged + * is called on all listeners + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0004(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + assertTrue(rsl2.isNotified(TestRowSetListener.ROW_CHANGED)); + } + + /* + * Create multiple RowSetListeners and validate that notifyCursorMoved + * is called on all listeners + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0005(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED)); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged, + * notifyRowChanged() and notifyCursorMoved are called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0006(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); + rs.notifyRowChanged(); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified( + TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED + | TestRowSetListener.ROW_CHANGED)); + } + + + /* + * Create multiple RowSetListeners and validate that notifyRowSetChanged, + * notifyRowChanged() and notifyCursorMoved are called on all listeners + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0007(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowSetChanged(); + rs.notifyRowChanged(); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified( + TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED + | TestRowSetListener.ROW_CHANGED)); + assertTrue(rsl2.isNotified( + TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED + | TestRowSetListener.ROW_CHANGED)); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called, + * remove the listener, invoke notifyRowSetChanged again and verify the + * listner is not called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0008(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + // Clear the flag indicating the listener has been called + rsl.resetFlag(); + rs.removeRowSetListener(rsl); + rs.notifyRowSetChanged(); + assertFalse(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + } + + /* + * Set the base parameters and validate that the value set is + * the correct type and value + */ + @Test(dataProvider = "testBaseParameters") + public void baseRowSetTest0009(int pos, Object o) throws Exception { + assertTrue(getParam(pos, o).getClass().isInstance(o)); + assertTrue(o.equals(getParam(pos, o))); + } + + /* + * Set the complex parameters and validate that the value set is + * the correct type + */ + @Test(dataProvider = "testAdvancedParameters") + public void baseRowSetTest0010(int pos, Object o) throws Exception { + assertTrue(getParam(pos, o).getClass().isInstance(o)); + } + + /* + * Validate setNull specifying the supported type values + */ + @Test(dataProvider = "jdbcTypes") + public void baseRowSetTest0011(Integer type) throws Exception { + brs = new StubBaseRowSet(); + brs.setNull(1, type); + assertTrue(checkNullParam(1, type, null)); + } + + /* + * Validate setNull specifying the supported type values and that + * typeName is set internally + */ + @Test(dataProvider = "jdbcTypes") + public void baseRowSetTest0012(Integer type) throws Exception { + brs = new StubBaseRowSet(); + brs.setNull(1, type, "SUPERHERO"); + assertTrue(checkNullParam(1, type, "SUPERHERO")); + } + + /* + * Validate that setDate sets the specified Calendar internally + */ + @Test() + public void baseRowSetTest0013() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setDate(1, Date.valueOf(LocalDate.now()), cal); + assertTrue(checkCalendarParam(1, cal)); + } + + /* + * Validate that setTime sets the specified Calendar internally + */ + @Test() + public void baseRowSetTest0014() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setTime(1, Time.valueOf(LocalTime.now()), cal); + assertTrue(checkCalendarParam(1, cal)); + } + + /* + * Validate that setTimestamp sets the specified Calendar internally + */ + @Test() + public void baseRowSetTest0015() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now()), cal); + assertTrue(checkCalendarParam(1, cal)); + } + + /* + * Validate that initParams() initializes the parameters + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0016(StubBaseRowSet rs) throws Exception { + rs.setInt(1, 1); + rs.initParams(); + assertTrue(rs.getParams().length == 0); + } + + + /* + * DataProvider used to set parameters for basic types that are supported + */ + @DataProvider(name = "testBaseParameters") + private Object[][] testBaseParameters() throws SQLException { + Integer aInt = 1; + Long aLong = Long.MAX_VALUE; + Short aShort = Short.MIN_VALUE; + BigDecimal bd = BigDecimal.ONE; + Double aDouble = Double.MAX_VALUE; + Date aDate = Date.valueOf(LocalDate.now()); + Time aTime = Time.valueOf(LocalTime.now()); + Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now()); + Calendar cal = Calendar.getInstance(); + Boolean aBoolean = true; + Float aFloat = 1.5f; + Byte aByte = 1; + brs = new StubBaseRowSet(); + + brs.setInt(1, aInt); + brs.setString(2, query); + brs.setLong(3, aLong); + brs.setBoolean(4, aBoolean); + brs.setShort(5, aShort); + brs.setDouble(6, aDouble); + brs.setBigDecimal(7, bd); + brs.setFloat(8, aFloat); + brs.setByte(9, aByte); + brs.setDate(10, aDate); + brs.setTime(11, aTime); + brs.setTimestamp(12, aTimeStamp); + brs.setDate(13, aDate, cal); + brs.setTime(14, aTime, cal); + brs.setTimestamp(15, aTimeStamp); + brs.setObject(16, query); + brs.setObject(17, query, Types.CHAR); + brs.setObject(18, query, Types.CHAR, 0); + + return new Object[][]{ + {1, aInt}, + {2, query}, + {3, aLong}, + {4, aBoolean}, + {5, aShort}, + {6, aDouble}, + {7, bd}, + {8, aFloat}, + {9, aByte}, + {10, aDate}, + {11, aTime}, + {12, aTimeStamp}, + {13, aDate}, + {14, aTime}, + {15, aTimeStamp}, + {16, query}, + {17, query}, + {18, query} + + }; + } + + /* + * DataProvider used to set advanced parameters for types that are supported + */ + @DataProvider(name = "testAdvancedParameters") + private Object[][] testAdvancedParameters() throws SQLException { + + byte[] bytes = new byte[10]; + Ref aRef = new SerialRef(new StubRef("INTEGER", query)); + Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1])); + Blob aBlob = new SerialBlob(new StubBlob()); + Clob aClob = new SerialClob(new StubClob()); + Reader rdr = new StringReader(query); + InputStream is = new StringBufferInputStream(query);; + brs = new StubBaseRowSet(); + brs.setBytes(1, bytes); + brs.setAsciiStream(2, is, query.length()); + brs.setRef(3, aRef); + brs.setArray(4, aArray); + brs.setBlob(5, aBlob); + brs.setClob(6, aClob); + brs.setBinaryStream(7, is, query.length()); + brs.setUnicodeStream(8, is, query.length()); + brs.setCharacterStream(9, rdr, query.length()); + + return new Object[][]{ + {1, bytes}, + {2, is}, + {3, aRef}, + {4, aArray}, + {5, aBlob}, + {6, aClob}, + {7, is}, + {8, is}, + {9, rdr} + }; + } + + /* + * Method that returns the specified parameter instance that was set via setXXX + * Note non-basic types are stored as an Object[] where the 1st element + * is the object instnace + */ + @SuppressWarnings("unchecked") + private T getParam(int pos, T o) throws SQLException { + Object[] params = brs.getParams(); + if (params[pos - 1] instanceof Object[]) { + Object[] param = (Object[]) params[pos - 1]; + return (T) param[0]; + } else { + return (T) params[pos - 1]; + } + } + + /* + * Utility method to validate parameters when the param is an Object[] + */ + private boolean checkParam(int pos, int type, Object val) throws SQLException { + boolean result = false; + Object[] params = brs.getParams(); + if (params[pos - 1] instanceof Object[]) { + Object[] param = (Object[]) params[pos - 1]; + + if (param[0] == null) { + // setNull was used + if (param.length == 2 && (Integer) param[1] == type) { + result = true; + } else { + if (param.length == 3 && (Integer) param[1] == type + && val.equals(param[2])) { + result = true; + } + } + + } else if (param[0] instanceof java.util.Date) { + // setDate/Time/Timestamp with a Calendar object + if (param[1] instanceof Calendar && val.equals(param[1])) { + result = true; + } + } + } + return result; + } + + /* + * Wrapper method for validating that a null was set and the appropriate + * type and typeName if applicable + */ + private boolean checkNullParam(int pos, int type, String typeName) throws SQLException { + return checkParam(pos, type, typeName); + } + + /* + * Wrapper method for validating that a Calander was set + */ + private boolean checkCalendarParam(int pos, Calendar cal) throws SQLException { + // 2nd param is ignored when instanceof java.util.Date + return checkParam(pos, Types.DATE, cal); + } +} diff --git a/test/javax/sql/testng/test/rowset/CommonRowSetTests.java b/test/javax/sql/testng/test/rowset/CommonRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..89492aefed5e907e2a166000f076ca5ba945a618 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/CommonRowSetTests.java @@ -0,0 +1,1372 @@ +/* + * Copyright (c) 2015, 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.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.rowset.BaseRowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetFactory; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.RowSetProvider; +import org.testng.Assert; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubBlob; +import util.StubClob; +import util.StubNClob; +import util.StubSQLXML; + +public abstract class CommonRowSetTests extends BaseTest { + + protected final String stubProvider = "util.StubSyncProvider"; + protected final String query = "SELECT * FROM SUPERHEROS"; + private final String url = "jdbc:derby://localhost:1527/myDB"; + private final String dsName = "jdbc/myDB"; + private final String user = "Bruce Wayne"; + private final String password = "The Dark Knight"; + protected final String COFFEE_HOUSES_TABLE = "COFFEE_HOUSES"; + protected final String COFFEES_TABLE = "COFFEES"; + protected final int COFFEE_HOUSES_ROWS = 14; + protected final int COFFEES_ROWS = 5; + protected final Object[] COFFEES_PRIMARY_KEYS = {1, 2, 3, 4, 5}; + protected final Object[] COFFEE_HOUSES_PRIMARY_KEYS = { + 10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041, + 33005, 33010, 10035, 10037, 10034, 32004 + }; + + /* + * COFFEES_HOUSES Table column names + */ + protected final String[] COFFEE_HOUSES_COLUMN_NAMES = { + "STORE_ID", "CITY", "COFFEE", "MERCH", "TOTAL" + }; + + /* + * COFFEES Table column names + */ + protected final String[] COFFEES_COLUMN_NAMES = { + "COF_ID", "COF_NAME", "SUP_ID", "PRICE", "SALES", "TOTAL" + }; + + protected RowSetFactory rsf; + + public CommonRowSetTests() { + try { + rsf = RowSetProvider.newFactory(); + } catch (SQLException ex) { + Assert.fail(ex.getMessage()); + } + } + + // Create an instance of the RowSet we are using + protected abstract T newInstance() throws SQLException; + + //DataProvider to use for common tests + + /* + * DataProvider used to specify the value to set and check for the + * methods for fetch direction + */ + @DataProvider(name = "rowSetFetchDirection") + protected Object[][] rowSetFetchDirection() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, ResultSet.FETCH_FORWARD}, + {rs, ResultSet.FETCH_REVERSE}, + {rs, ResultSet.FETCH_UNKNOWN} + }; + } + + /* + * DataProvider used to specify the value to set and check for the + * methods for Cursor Scroll Type + */ + @DataProvider(name = "rowSetScrollTypes") + protected Object[][] rowSetScrollTypes() throws Exception { + RowSet rs = newInstance(); + + return new Object[][]{ + {rs, ResultSet.TYPE_FORWARD_ONLY}, + {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, + {rs, ResultSet.TYPE_SCROLL_SENSITIVE} + }; + } + + /* + * DataProvider used to specify the value to set and check for + * methods using transaction isolation types + */ + @DataProvider(name = "rowSetIsolationTypes") + protected Object[][] rowSetIsolationTypes() throws Exception { + RowSet rs = newInstance(); + + return new Object[][]{ + {rs, Connection.TRANSACTION_NONE}, + {rs, Connection.TRANSACTION_READ_COMMITTED}, + {rs, Connection.TRANSACTION_READ_UNCOMMITTED}, + {rs, Connection.TRANSACTION_REPEATABLE_READ}, + {rs, Connection.TRANSACTION_SERIALIZABLE} + }; + } + + /* + * DataProvider used to specify the value to set and check for the + * methods for Concurrency + */ + @DataProvider(name = "rowSetConcurrencyTypes") + protected Object[][] rowSetConcurrencyTypes() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, ResultSet.CONCUR_READ_ONLY}, + {rs, ResultSet.CONCUR_UPDATABLE} + }; + } + + /* + * DataProvider used to specify the value to set and check for + * methods using boolean values + */ + @DataProvider(name = "rowSetTrueFalse") + protected Object[][] rowSetTrueFalse() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, true}, + {rs, false} + }; + } + /* + * DataProvider used to specify the type of RowSet to use. We also must + * initialize the RowSet + */ + @DataProvider(name = "rowSetType") + protected Object[][] rowSetType() throws Exception { + + RowSet rs = newInstance(); + return new Object[][]{ + {rs} + }; + } + + /* + * Initializes a RowSet containing the COFFEE_HOUSES data + */ + protected T createCoffeeHousesRowSet() throws SQLException { + T rs = (T) newInstance(); + initCoffeeHousesMetaData((CachedRowSet) rs); + createCoffeeHouseRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + /* + * Initializes a RowSet containing the COFFEE_HOUSES data + */ + protected T createCoffeesRowSet() throws SQLException { + T rs = (T) newInstance(); + initCoffeesMetaData((CachedRowSet) rs); + createCoffeesRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + /* + * Initializes the COFFEE_HOUSES metadata + */ + private void initCoffeeHousesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + /* + * CREATE TABLE COFFEE_HOUSES( + * STORE_ID Integer NOT NULL, + * CITY VARCHAR(32), + * COFFEE INTEGER NOT NULL, + * MERCH INTEGER NOT NULL, + * TOTAL INTEGER NOT NULL, + * PRIMARY KEY (STORE_ID)) + */ + rsmd.setColumnCount(COFFEE_HOUSES_COLUMN_NAMES.length); + for(int i = 1; i <= COFFEE_HOUSES_COLUMN_NAMES.length; i++){ + rsmd.setColumnName(i, COFFEE_HOUSES_COLUMN_NAMES[i-1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.INTEGER); + rsmd.setColumnType(4, Types.INTEGER); + rsmd.setColumnType(5, Types.INTEGER); + crs.setMetaData(rsmd); + crs.setTableName(COFFEE_HOUSES_TABLE); + + } + + /* + * Add rows to COFFEE_HOUSES table + */ + protected void createCoffeeHouseRows(RowSet rs) throws SQLException { + + // insert into COFFEE_HOUSES values(10023, 'Mendocino', 3450, 2005, 5455) + rs.moveToInsertRow(); + rs.updateInt(1, 10023); + rs.updateString(2, "Mendocino"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33002, 'Seattle', 4699, 3109, 7808) + rs.moveToInsertRow(); + rs.updateInt(1, 33002); + rs.updateString(2, "Seattle"); + rs.updateInt(3, 4699); + rs.updateInt(4, 3109); + rs.updateInt(5, 7808); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10040, 'SF', 5386, 2841, 8227) + rs.moveToInsertRow(); + rs.updateInt(1, 10040); + rs.updateString(2, "SF"); + rs.updateInt(3, 5386); + rs.updateInt(4, 2841); + rs.updateInt(5, 8227); + rs.insertRow(); + // insert into COFFEE_HOUSES values(32001, 'Portland', 3147, 3579, 6726) + rs.moveToInsertRow(); + rs.updateInt(1, 32001); + rs.updateString(2, "Portland"); + rs.updateInt(3, 3147); + rs.updateInt(4, 3579); + rs.updateInt(5, 6726); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10042, 'SF', 2863, 1874, 4710) + rs.moveToInsertRow(); + rs.updateInt(1, 10042); + rs.updateString(2, "SF"); + rs.updateInt(3, 2863); + rs.updateInt(4, 1874); + rs.updateInt(5, 4710); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10024, 'Sacramento', 1987, 2341, 4328) + rs.moveToInsertRow(); + rs.updateInt(1, 10024); + rs.updateString(2, "Sacramento"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 4328); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10039, 'Carmel', 2691, 1121, 3812) + rs.moveToInsertRow(); + rs.updateInt(1, 10039); + rs.updateString(2, "Carmel"); + rs.updateInt(3, 2691); + rs.updateInt(4, 1121); + rs.updateInt(5, 3812); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10041, 'LA', 1533, 1007, 2540) + rs.moveToInsertRow(); + rs.updateInt(1, 10041); + rs.updateString(2, "LA"); + rs.updateInt(3, 1533); + rs.updateInt(4, 1007); + rs.updateInt(5, 2540); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33005, 'Olympia', 2733, 1550, 1550) + rs.moveToInsertRow(); + rs.updateInt(1, 33005); + rs.updateString(2, "Olympia"); + rs.updateInt(3, 2733); + rs.updateInt(4, 1550); + rs.updateInt(5, 1550); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33010, 'Seattle', 3210, 2177, 5387) + rs.moveToInsertRow(); + rs.updateInt(1, 33010); + rs.updateString(2, "Seattle"); + rs.updateInt(3, 3210); + rs.updateInt(4, 2177); + rs.updateInt(5, 5387); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10035, 'SF', 1922, 1056, 2978) + rs.moveToInsertRow(); + rs.updateInt(1, 10035); + rs.updateString(2, "SF"); + rs.updateInt(3, 1922); + rs.updateInt(4, 1056); + rs.updateInt(5, 2978); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10037, 'LA', 2143, 1876, 4019) + rs.moveToInsertRow(); + rs.updateInt(1, 10037); + rs.updateString(2, "LA"); + rs.updateInt(3, 2143); + rs.updateInt(4, 1876); + rs.updateInt(5, 4019); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10034, 'San_Jose', 1234, 1032, 2266) + rs.moveToInsertRow(); + rs.updateInt(1, 10034); + rs.updateString(2, "San Jose"); + rs.updateInt(3, 1234); + rs.updateInt(4, 1032); + rs.updateInt(5, 2266); + rs.insertRow(); + // insert into COFFEE_HOUSES values(32004, 'Eugene', 1356, 1112, 2468) + rs.moveToInsertRow(); + rs.updateInt(1, 32004); + rs.updateString(2, "Eugene"); + rs.updateInt(3, 1356); + rs.updateInt(4, 1112); + rs.updateInt(5, 2468); + rs.insertRow(); + rs.moveToCurrentRow(); + } + + /* + * Initializes the COFFEES metadata + */ + protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + /* + * CREATE TABLE COFFEES ( + * COF_ID INTEGER NOT NULL, + * COF_NAME VARCHAR(32) NOT NULL, + * SUP_ID INTEGER NOT NULL, + * PRICE NUMBERIC(10,2 NOT NULL, + * SALES INTEGER NOT NULL, + * TOTAL INTEGER NOT NULL, + * PRIMARY KEY (COF_ID), + * FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) ) + */ + rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length); + for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){ + rsmd.setColumnName(i, COFFEES_COLUMN_NAMES[i-1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.INTEGER); + rsmd.setColumnType(4, Types.NUMERIC); + rsmd.setPrecision(4, 10); + rsmd.setScale(4, 2); + rsmd.setColumnType(5, Types.INTEGER); + rsmd.setColumnType(6, Types.INTEGER); + crs.setMetaData(rsmd); + crs.setTableName(COFFEES_TABLE); + + } + + /* + * Add rows to COFFEES table + */ + protected void createCoffeesRows(RowSet rs) throws SQLException { + + // insert into COFFEES values(1, 'Colombian', 101, 7.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 1); + rs.updateString(2, "Colombian"); + rs.updateInt(3, 101); + rs.updateBigDecimal(4, BigDecimal.valueOf(7.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(2, 'French_Roast', 49, 8.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 2); + rs.updateString(2, "French_Roast"); + rs.updateInt(3, 49); + rs.updateBigDecimal(4, BigDecimal.valueOf(8.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(3, 'Espresso', 150, 9.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 3); + rs.updateString(2, "Espresso"); + rs.updateInt(3, 150); + rs.updateBigDecimal(4, BigDecimal.valueOf(9.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(4, 'Colombian_Decaf', 101, 8.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 4); + rs.updateString(2, "Colombian_Decaf"); + rs.updateInt(3, 101); + rs.updateBigDecimal(4, BigDecimal.valueOf(8.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(5, 'French_Roast_Decaf', 049, 9.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 5); + rs.updateString(2, "French_Roast_Decaf"); + rs.updateInt(3, 49); + rs.updateBigDecimal(4, BigDecimal.valueOf(9.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + + } + + + /* + * Utility method to return the Primary Keys for a RowSet. The Primary + * keys are assumed to be in the first column of the RowSet + */ + protected Object[] getPrimaryKeys(ResultSet rs) throws SQLException { + List result = new ArrayList<>(); + if (rs == null) { + return null; + } + rs.beforeFirst(); + while (rs.next()) { + result.add(rs.getInt(1)); + } + return result.toArray(); + } + + /* + * Utility method to display the RowSet and will return the row count + * it found + */ + protected int displayResults(ResultSet rs) throws SQLException { + int rows = 0; + ResultSetMetaData rsmd = rs.getMetaData(); + int cols = rsmd.getColumnCount(); + if (rs != null) { + rs.beforeFirst(); + while (rs.next()) { + rows++; + + for (int i = 0; i < cols; i++) { + System.out.print(rs.getString(i + 1) + " "); + } + System.out.println(); + } + } + + return rows; + } + + + // Insert common tests here + + /* + * Validate that getCommand() returns null by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0000(RowSet rs) { + assertNull(rs.getCommand()); + } + + /* + * Validate that getCommand() returns command specified to setCommand + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0001(RowSet rs) throws Exception { + rs.setCommand(query); + assertTrue(rs.getCommand().equals(query)); + } + + + /* + * Validate that getCurrency() returns the correct default value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0002(RowSet rs) throws Exception { + assertTrue(rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + } + + /* + * Validate that getCurrency() returns the correct value + * after a call to setConcurrency()) + */ + @Test(dataProvider = "rowSetConcurrencyTypes") + public void commonRowSetTest0003(RowSet rs, int concurType) throws Exception { + rs.setConcurrency(concurType); + assertTrue(rs.getConcurrency() == concurType); + } + + /* + * Validate that getCurrency() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0004(RowSet rs) throws Exception { + rs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT); + } + + /* + * Validate that getDataSourceName() returns null by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0005(RowSet rs) throws Exception { + assertTrue(rs.getDataSourceName() == null); + } + + /* + * Validate that getDataSourceName() returns the value specified + * by setDataSourceName() and getUrl() returns null + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0006(RowSet rs) throws Exception { + rs.setUrl(url); + rs.setDataSourceName(dsName); + assertTrue(rs.getDataSourceName().equals(dsName)); + assertNull(rs.getUrl()); + } + + /* + * Validate that setDataSourceName() throws a SQLException for an empty + * String specified for the data source name + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0007(RowSet rs) throws Exception { + String dsname = ""; + rs.setDataSourceName(dsname); + } + + /* + * Validate that getEscapeProcessing() returns false by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0008(RowSet rs) throws Exception { + assertTrue(rs.getEscapeProcessing()); + } + + /* + * Validate that getEscapeProcessing() returns value set by + * setEscapeProcessing() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0009(RowSet rs, boolean val) throws Exception { + rs.setEscapeProcessing(val); + assertTrue(rs.getEscapeProcessing() == val); + } + + /* + * Validate that getFetchDirection() returns the correct default value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0010(RowSet rs) throws Exception { + assertTrue(rs.getFetchDirection() == ResultSet.FETCH_FORWARD); + } + + /* + * Validate that getFetchDirection() returns the value set by + * setFetchDirection() + */ + @Test(dataProvider = "rowSetFetchDirection") + public void commonRowSetTest0011(RowSet rs, int direction) throws Exception { + rs.setFetchDirection(direction); + assertTrue(rs.getFetchDirection() == direction); + } + + /* + * Validate that setFetchSize() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0013(RowSet rs) throws Exception { + rs.setFetchSize(-1); + } + + /* + * Validate that setFetchSize() throws a SQLException for a + * value greater than getMaxRows() + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0014(RowSet rs) throws Exception { + rs.setMaxRows(5); + rs.setFetchSize(rs.getMaxRows() + 1); + } + + /* + * Validate that getFetchSize() returns the correct value after + * setFetchSize() has been called + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0015(RowSet rs) throws Exception { + int maxRows = 150; + rs.setFetchSize(0); + assertTrue(rs.getFetchSize() == 0); + rs.setFetchSize(100); + assertTrue(rs.getFetchSize() == 100); + rs.setMaxRows(maxRows); + rs.setFetchSize(maxRows); + assertTrue(rs.getFetchSize() == maxRows); + } + + /* + * Validate that setMaxFieldSize() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0016(RowSet rs) throws Exception { + rs.setMaxFieldSize(-1); + } + + /* + * Validate that getMaxFieldSize() returns the value set by + * setMaxFieldSize() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0017(RowSet rs) throws Exception { + rs.setMaxFieldSize(0); + assertTrue(rs.getMaxFieldSize() == 0); + rs.setMaxFieldSize(100); + assertTrue(rs.getMaxFieldSize() == 100); + rs.setMaxFieldSize(50); + assertTrue(rs.getMaxFieldSize() == 50); + } + + /* + * Validate that isReadOnly() returns value set by + * setReadOnly() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0018(RowSet rs, boolean val) throws Exception { + rs.setReadOnly(val); + assertTrue(rs.isReadOnly() == val); + } + + /* + * Validate that getTransactionIsolation() returns value set by + * setTransactionIsolation() + */ + @Test(dataProvider = "rowSetIsolationTypes") + public void commonRowSetTest0019(RowSet rs, int val) throws Exception { + rs.setTransactionIsolation(val); + assertTrue(rs.getTransactionIsolation() == val); + } + + /* + * Validate that getType() returns value set by setType() + */ + @Test(dataProvider = "rowSetScrollTypes") + public void commonRowSetTest0020(RowSet rs, int val) throws Exception { + rs.setType(val); + assertTrue(rs.getType() == val); + } + + /* + * Validate that getEscapeProcessing() returns value set by + * setEscapeProcessing() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0021(BaseRowSet rs, boolean val) throws Exception { + rs.setShowDeleted(val); + assertTrue(rs.getShowDeleted() == val); + } + + /* + * Validate that getTypeMap() returns same value set by + * setTypeMap() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0022(RowSet rs) throws Exception { + Map> map = new HashMap<>(); + map.put("SUPERHERO", Class.forName("util.SuperHero")); + rs.setTypeMap(map); + assertTrue(rs.getTypeMap().equals(map)); + } + + /* + * Validate that getUsername() returns same value set by + * setUsername() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0023(RowSet rs) throws Exception { + rs.setUsername(user); + assertTrue(rs.getUsername().equals(user)); + } + + /* + * Validate that getPassword() returns same password set by + * setPassword() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0024(RowSet rs) throws Exception { + rs.setPassword(password); + assertTrue(rs.getPassword().equals(password)); + } + + /* + * Validate that getQueryTimeout() returns same value set by + * setQueryTimeout() and that 0 is a valid timeout value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0025(RowSet rs) throws Exception { + int timeout = 0; + rs.setQueryTimeout(timeout); + assertTrue(rs.getQueryTimeout() == timeout); + } + + /* + * Validate that getQueryTimeout() returns same value set by + * setQueryTimeout() and that 0 is a valid timeout value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0026(RowSet rs) throws Exception { + int timeout = 10000; + rs.setQueryTimeout(timeout); + assertTrue(rs.getQueryTimeout() == timeout); + } + + /* + * Validate that setQueryTimeout() throws a SQLException for a timeout + * value < 0 + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0027(RowSet rs) throws Exception { + rs.setQueryTimeout(-1); + } + + + /* + * Validate addRowSetListener does not throw an Exception when null is + * passed as the parameter + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0028(RowSet rs) throws Exception { + rs.addRowSetListener(null); + } + + /* + * Validate removeRowSetListener does not throw an Exception when null is + * passed as the parameter + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0029(RowSet rs) throws Exception { + rs.removeRowSetListener(null); + } + + /* + * Set two parameters and then validate clearParameters() will clear them + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0030(BaseRowSet rs) throws Exception { + rs.setInt(1, 1); + rs.setString(2, query); + assertTrue(rs.getParams().length == 2); + rs.clearParameters(); + assertTrue(rs.getParams().length == 0); + } + + /* + * Validate that getURL() returns same value set by + * setURL() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0031(RowSet rs) throws Exception { + rs.setUrl(url); + assertTrue(rs.getUrl().equals(url)); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0100(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0101(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0102(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0103(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0104(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0105(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0106(RowSet rs) throws Exception { + rs.setBigDecimal("one", BigDecimal.ONE); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0107(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0108(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0109(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0110(RowSet rs) throws Exception { + rs.setBlob("one", new StubBlob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0111(RowSet rs) throws Exception { + rs.setBoolean("one", true); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0112(RowSet rs) throws Exception { + byte b = 1; + rs.setByte("one", b); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0113(RowSet rs) throws Exception { + byte b = 1; + rs.setBytes("one", new byte[10]); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0114(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0115(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0116(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0117(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0118(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0119(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0120(RowSet rs) throws Exception { + rs.setClob("one", new StubClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0121(RowSet rs) throws Exception { + rs.setDate("one", Date.valueOf(LocalDate.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0122(RowSet rs) throws Exception { + rs.setDate("one", Date.valueOf(LocalDate.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0123(RowSet rs) throws Exception { + rs.setTime("one", Time.valueOf(LocalTime.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0124(RowSet rs) throws Exception { + rs.setTime("one", Time.valueOf(LocalTime.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0125(RowSet rs) throws Exception { + rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0126(RowSet rs) throws Exception { + rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0127(RowSet rs) throws Exception { + rs.setDouble("one", 2.0d); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0128(RowSet rs) throws Exception { + rs.setFloat("one", 2.0f); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0129(RowSet rs) throws Exception { + rs.setInt("one", 21); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0130(RowSet rs) throws Exception { + rs.setLong("one", 21l); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0131(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0132(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0133(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0134(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream(1, rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0135(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0136(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0137(RowSet rs) throws Exception { + rs.setNClob("one", new StubNClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0138(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNClob(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0139(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNClob(1, rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0140(RowSet rs) throws Exception { + rs.setNClob(1, new StubNClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0141(RowSet rs) throws Exception { + rs.setNString(1, query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0142(RowSet rs) throws Exception { + rs.setNull("one", Types.INTEGER); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0143(RowSet rs) throws Exception { + rs.setNull("one", Types.INTEGER, "my.type"); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0144(RowSet rs) throws Exception { + rs.setObject("one", query, Types.VARCHAR); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0145(RowSet rs) throws Exception { + rs.setObject("one", query, Types.VARCHAR, 0); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0146(RowSet rs) throws Exception { + rs.setObject("one", query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0147(RowSet rs) throws Exception { + RowId aRowid = null; + rs.setRowId("one", aRowid); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0148(RowSet rs) throws Exception { + rs.setSQLXML("one", new StubSQLXML()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0149(RowSet rs) throws Exception { + rs.setSQLXML(1, new StubSQLXML()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0150(RowSet rs) throws Exception { + rs.setNString(1, query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0151(RowSet rs) throws Exception { + rs.setNString("one", query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0152(RowSet rs) throws Exception { + short val = 21; + rs.setShort("one", val); + } + +} diff --git a/test/javax/sql/testng/test/rowset/RowSetFactoryTests.java b/test/javax/sql/testng/test/rowset/RowSetFactoryTests.java new file mode 100644 index 0000000000000000000000000000000000000000..72a4341c7aa05796eeaf6cd9ca3db1845781bab4 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/RowSetFactoryTests.java @@ -0,0 +1,119 @@ +/* + * 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.SQLException; +import javax.sql.rowset.RowSetFactory; +import javax.sql.rowset.RowSetProvider; +import static org.testng.Assert.*; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import util.BaseTest; + +public class RowSetFactoryTests extends BaseTest { + + // RowSet implementations that we are testing for + private final String DEFAULT_CACHEDROWSET_CLASSNAME = "com.sun.rowset.CachedRowSetImpl"; + private final String DEFAULT_FILTEREDROWSET_CLASSNAME = "com.sun.rowset.FileteredRowSetImpl"; + private final String DEFAULT_JDBCROWSET_CLASSNAME = "com.sun.rowset.JdbcRowSetImpl"; + private final String DEFAULT_JOINROWSET_CLASSNAME = "com.sun.rowset.JoinRowSetImpl"; + private final String DEFAULT_WEBROWSET_CLASSNAME = "com.sun.rowset.WebRowSetImpl"; + private final String STUB_FACTORY_CLASSNAME = "util.StubRowSetFactory"; + private final String STUB_CACHEDROWSET_CLASSNAME = "util.StubCachedRowSetImpl"; + private final String STUB_FILTEREDROWSET_CLASSNAME = "util.StubFilteredRowSetImpl"; + private final String STUB_JDBCROWSET_CLASSNAME = "util.StubJdbcRowSetImpl"; + private final String STUB_JOINROWSET_CLASSNAME = "util.StubJoinRowSetImpl"; + private final String STUB_WEBROWSET_CLASSNAME = "util.StubWebRowSetImpl"; + + + /* + * Validate that the RowSetFactory returned by RowSetProvider.newFactory() + * returns the correct RowSet implementations + */ + @Test(dataProvider = "RowSetValues", enabled = true) + public void test(RowSetFactory rsf, String impl) throws SQLException { + validateRowSetImpl(rsf, impl); + } + + /* + * Utility Method to validate the RowsetFactory returns the correct + * RowSet implementation + */ + private void validateRowSetImpl(RowSetFactory rsf, String implName) + throws SQLException { + assertNotNull(rsf, "RowSetFactory should not be null"); + switch (implName) { + case DEFAULT_CACHEDROWSET_CLASSNAME: + assertTrue(rsf.createCachedRowSet() instanceof com.sun.rowset.CachedRowSetImpl); + break; + case DEFAULT_FILTEREDROWSET_CLASSNAME: + assertTrue(rsf.createFilteredRowSet() instanceof com.sun.rowset.FilteredRowSetImpl); + break; + case DEFAULT_JDBCROWSET_CLASSNAME: + assertTrue(rsf.createJdbcRowSet() instanceof com.sun.rowset.JdbcRowSetImpl); + break; + case DEFAULT_JOINROWSET_CLASSNAME: + assertTrue(rsf.createJoinRowSet() instanceof com.sun.rowset.JoinRowSetImpl); + break; + case DEFAULT_WEBROWSET_CLASSNAME: + assertTrue(rsf.createWebRowSet() instanceof com.sun.rowset.WebRowSetImpl); + break; + case STUB_CACHEDROWSET_CLASSNAME: + assertTrue(rsf.createCachedRowSet() instanceof util.StubCachedRowSetImpl); + break; + case STUB_FILTEREDROWSET_CLASSNAME: + assertTrue(rsf.createFilteredRowSet() instanceof util.StubFilteredRowSetImpl); + break; + case STUB_JDBCROWSET_CLASSNAME: + assertTrue(rsf.createJdbcRowSet() instanceof util.StubJdbcRowSetImpl); + break; + case STUB_WEBROWSET_CLASSNAME: + assertTrue(rsf.createWebRowSet() instanceof util.StubWebRowSetImpl); + break; + } + + } + + /* + * DataProvider used to provide the RowSetFactory and the RowSet + * implementation that should be returned + */ + @DataProvider(name = "RowSetValues") + private Object[][] RowSetValues() throws SQLException { + RowSetFactory rsf = RowSetProvider.newFactory(); + RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null); + return new Object[][]{ + {rsf, DEFAULT_CACHEDROWSET_CLASSNAME}, + {rsf, DEFAULT_FILTEREDROWSET_CLASSNAME}, + {rsf, DEFAULT_JDBCROWSET_CLASSNAME}, + {rsf, DEFAULT_JOINROWSET_CLASSNAME}, + {rsf, DEFAULT_WEBROWSET_CLASSNAME}, + {rsf1, STUB_CACHEDROWSET_CLASSNAME}, + {rsf1, STUB_FILTEREDROWSET_CLASSNAME}, + {rsf1, STUB_JDBCROWSET_CLASSNAME}, + {rsf1, STUB_JOINROWSET_CLASSNAME}, + {rsf1, STUB_WEBROWSET_CLASSNAME} + + }; + } +} diff --git a/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java b/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java new file mode 100644 index 0000000000000000000000000000000000000000..8a944a8bbb1260319dc4b0b8ad75b0c3d6ebc0e8 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java @@ -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"} + + }; + + } + +} diff --git a/test/javax/sql/testng/test/rowset/RowSetProviderTests.java b/test/javax/sql/testng/test/rowset/RowSetProviderTests.java new file mode 100644 index 0000000000000000000000000000000000000000..47a5cdb1eb08ee60f5797c7f9c8c618b319afd20 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/RowSetProviderTests.java @@ -0,0 +1,189 @@ +/* + * 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 com.sun.rowset.RowSetFactoryImpl; +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; +import java.sql.SQLException; +import javax.sql.rowset.RowSetFactory; +import javax.sql.rowset.RowSetProvider; +import static org.testng.Assert.*; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubRowSetFactory; + +public class RowSetProviderTests extends BaseTest { + + // Default RowSetFactory Implementation + private final String DEFFAULT_FACTORY_CLASSNAME = "com.sun.rowset.RowSetFactoryImpl"; + // Stub RowSetFactory Implementation + private final String STUB_FACTORY_CLASSNAME = "util.StubRowSetFactory"; + // Indicator that the factory implementation does not need to be checked + private final String NO_VALADATE_IMPL = ""; + // Original System property value for javax.sql.rowset.RowSetFactory + private static String origFactoryProperty; + // Original ClassLoader + private static ClassLoader cl; + // Path to the location of the jar files used by the ServiceLoader API + private static String jarPath; + + /* + * Save off the original property value for javax.sql.rowset.RowSetFactory, + * original classloader and define the path to the jars directory + */ + @BeforeClass + public static void setUpClass() throws Exception { + origFactoryProperty = System.getProperty("javax.sql.rowset.RowSetFactory"); + cl = Thread.currentThread().getContextClassLoader(); + jarPath = System.getProperty("test.src", ".") + File.separatorChar + + "jars" + File.separatorChar; + } + + /* + * Install the original javax.sql.rowset.RowSetFactory property value + */ + @AfterClass + public static void tearDownClass() throws Exception { + if (origFactoryProperty != null) { + System.setProperty("javax.sql.rowset.RowSetFactory", + origFactoryProperty); + } + } + + /* + * Clear the javax.sql.rowset.RowSetFactory property value and + * reset the classloader to its original value + */ + @AfterMethod + public void tearDownMethod() throws Exception { + System.clearProperty("javax.sql.rowset.RowSetFactory"); + Thread.currentThread().setContextClassLoader(cl); + } + + /* + * Validate that the correct RowSetFactory is returned by newFactory(). + */ + @Test(dataProvider = "RowSetFactoryValues") + public void test(RowSetFactory rsf, String impl) throws SQLException { + validateProvider(rsf, impl); + } + + /* + * Validate that the default RowSetFactory is returned by newFactory() + * when specified by the javax.sql.rowset.RowSetFactory property. + */ + @Test + public void test01() throws SQLException { + System.setProperty("javax.sql.rowset.RowSetFactory", + DEFFAULT_FACTORY_CLASSNAME); + validateProvider(RowSetProvider.newFactory(), DEFFAULT_FACTORY_CLASSNAME); + } + + /* + * Validate that the correct RowSetFactory is returned by newFactory() + * when specified by the javax.sql.rowset.RowSetFactory property. + */ + @Test(enabled = true) + public void test02() throws SQLException { + System.setProperty("javax.sql.rowset.RowSetFactory", STUB_FACTORY_CLASSNAME); + validateProvider(RowSetProvider.newFactory(), STUB_FACTORY_CLASSNAME); + } + + /* + * Validate that a SQLException is thrown by newFactory() + * when specified RowSetFactory specified by the + * javax.sql.rowset.RowSetFactory property is not valid. + */ + @Test(expectedExceptions = SQLException.class) + public void test03() throws SQLException { + System.setProperty("javax.sql.rowset.RowSetFactory", + "invalid.RowSetFactoryImpl"); + RowSetFactory rsf = RowSetProvider.newFactory(); + } + + /* + * Validate that the correct RowSetFactory is returned by newFactory() + * when specified by the ServiceLoader API. + */ + @Test + public void test04() throws Exception { + File f = new File(jarPath + "goodFactory"); + URLClassLoader loader = new URLClassLoader(new URL[]{ + new URL(f.toURI().toString())}, getClass().getClassLoader()); + Thread.currentThread().setContextClassLoader(loader); + validateProvider(RowSetProvider.newFactory(), STUB_FACTORY_CLASSNAME); + } + + /* + * Validate that a SQLException is thrown by newFactory() if the default + * RowSetFactory specified by the ServiceLoader API is not valid + */ + @Test(expectedExceptions = SQLException.class) + public void test05() throws Exception { + File f = new File(jarPath + "badFactory"); + URLClassLoader loader = new URLClassLoader(new URL[]{ + new URL(f.toURI().toString())}, getClass().getClassLoader()); + Thread.currentThread().setContextClassLoader(loader); + RowSetProvider.newFactory(); + } + + /* + * Utility Method to validate that the RowsetFactory returned from + * RowSetProvider.newFactory() is correct + */ + private void validateProvider(RowSetFactory rsf, String implName) { + assertNotNull(rsf, "RowSetFactory should not be null"); + switch (implName) { + case DEFFAULT_FACTORY_CLASSNAME: + assertTrue(rsf instanceof RowSetFactoryImpl); + break; + case STUB_FACTORY_CLASSNAME: + assertTrue(rsf instanceof StubRowSetFactory); + break; + default: + } + } + + /* + * DataProvider used to provide a RowSetFactory and the expected + * RowSetFactory implementation that should be returned + */ + @DataProvider(name = "RowSetFactoryValues") + private Object[][] RowSetFactoryValues() throws SQLException { + RowSetFactory rsf = RowSetProvider.newFactory(); + RowSetFactory rsf1 = RowSetProvider.newFactory(STUB_FACTORY_CLASSNAME, null); + RowSetFactory rsf2 = RowSetProvider.newFactory(DEFFAULT_FACTORY_CLASSNAME, null); + return new Object[][]{ + {rsf, NO_VALADATE_IMPL}, + {rsf, DEFFAULT_FACTORY_CLASSNAME}, + {rsf1, STUB_FACTORY_CLASSNAME}, + {rsf2, DEFFAULT_FACTORY_CLASSNAME} + }; + } +} diff --git a/test/javax/sql/testng/test/rowset/RowSetWarningTests.java b/test/javax/sql/testng/test/rowset/RowSetWarningTests.java new file mode 100644 index 0000000000000000000000000000000000000000..41b52c4ef576354fe0020038ef67a166d9d4e7a3 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/RowSetWarningTests.java @@ -0,0 +1,238 @@ +/* + * 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.SQLException; +import javax.sql.rowset.RowSetWarning; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; + +public class RowSetWarningTests extends BaseTest { + + private final String[] warnings = {"Warning 1", "cause 1", "Warning 2", + "Warning 3", "cause 2"}; + + /* + * Create RowSetWarning and setting all objects to null + */ + @Test + public void test() { + RowSetWarning e = new RowSetWarning(null, null, errorCode); + assertTrue(e.getMessage() == null && e.getSQLState() == null + && e.getCause() == null && e.getErrorCode() == errorCode); + } + + /* + * Create RowSetWarning with no-arg constructor + */ + @Test + public void test01() { + RowSetWarning ex = new RowSetWarning(); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Create RowSetWarning with message + */ + @Test + public void test02() { + RowSetWarning ex = new RowSetWarning(reason); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Create RowSetWarning with message, and SQLState + */ + @Test + public void test03() { + + RowSetWarning ex = new RowSetWarning(reason, state); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState().equals(state) + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Create RowSetWarning with message, SQLState, and error code + */ + @Test + public void test04() { + RowSetWarning ex = new RowSetWarning(reason, state, errorCode); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState().equals(state) + && ex.getCause() == null + && ex.getErrorCode() == errorCode); + } + + /* + * Serialize a RowSetWarning and make sure you can read it back properly + */ + @Test + public void test05() throws Exception { + RowSetWarning e = new RowSetWarning(reason, state, errorCode); + e.initCause(t); + RowSetWarning 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 test06() { + RowSetWarning ex = new RowSetWarning("Exception 1"); + ex.initCause(t1); + RowSetWarning ex1 = new RowSetWarning("Exception 2"); + RowSetWarning ex2 = new RowSetWarning("Exception 3"); + ex2.initCause(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 test07() { + RowSetWarning ex = new RowSetWarning("Exception 1"); + ex.initCause(t1); + RowSetWarning ex1 = new RowSetWarning("Exception 2"); + RowSetWarning ex2 = new RowSetWarning("Exception 3"); + ex2.initCause(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 RowSetWarning is correct using + * for-each loop + */ + @Test + public void test08() { + RowSetWarning ex = new RowSetWarning("Warning 1"); + ex.initCause(t1); + RowSetWarning ex1 = new RowSetWarning("Warning 2"); + RowSetWarning ex2 = new RowSetWarning("Warning 3"); + ex2.initCause(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 RowSetWarning is correct using + * traditional while loop + */ + @Test + public void test09() { + RowSetWarning ex = new RowSetWarning("Warning 1"); + ex.initCause(t1); + RowSetWarning ex1 = new RowSetWarning("Warning 2"); + RowSetWarning ex2 = new RowSetWarning("Warning 3"); + ex2.initCause(t2); + ex.setNextWarning(ex1); + ex.setNextWarning(ex2); + int num = 0; + RowSetWarning 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(); + } + } + + /* + * Serialize a RowSetWarning and make sure you can read it back properly + */ + @Test + public void test10() throws Exception { + RowSetWarning e = new RowSetWarning(reason, state, errorCode); + RowSetWarning ex1 = createSerializedException(e); + assertTrue(reason.equals(ex1.getMessage()) + && ex1.getSQLState().equals(state) + && ex1.getCause() == null + && ex1.getErrorCode() == errorCode); + } + + /* + * Serialize a RowSetWarning and make sure you can read it back properly. + * Validate that the ordering of the returned RowSetWarning is correct using + * traditional while loop + */ + @Test + public void test11() throws Exception { + RowSetWarning ex = new RowSetWarning("Warning 1"); + ex.initCause(t1); + RowSetWarning ex1 = new RowSetWarning("Warning 2"); + RowSetWarning ex2 = new RowSetWarning("Warning 3"); + ex2.initCause(t2); + ex.setNextWarning(ex1); + ex.setNextWarning(ex2); + int num = 0; + RowSetWarning sqe = createSerializedException(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(); + } + } +} diff --git a/test/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java b/test/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..1155a8891875cb78ce0408f7fff1ec4753924572 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, 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.cachedrowset; + +import java.sql.SQLException; +import javax.sql.rowset.CachedRowSet; + +public class CachedRowSetTests extends CommonCachedRowSetTests { + + @Override + protected CachedRowSet newInstance() throws SQLException { + return rsf.createCachedRowSet(); + } + +} diff --git a/test/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java b/test/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..7b04443e23f2ea5a8915738dcc932b048fba6c34 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java @@ -0,0 +1,1612 @@ +/* + * Copyright (c) 2015, 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.cachedrowset; + +import java.math.BigDecimal; +import java.sql.Array; +import java.sql.Date; +import java.sql.JDBCType; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Collection; +import javax.sql.RowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.serial.SerialRef; +import javax.sql.rowset.spi.SyncFactory; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import test.rowset.CommonRowSetTests; +import util.StubArray; +import util.StubRef; +import util.StubSyncProvider; +import util.TestRowSetListener; + +public abstract class CommonCachedRowSetTests extends CommonRowSetTests { + + /* + * DATATYPES Table column names + */ + private final String[] DATATYPES_COLUMN_NAMES = {"AINTEGER", "ACHAR", + "AVARCHAR", "ALONG", "ABOOLEAN", "ASHORT", "ADOUBLE", "ABIGDECIMAL", + "AREAL", "ABYTE", "ADATE", "ATIME", "ATIMESTAMP", "ABYTES", "ARRAY", + "AREF", "AFLOAT"}; + + /* + * Initializes a RowSet containing the DATAYPES data + */ + protected T createDataTypesRowSet() throws SQLException { + T rs = (T) newInstance(); + initDataTypesMetaData((CachedRowSet) rs); + createDataTypesRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + //DataProviders to use for common tests + + /* + * DataProvider that uses a RowSet with the COFFEE_HOUSES Table + */ + @DataProvider(name = "rowsetUsingCoffeeHouses") + protected Object[][] rowsetUsingCoffeeHouses() throws Exception { + RowSet rs = createCoffeeHousesRowSet(); + return new Object[][]{ + {rs} + }; + } + + /* + * DataProvider that uses a RowSet with the COFFEES Table + */ + @DataProvider(name = "rowsetUsingCoffees") + protected Object[][] rowsetUsingCoffees() throws Exception { + RowSet rs = createCoffeesRowSet(); + return new Object[][]{ + {rs} + }; + } + + /* + * DataProvider that uses a RowSet with the DATAYPES Table and + * used to validate the various supported data types + */ + @DataProvider(name = "rowsetUsingDataTypes") + protected Object[][] rowsetUsingDataTypes() throws Exception { + + CachedRowSet rs = createDataTypesRowSet(); + return new Object[][]{ + {rs, JDBCType.INTEGER}, + {rs, JDBCType.CHAR}, + {rs, JDBCType.VARCHAR}, + {rs, JDBCType.BIGINT}, + {rs, JDBCType.BOOLEAN}, + {rs, JDBCType.SMALLINT}, + {rs, JDBCType.DOUBLE}, + {rs, JDBCType.DECIMAL}, + {rs, JDBCType.REAL}, + {rs, JDBCType.TINYINT}, + {rs, JDBCType.DATE}, + {rs, JDBCType.TIME}, + {rs, JDBCType.TIMESTAMP}, + {rs, JDBCType.VARBINARY}, + {rs, JDBCType.ARRAY}, + {rs, JDBCType.REF}, + {rs, JDBCType.FLOAT} + }; + } + + /* + * Initializes the DATAYPES table metadata + */ + protected void initDataTypesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + rsmd.setColumnCount(DATATYPES_COLUMN_NAMES.length); + + for (int i = 1; i <= DATATYPES_COLUMN_NAMES.length; i++) { + rsmd.setColumnName(i, DATATYPES_COLUMN_NAMES[i - 1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.CHAR); + rsmd.setColumnType(3, Types.VARCHAR); + rsmd.setColumnType(4, Types.BIGINT); + rsmd.setColumnType(5, Types.BOOLEAN); + rsmd.setColumnType(6, Types.SMALLINT); + rsmd.setColumnType(7, Types.DOUBLE); + rsmd.setColumnType(8, Types.DECIMAL); + rsmd.setColumnType(9, Types.REAL); + rsmd.setColumnType(10, Types.TINYINT); + rsmd.setColumnType(11, Types.DATE); + rsmd.setColumnType(12, Types.TIME); + rsmd.setColumnType(13, Types.TIMESTAMP); + rsmd.setColumnType(14, Types.VARBINARY); + rsmd.setColumnType(15, Types.ARRAY); + rsmd.setColumnType(16, Types.REF); + rsmd.setColumnType(17, Types.FLOAT); + crs.setMetaData(rsmd); + + } + + /* + * Add rows to DATAYPES table + */ + protected void createDataTypesRows(RowSet crs) throws SQLException { + + Integer aInteger = 100; + String aChar = "Oswald Cobblepot"; + Long aLong = Long.MAX_VALUE; + Short aShort = Short.MAX_VALUE; + Double aDouble = Double.MAX_VALUE; + BigDecimal aBigDecimal = BigDecimal.ONE; + Boolean aBoolean = false; + Float aFloat = Float.MAX_VALUE; + Byte aByte = Byte.MAX_VALUE; + Date aDate = Date.valueOf(LocalDate.now()); + Time aTime = Time.valueOf(LocalTime.now()); + Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now()); + Array aArray = new StubArray("INTEGER", new Object[1]); + Ref aRef = new SerialRef(new StubRef("INTEGER", query)); + byte[] bytes = new byte[10]; + crs.moveToInsertRow(); + crs.updateInt(1, aInteger); + crs.updateString(2, aChar); + crs.updateString(3, aChar); + crs.updateLong(4, aLong); + crs.updateBoolean(5, aBoolean); + crs.updateShort(6, aShort); + crs.updateDouble(7, aDouble); + crs.updateBigDecimal(8, aBigDecimal); + crs.updateFloat(9, aFloat); + crs.updateByte(10, aByte); + crs.updateDate(11, aDate); + crs.updateTime(12, aTime); + crs.updateTimestamp(13, aTimeStamp); + crs.updateBytes(14, bytes); + crs.updateArray(15, aArray); + crs.updateRef(16, aRef); + crs.updateDouble(17, aDouble); + crs.insertRow(); + crs.moveToCurrentRow(); + + } + + /* + * Dermine if a Row exists in a ResultSet by its primary key + * If the parameter deleteRow is true, delete the row and validate + * the RowSet indicates it is deleted + */ + protected boolean findRowByPrimaryKey(RowSet rs, int id, int idPos, + boolean deleteRow) throws Exception { + boolean foundRow = false; + rs.beforeFirst(); + while (rs.next()) { + if (rs.getInt(idPos) == id) { + foundRow = true; + if (deleteRow) { + rs.deleteRow(); + // validate row is marked as deleted + assertTrue(rs.rowDeleted()); + } + break; + } + } + return foundRow; + } + + /* + * Wrapper method to find if a row exists within a RowSet by its primary key + */ + protected boolean findRowByPrimaryKey(RowSet rs, int id, int idPos) throws Exception { + return findRowByPrimaryKey(rs, id, idPos, false); + } + + /* + * Wrapper method to find if a row exists within a RowSet by its primary key + * and delete it + */ + protected boolean deleteRowByPrimaryKey(RowSet rs, int id, int idPos) throws Exception { + return findRowByPrimaryKey(rs, id, idPos, true); + } + + /* + * Utility method that compares two ResultSetMetaDataImpls for containing + * the same values + */ + private void compareMetaData(ResultSetMetaData rsmd, + ResultSetMetaData rsmd1) throws SQLException { + + assertEquals(rsmd1.getColumnCount(), rsmd.getColumnCount()); + int cols = rsmd.getColumnCount(); + for (int i = 1; i <= cols; i++) { + assertTrue(rsmd1.getCatalogName(i).equals(rsmd.getCatalogName(i))); + assertTrue(rsmd1.getColumnClassName(i).equals(rsmd.getColumnClassName(i))); + assertTrue(rsmd1.getColumnDisplaySize(i) == rsmd.getColumnDisplaySize(i)); + assertTrue(rsmd1.getColumnLabel(i).equals(rsmd.getColumnLabel(i))); + assertTrue(rsmd1.getColumnName(i).equals(rsmd.getColumnName(i))); + assertTrue(rsmd1.getColumnType(i) == rsmd.getColumnType(i)); + assertTrue(rsmd1.getPrecision(i) == rsmd.getPrecision(i)); + assertTrue(rsmd1.getScale(i) == rsmd.getScale(i)); + assertTrue(rsmd1.getSchemaName(i).equals(rsmd.getSchemaName(i))); + assertTrue(rsmd1.getTableName(i).equals(rsmd.getTableName(i))); + assertTrue(rsmd1.isAutoIncrement(i) == rsmd.isAutoIncrement(i)); + assertTrue(rsmd1.isCaseSensitive(i) == rsmd.isCaseSensitive(i)); + assertTrue(rsmd1.isCurrency(i) == rsmd.isCurrency(i)); + assertTrue(rsmd1.isDefinitelyWritable(i) == rsmd.isDefinitelyWritable(i)); + assertTrue(rsmd1.isNullable(i) == rsmd.isNullable(i)); + assertTrue(rsmd1.isReadOnly(i) == rsmd.isReadOnly(i)); + assertTrue(rsmd1.isSearchable(i) == rsmd.isSearchable(i)); + assertTrue(rsmd1.isSigned(i) == rsmd.isSigned(i)); + assertTrue(rsmd1.isWritable(i) == rsmd.isWritable(i)); + + } + } + + /* + * Utility method to compare two rowsets + */ + private void compareRowSets(CachedRowSet crs, CachedRowSet crs1) throws Exception { + + int rows = crs.size(); + assertTrue(rows == crs1.size()); + + ResultSetMetaData rsmd = crs.getMetaData(); + + compareMetaData(rsmd, crs1.getMetaData()); + int cols = rsmd.getColumnCount(); + + for (int row = 1; row <= rows; row++) { + crs.absolute((row)); + crs1.absolute(row); + for (int col = 1; col <= cols; col++) { + compareColumnValue(JDBCType.valueOf(rsmd.getColumnType(col)), + crs, crs1, col); + } + } + + } + + /* + * Utility method to compare two columns + */ + private void compareColumnValue(JDBCType type, ResultSet rs, ResultSet rs1, + int col) throws SQLException { + + switch (type) { + case INTEGER: + assertTrue(rs.getInt(col) == rs1.getInt(col)); + break; + case CHAR: + case VARCHAR: + assertTrue(rs.getString(col).equals(rs1.getString(col))); + break; + case BIGINT: + assertTrue(rs.getLong(col) == rs1.getLong(col)); + break; + case BOOLEAN: + assertTrue(rs.getBoolean(col) == rs1.getBoolean(col)); + break; + case SMALLINT: + assertTrue(rs.getShort(col) == rs1.getShort(col)); + break; + case DOUBLE: + case FLOAT: + assertTrue(rs.getDouble(col) == rs1.getDouble(col)); + break; + case DECIMAL: + assertTrue(rs.getBigDecimal(col).equals(rs1.getBigDecimal(col))); + break; + case REAL: + assertTrue(rs.getFloat(col) == rs1.getFloat(col)); + break; + case TINYINT: + assertTrue(rs.getByte(col) == rs1.getByte(col)); + break; + case DATE: + assertTrue(rs.getDate(col).equals(rs1.getDate(col))); + break; + case TIME: + assertTrue(rs.getTime(col).equals(rs1.getTime(col))); + break; + case TIMESTAMP: + assertTrue(rs.getTimestamp(col).equals(rs1.getTimestamp(col))); + break; + } + } + + /* + * Validate SyncProviderException is thrown when acceptChanges is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + public void commonCachedRowSetTest0000(CachedRowSet rs) throws Exception { + rs.acceptChanges(); + rs.close(); + } + + /* + * Validate SyncProviderException is thrown when acceptChanges is called + * when null is passed as the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + public void commonCachedRowSetTest0001(CachedRowSet rs) throws Exception { + rs.acceptChanges(null); + rs.close(); + } + + /* + * Validate that that RIOPtimsticProvider is the default SyncProvider + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0002(CachedRowSet rs) throws SQLException { + SyncProvider sp = rs.getSyncProvider(); + assertTrue(sp instanceof com.sun.rowset.providers.RIOptimisticProvider); + rs.close(); + } + + /* + * Validate that you can specify a SyncProvider + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0003(CachedRowSet rs) throws SQLException { + + // Register a provider and make sure it is avaiable + SyncFactory.registerProvider(stubProvider); + rs.setSyncProvider(stubProvider); + SyncProvider sp = rs.getSyncProvider(); + assertTrue(sp instanceof StubSyncProvider); + SyncFactory.unregisterProvider(stubProvider); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.release(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowChanged is called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0006(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.moveToInsertRow(); + rs.updateInt(1, 10024); + rs.updateString(2, "Sacramento"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 4328); + rs.insertRow(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a multiple RowSetListeners and validate that notifyRowChanged, + * notifiyMoved is called on all listners + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0007(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.first(); + rs.updateInt(1, 1961); + rs.updateString(2, "Pittsburgh"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 6689); + rs.updateRow(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED + | TestRowSetListener.ROW_CHANGED)); + assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED + | TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowChanged and + * notifyCursorMoved are called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + + rs.first(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + rs.deleteRow(); + assertTrue( + rsl.isNotified(TestRowSetListener.ROW_CHANGED | TestRowSetListener.CURSOR_MOVED)); + rsl.resetFlag(); + rs.setShowDeleted(true); + rs.undoDelete(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyCursorMoved is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0009(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.beforeFirst(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + rs.close(); + } + + /* + * Validate that getTableName() returns the proper values + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0010(CachedRowSet rs) throws Exception { + assertNull(rs.getTableName()); + rs.setTableName(COFFEE_HOUSES_TABLE); + assertTrue(rs.getTableName().equals(COFFEE_HOUSES_TABLE)); + rs.close(); + } + + /* + * Validate that getKeyColumns() returns the proper values + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0011(CachedRowSet rs) throws Exception { + int[] pkeys = {1, 3}; + assertNull(rs.getKeyColumns()); + rs.setKeyColumns(pkeys); + assertEquals(rs.getKeyColumns(), pkeys); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0012(CachedRowSet rs) throws Exception { + rs.setMatchColumn(-1); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0013(CachedRowSet rs) throws Exception { + int[] cols = {1, -1}; + rs.setMatchColumn(cols); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0014(CachedRowSet rs) throws Exception { + rs.setMatchColumn((String) null); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0015(CachedRowSet rs) throws Exception { + String[] cols = {"ID", null}; + rs.setMatchColumn(cols); + } + + /* + * Validate that getMatchColumn returns the same value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0016(CachedRowSet rs) throws Exception { + int[] expectedCols = {1}; + String[] expectedColNames = {"ID"}; + rs.setMatchColumn(1); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + for (int i = 0; i < actualCols.length; i++) { + System.out.println(actualCols[i]); + } + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0017(CachedRowSet rs) throws Exception { + int[] expectedCols = {1}; + String[] expectedColNames = {"ID"}; + rs.setMatchColumn(expectedColNames[0]); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same valid value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0018(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedCols); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + assertEquals(actualCols, expectedCols); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same valid value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0019(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedColNames); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumnIndexes throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0020(CachedRowSet rs) throws Exception { + rs.setMatchColumn(1); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(1); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + } + + /* + * Validate that getMatchColumnNames throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0021(CachedRowSet rs) throws Exception { + String matchColumn = "ID"; + rs.setMatchColumn(matchColumn); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(matchColumn); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + } + + /* + * Validate that getMatchColumnIndexes throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0022(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + rs.setMatchColumn(expectedCols); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(expectedCols); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + } + + /* + * Validate that getMatchColumnNames throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0023(CachedRowSet rs) throws Exception { + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedColNames); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(expectedColNames); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + } + + /* + * Validate size() returns the correct number of rows + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0024(CachedRowSet rs) throws Exception { + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + rs.close(); + } + + /* + * Validate that the correct rows are returned comparing the primary + * keys + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0025(RowSet rs) throws SQLException { + assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + rs.close(); + } + + /* + * Delete a row within the RowSet using its primary key + * Validate the visibility of the row depending on the value of + * setShowdelete + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception { + Object[] afterDelete = { + 10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041, + 33005, 33010, 10037, 10034, 32004 + }; + int rowToDelete = 10035; + // All rows should be found + assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + // Delete the row + assertTrue(deleteRowByPrimaryKey(rs, rowToDelete, 1)); + // With setShowDeleted(false) which is the default, + // the deleted row should not be visible + assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1)); + assertEquals(getPrimaryKeys(rs), afterDelete); + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // With setShowDeleted(true), the deleted row should be visible + rs.setShowDeleted(true); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.close(); + } + + /* + * Validate that there is no page size by default + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception { + assertTrue(rs.getPageSize() == 0); + rs.close(); + } + + /* + * Validate the value you set via setPageSize is returned by getPageSize + * then reset to having no limit + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception { + int rows = 100; + rs.setPageSize(rows); + assertTrue(rows == rs.getPageSize()); + rs.setPageSize(0); + assertTrue(rs.getPageSize() == 0); + rs.close(); + } + + /* + * Validate SQLException is thrown when an invalid value is specified + * for setPageSize + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0029(CachedRowSet rs) throws Exception { + rs.setPageSize(-1); + rs.close(); + } + + /* + * Validate SQLException is thrown when nextPage is called without a + * call to populate or execute + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0030(CachedRowSet rs) throws Exception { + rs.nextPage(); + rs.close(); + } + + /* + * Validate SQLException is thrown when previousPage is called without a + * call to populate or execute + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0031(CachedRowSet rs) throws Exception { + rs.previousPage(); + rs.close(); + } + + + /* + * Validate SQLException is thrown when execute is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0032(CachedRowSet rs) throws Exception { + rs.execute(null); + rs.close(); + } + + /* + * Validate SQLException is thrown when execute is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0033(CachedRowSet rs) throws Exception { + rs.execute(); + rs.close(); + } + + /* + * Validate that toCollection() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0034(CachedRowSet rs) throws Exception { + Object[] cities = {"Mendocino", "Seattle", "SF", "Portland", "SF", + "Sacramento", "Carmel", "LA", "Olympia", "Seattle", "SF", + "LA", "San Jose", "Eugene"}; + rs.beforeFirst(); + assertEquals(rs.toCollection(2).toArray(), cities); + assertEquals(rs.toCollection("CITY").toArray(), cities); + rs.close(); + } + + /* + * Validate that toCollection() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0035(CachedRowSet rs) throws Exception { + Collection col = rs.toCollection(); + assertTrue(rs.size() == col.size()); + assertTrue(rs.toCollection().containsAll(col) + && col.containsAll(rs.toCollection())); + try ( // Validate that False is returned when compared to a different RowSet; + CachedRowSet crs1 = createCoffeesRowSet()) { + assertFalse(crs1.toCollection().containsAll(col) + && col.containsAll(crs1.toCollection())); + } + rs.close(); + + } + + /* + * Validate that createCopy() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0036(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rs.createCopy()) { + compareRowSets(rs, crs1); + } + rs.close(); + } + + /* + * Validate that createCopySchema() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rs.createCopySchema()) { + assertTrue(crs1.size() == 0); + compareMetaData(crs1.getMetaData(), rs.getMetaData()); + } + rs.close(); + } + + /* + * Validate that createCopyNoConstraints() returns the proper values + * and getMatchColumnIndexes should throw a SQLException. This test + * specifies setMatchColumn(int) + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0038(CachedRowSet rs) throws Exception { + rs.setMatchColumn(1); + try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { + assertTrue(crs1.size() == COFFEE_HOUSES_ROWS); + compareRowSets(rs, crs1); + boolean recievedSQE = false; + try { + int[] indexes = crs1.getMatchColumnIndexes(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + recievedSQE = false; + try { + String[] colNames = crs1.getMatchColumnNames(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + } + rs.close(); + } + + /* + * Validate that createCopyNoConstraints() returns the proper values + * and getMatchColumnIndexes should throw a SQLException. This test + * specifies setMatchColumn(String) + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0039(CachedRowSet rs) throws Exception { + rs.setMatchColumn("ID"); + try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { + assertTrue(crs1.size() == COFFEE_HOUSES_ROWS); + compareRowSets(rs, crs1); + boolean recievedSQE = false; + try { + int[] indexes = crs1.getMatchColumnIndexes(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + recievedSQE = false; + try { + String[] colNames = crs1.getMatchColumnNames(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + } + rs.close(); + } + + /* + * Validate that columnUpdated works with the various datatypes specifying + * the column index + */ + @Test(dataProvider = "rowsetUsingDataTypes") + public void commonCachedRowSetTest0040(CachedRowSet rs, JDBCType type) throws Exception { + rs.beforeFirst(); + assertTrue(rs.next()); + switch (type) { + case INTEGER: + assertFalse(rs.columnUpdated(1)); + rs.updateInt(1, Integer.MIN_VALUE); + assertTrue(rs.columnUpdated(1)); + break; + case CHAR: + assertFalse(rs.columnUpdated(2)); + rs.updateString(2, "foo"); + assertTrue(rs.columnUpdated(2)); + break; + case VARCHAR: + assertFalse(rs.columnUpdated(3)); + rs.updateString(3, "foo"); + assertTrue(rs.columnUpdated(3)); + break; + case BIGINT: + assertFalse(rs.columnUpdated(4)); + rs.updateLong(4, Long.MIN_VALUE); + assertTrue(rs.columnUpdated(4)); + break; + case BOOLEAN: + assertFalse(rs.columnUpdated(5)); + rs.updateBoolean(5, false); + assertTrue(rs.columnUpdated(5)); + break; + case SMALLINT: + assertFalse(rs.columnUpdated(6)); + rs.updateShort(6, Short.MIN_VALUE); + assertTrue(rs.columnUpdated(6)); + break; + case DOUBLE: + assertFalse(rs.columnUpdated(7)); + rs.updateDouble(7, Double.MIN_VALUE); + assertTrue(rs.columnUpdated(7)); + break; + case DECIMAL: + assertFalse(rs.columnUpdated(8)); + rs.updateBigDecimal(8, BigDecimal.TEN); + assertTrue(rs.columnUpdated(8)); + break; + case REAL: + assertFalse(rs.columnUpdated(9)); + rs.updateFloat(9, Float.MIN_VALUE); + assertTrue(rs.columnUpdated(9)); + break; + case TINYINT: + assertFalse(rs.columnUpdated(10)); + rs.updateByte(10, Byte.MIN_VALUE); + assertTrue(rs.columnUpdated(10)); + break; + case DATE: + assertFalse(rs.columnUpdated(11)); + rs.updateDate(11, Date.valueOf(LocalDate.now())); + assertTrue(rs.columnUpdated(11)); + break; + case TIME: + assertFalse(rs.columnUpdated(12)); + rs.updateTime(12, Time.valueOf(LocalTime.now())); + assertTrue(rs.columnUpdated(12)); + break; + case TIMESTAMP: + assertFalse(rs.columnUpdated(13)); + rs.updateTimestamp(13, Timestamp.valueOf(LocalDateTime.now())); + assertTrue(rs.columnUpdated(13)); + break; + case VARBINARY: + assertFalse(rs.columnUpdated(14)); + rs.updateBytes(14, new byte[1]); + assertTrue(rs.columnUpdated(14)); + break; + case ARRAY: + assertFalse(rs.columnUpdated(15)); + rs.updateArray(15, new StubArray("VARCHAR", new Object[10])); + assertTrue(rs.columnUpdated(15)); + break; + case REF: + assertFalse(rs.columnUpdated(16)); + rs.updateRef(16, new StubRef("INTEGER", query)); + assertTrue(rs.columnUpdated(16)); + break; + case FLOAT: + assertFalse(rs.columnUpdated(17)); + rs.updateDouble(17, Double.MIN_NORMAL); + assertTrue(rs.columnUpdated(17)); + } + + } + + /* + * Validate that columnUpdated works with the various datatypes specifying + * the column name + */ + @Test(dataProvider = "rowsetUsingDataTypes") + public void commonCachedRowSetTest0041(CachedRowSet rs, JDBCType type) throws Exception { + rs.beforeFirst(); + assertTrue(rs.next()); + switch (type) { + case INTEGER: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0])); + rs.updateInt(DATATYPES_COLUMN_NAMES[0], Integer.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0])); + break; + case CHAR: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1])); + rs.updateString(DATATYPES_COLUMN_NAMES[1], "foo"); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1])); + break; + case VARCHAR: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2])); + rs.updateString(DATATYPES_COLUMN_NAMES[2], "foo"); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2])); + break; + case BIGINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3])); + rs.updateLong(DATATYPES_COLUMN_NAMES[3], Long.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3])); + break; + case BOOLEAN: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4])); + rs.updateBoolean(DATATYPES_COLUMN_NAMES[4], false); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4])); + break; + case SMALLINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5])); + rs.updateShort(DATATYPES_COLUMN_NAMES[5], Short.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5])); + break; + case DOUBLE: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6])); + rs.updateDouble(DATATYPES_COLUMN_NAMES[6], Double.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6])); + break; + case DECIMAL: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7])); + rs.updateBigDecimal(DATATYPES_COLUMN_NAMES[7], BigDecimal.TEN); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7])); + break; + case REAL: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8])); + rs.updateFloat(DATATYPES_COLUMN_NAMES[8], Float.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8])); + break; + case TINYINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9])); + rs.updateByte(DATATYPES_COLUMN_NAMES[9], Byte.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9])); + break; + case DATE: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10])); + rs.updateDate(DATATYPES_COLUMN_NAMES[10], Date.valueOf(LocalDate.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10])); + break; + case TIME: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11])); + rs.updateTime(DATATYPES_COLUMN_NAMES[11], Time.valueOf(LocalTime.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11])); + break; + case TIMESTAMP: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12])); + rs.updateTimestamp(DATATYPES_COLUMN_NAMES[12], Timestamp.valueOf(LocalDateTime.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12])); + break; + case VARBINARY: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13])); + rs.updateBytes(DATATYPES_COLUMN_NAMES[13], new byte[1]); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13])); + break; + case ARRAY: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14])); + rs.updateArray(DATATYPES_COLUMN_NAMES[14], new StubArray("VARCHAR", new Object[10])); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14])); + break; + case REF: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15])); + rs.updateRef(DATATYPES_COLUMN_NAMES[15], new StubRef("INTEGER", query)); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15])); + break; + case FLOAT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16])); + rs.updateDouble(DATATYPES_COLUMN_NAMES[16], Double.MIN_NORMAL); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16])); + break; + } + + } + + /* + * Validate isBeforeFirst(), isFirst() and first() return the correct + * results + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0042(RowSet rs) throws Exception { + assertFalse(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.beforeFirst(); + assertTrue(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.next(); + assertFalse(rs.isBeforeFirst()); + assertTrue(rs.isFirst()); + rs.next(); + assertFalse(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.first(); + assertFalse(rs.isBeforeFirst()); + assertTrue(rs.isFirst()); + rs.close(); + } + + /* + * Validate isAfterLast(), isLast() and last() return the correct + * results + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0043(RowSet rs) throws Exception { + assertFalse(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.afterLast(); + assertTrue(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.previous(); + assertFalse(rs.isAfterLast()); + assertTrue(rs.isLast()); + rs.previous(); + assertFalse(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.last(); + assertFalse(rs.isAfterLast()); + assertTrue(rs.isLast()); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0044(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0045(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0046(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0048(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0049(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0050(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoInsert(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoInsert(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0052(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoInsert(); + rs.close(); + } + + /* + * Insert a row, then call undoInsert to roll back the insert and validate + * the row is not there + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToInsert); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.undoInsert(); + // Check to make sure the row is no longer there + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.close(); + } + + /* + * Insert a row, delete the row and then call undoDelete to make sure it + * is comes back + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception { + int rowToDelete = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToDelete); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.deleteRow(); + // Check to make sure the row is no longer there + //assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.setShowDeleted(true); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.undoDelete(); + // check that the row is back + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.close(); + } + + /* + * Insert a row, modify a field and then call undoUpdate to revert the + * insert + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToInsert); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + // Save off the original column values + String f2 = rs.getString(2); + int f3 = rs.getInt(3); + rs.updateString(2, "SMALLVILLE"); + rs.updateInt(3, 500); + // Validate the columns have been updated + assertTrue(rs.columnUpdated(2)); + assertTrue(rs.columnUpdated(3)); + // Undo the update and validate it has taken place + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.undoUpdate(); + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.close(); + } + + /* + * Validate getOriginal returns a ResultSet which is a copy of the original + * RowSet + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void commonCachedRowSetTest0056(CachedRowSet rs) throws Exception { + String coffee = "Hazelnut"; + int sales = 100; + int id = 200; + Object[] updatedPkeys = {1, id, 3, 4, 5}; + // Change the coffee name and sales total for row 2 and save the + // previous values + rs.absolute(2); + int origId = rs.getInt(1); + String origCoffee = rs.getString(2); + int origSales = rs.getInt(5); + rs.updateInt(1, id); + rs.updateString(2, coffee); + rs.updateInt(5, sales); + // MetaData should match + try ( // Get the original original RowSet and validate that the changes + // are only made to the current, not the original + ResultSet rs1 = rs.getOriginal()) { + // MetaData should match + compareMetaData(rs.getMetaData(), rs1.getMetaData()); + assertTrue(rs1.isBeforeFirst()); + assertTrue(rs1.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + assertTrue(rs1.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE); + rs1.absolute(2); + // Check original rowset is not changed + assertTrue(rs1.getInt(1) == origId); + assertTrue(rs1.getString(2).equals(origCoffee)); + assertTrue(rs1.getInt(5) == origSales); + assertEquals(getPrimaryKeys(rs1), COFFEES_PRIMARY_KEYS); + // Check current rowset + assertTrue(rs.getInt(1) == id); + assertTrue(rs.getString(2).equals(coffee)); + assertTrue(rs.getInt(5) == sales); + assertEquals(getPrimaryKeys(rs), updatedPkeys); + } + rs.close(); + } + + /* + * Validate getOriginalRow returns a ResultSet which is a copy of the + * original row that was modified + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void commonCachedRowSetTest0057(CachedRowSet rs) throws Exception { + String coffee = "Hazelnut"; + int sales = 100; + int id = 200; + Object[] updatedPkeys = {1, id, 3, 4, 5}; + // Change the coffee name and sales total for row 2 and save the + // previous values + rs.absolute(2); + int origId = rs.getInt(1); + String origCoffee = rs.getString(2); + int origSales = rs.getInt(5); + rs.updateInt(1, id); + rs.updateString(2, coffee); + rs.updateInt(5, sales); + // MetaData should match + try ( // Get the original original row and validate that the changes + // are only made to the current, not the original + ResultSet rs1 = rs.getOriginalRow()) { + // MetaData should match + compareMetaData(rs.getMetaData(), rs1.getMetaData()); + assertTrue(rs1.isBeforeFirst()); + assertTrue(rs1.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + assertTrue(rs1.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE); + rs1.next(); + assertTrue(rs1.isFirst() && rs1.isLast()); + assertTrue(rs1.getRow() == 1); + // Check original row is not changed + assertTrue(rs1.getInt(1) == origId); + assertTrue(rs1.getString(2).equals(origCoffee)); + assertTrue(rs1.getInt(5) == origSales); + // Check current row + assertTrue(rs.getInt(1) == id); + assertTrue(rs.getString(2).equals(coffee)); + assertTrue(rs.getInt(5) == sales); + assertEquals(getPrimaryKeys(rs), updatedPkeys); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to the insert of a row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0058(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + try ( // Add new row + CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + crs1.moveToInsertRow(); + crs1.updateInt(1, rowToInsert); + crs1.updateString(2, "GOTHAM"); + crs1.updateInt(3, 3450); + crs1.updateInt(4, 2005); + crs1.updateInt(5, 5455); + crs1.insertRow(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + crs1.moveToCurrentRow(); + assertTrue(findRowByPrimaryKey(crs1, rowToInsert, 1)); + // Restore back to our original state and the + // previously inserted row should not be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + crs1.last(); + assertFalse(crs1.rowInserted()); + assertFalse(findRowByPrimaryKey(crs1, rowToInsert, 1)); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to deleting a row + */ + @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception { + int rowToDelete = 2; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + // Delete a row, the PK is also the absolute position as a List + // backs the RowSet + crs1.absolute(rowToDelete); + crs1.deleteRow(); + assertTrue(crs1.rowDeleted()); + assertFalse(findRowByPrimaryKey(crs1, rowToDelete, 1)); + // Restore back to our original state and the + // previously deleted row should be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + crs1.absolute(rowToDelete); + assertFalse(crs1.rowDeleted()); + assertTrue(findRowByPrimaryKey(crs1, rowToDelete, 1)); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to updating a row + */ + @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception { + int rowToUpdate = 2; + String coffee = "Hazelnut"; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + // Delete a row, the PK is also the absolute position as a List + // backs the RowSet + crs1.absolute(rowToUpdate); + String origCoffee = crs1.getString(2); + crs1.updateString(2, coffee); + assertTrue(crs1.columnUpdated(2)); + crs1.updateRow(); + assertTrue(crs1.rowUpdated()); + assertFalse(origCoffee.equals(crs1.getString(2))); + // Restore back to our original state and the + // previous value for the column within the row should be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + // absolute() is failing for some reason so need to look at this later + crs1.next(); + crs1.next(); + assertFalse(crs1.columnUpdated(2)); + assertFalse(crs1.rowUpdated()); + assertTrue(origCoffee.equals(crs1.getString(2))); + } + rs.close(); + } + + /* + * Initialize a RowSet via the populate method. Validate it matches + * the original ResultSet + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0061(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + compareRowSets(rs, crs1); + } + rs.close(); + } + + /* + * Initialize a RowSet via the populate method specifying a starting row. + * Validate it matches the original ResultSet starting for the specofied + * offset + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0062(CachedRowSet rs) throws Exception { + Object[] expectedRows = { + 32001, 10042, 10024, 10039, 10041, 33005, 33010, 10035, 10037, + 10034, 32004 + }; + int startingRow = 4; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs, startingRow); + assertEquals(crs1.size(), COFFEE_HOUSES_ROWS - startingRow + 1); + assertEquals(getPrimaryKeys(crs1), expectedRows); + } + rs.close(); + } + +} diff --git a/test/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java b/test/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..2188c4eed08006b8cc4d22bd202592448fb5f33d --- /dev/null +++ b/test/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2015, 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.filteredrowset; + +import java.sql.SQLException; +import javax.sql.RowSet; +import javax.sql.rowset.Predicate; + +/* + * Simple implementation of Predicate which is used to filter rows based + * on a City. + */ +public class CityFilter implements Predicate { + + private final String[] cities; + private String colName = null; + private int colNumber = -1; + + public CityFilter(String[] cities, String colName) { + this.cities = cities; + this.colName = colName; + } + + public CityFilter(String[] cities, int colNumber) { + this.cities = cities; + this.colNumber = colNumber; + } + + public boolean evaluate(Object value, String colName) { + + if (colName.equalsIgnoreCase(this.colName)) { + for (String city : cities) { + if (city.equalsIgnoreCase((String) value)) { + return true; + } + } + } + return false; + } + + public boolean evaluate(Object value, int colNumber) { + + if (colNumber == this.colNumber) { + for (String city : this.cities) { + if (city.equalsIgnoreCase((String) value)) { + return true; + } + } + } + return false; + } + + public boolean evaluate(RowSet rs) { + + boolean result = false; + + if (rs == null) { + return false; + } + + try { + for (String city : cities) { + + String val = ""; + if (colNumber > 0) { + val = (String) rs.getObject(colNumber); + } else if (colName != null) { + val = (String) rs.getObject(colName); + } + + if (val.equalsIgnoreCase(city)) { + return true; + } + } + } catch (SQLException e) { + result = false; + } + return result; + } +} diff --git a/test/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java b/test/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..263a79a68b6996e3a55e0a6945d506ef72eb4730 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2015, 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.filteredrowset; + +import java.sql.SQLException; +import javax.sql.RowSet; +import javax.sql.rowset.FilteredRowSet; +import javax.sql.rowset.Predicate; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import test.rowset.webrowset.CommonWebRowSetTests; + +public class FilteredRowSetTests extends CommonWebRowSetTests { + + private FilteredRowSet frs; + + @BeforeMethod + public void setUpMethod() throws Exception { + frs = createCoffeeHousesRowSet(); + } + + @AfterMethod + public void tearDownMethod() throws Exception { + frs.close(); + } + + protected FilteredRowSet newInstance() throws SQLException { + return rsf.createFilteredRowSet(); + } + + /* + * Validate getFilter returns null if setFilter has not been called + */ + @Test + public void FilteredRowSetTest0000() throws SQLException { + assertNull(frs.getFilter()); + } + + /* + * Call setFilter to set a Predicate and validate that getFilter + * returns the correct Predicate + */ + @Test + public void FilteredRowSetTest0001() throws SQLException { + Predicate p = new PrimaryKeyFilter(0, 100030, 1); + frs.setFilter(p); + assertTrue(frs.getFilter().equals(p)); + frs.setFilter(null); + assertNull(frs.getFilter()); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column index is used + */ + @Test + public void FilteredRowSetTest0002() throws SQLException { + Object[] expectedKeys = { + 10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034 + }; + frs.setFilter(new PrimaryKeyFilter(10000, 10999, 1)); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column Label is used + */ + @Test + public void FilteredRowSetTest0003() throws SQLException { + Object[] expectedKeys = { + 10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034 + }; + frs.setFilter(new PrimaryKeyFilter(10000, 10999, "STORE_ID")); + assertEquals(getPrimaryKeys(frs), expectedKeys); + + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column index is used + */ + @Test + public void FilteredRowSetTest0004() throws SQLException { + Object[] expectedKeys = { + 10040, 10042, 10041, 10035, 10037 + }; + String[] cityArray = {"SF", "LA"}; + frs.setFilter(new CityFilter(cityArray, 2)); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column Label is used + */ + @Test + public void FilteredRowSetTest0005() throws SQLException { + Object[] expectedKeys = { + 10040, 10042, 10041, 10035, 10037 + }; + String[] cityArray = {"SF", "LA"}; + frs.setFilter(new CityFilter(cityArray, "CITY")); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + + // Tests that are common but need to be disabled due to an implementation bug + + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0043(RowSet rs) throws Exception { + // Need to fix bug in FilteredRowSets + } + +} diff --git a/test/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java b/test/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..2a748314006d2b4cabe62ea3eaefe7155a5bafe3 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015, 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.filteredrowset; + +import javax.sql.RowSet; +import javax.sql.rowset.Predicate; + +/* + * Simple implementation of Predicate which is used to filter rows based + * on the Primary Key. + */ +public class PrimaryKeyFilter implements Predicate { + + private final int lo; + private final int hi; + private String colName = null; + private int colNumber = -1; + + public PrimaryKeyFilter(int lo, int hi, int colNumber) { + this.lo = lo; + this.hi = hi; + this.colNumber = colNumber; + } + + public PrimaryKeyFilter(int lo, int hi, String colName) { + this.lo = lo; + this.hi = hi; + this.colName = colName; + } + + public boolean evaluate(Object value, String columnName) { + + boolean result = false; + if (columnName.equalsIgnoreCase(this.colName)) { + int columnValue = ((Integer) value); + result = (columnValue >= this.lo) && (columnValue <= this.hi); + } + return result; + } + + public boolean evaluate(Object value, int columnNumber) { + + boolean result = false; + if (this.colNumber == columnNumber) { + int columnValue = (Integer) value; + result = (columnValue >= this.lo) && (columnValue <= this.hi); + } + return result; + } + + public boolean evaluate(RowSet rs) { + + boolean result = false; + try { + int columnValue = -1; + + if (this.colNumber > 0) { + columnValue = rs.getInt(this.colNumber); + } else if (this.colName != null) { + columnValue = rs.getInt(this.colName); + } + if ((columnValue >= this.lo) && (columnValue <= this.hi)) { + result = true; + } + + } catch (Exception e) { + System.out.println("Error:" + e.getMessage()); + result = false; + } + return result; + } + +} diff --git a/test/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java b/test/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..b84453e9a3bd8581d04e0159eddf44b3d2ea607d --- /dev/null +++ b/test/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2015, 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.joinrowset; + +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; +import javax.sql.RowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.JoinRowSet; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.WebRowSet; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import test.rowset.webrowset.CommonWebRowSetTests; + +public class JoinRowSetTests extends CommonWebRowSetTests { + + private final String SUPPLIERS_TABLE = "SUPPLIERS"; + // Expected COF_IDs to be found + private final Object[] EXPECTED = {4, 1}; + // SUPPLIERS Primary Key to use to validate the joins + private final int SUP_ID = 101; + // Join Column between the SUPPLIERS and COFFEES table + private final String JOIN_COLNAME = "SUP_ID"; + // Column index in COFFEES table which contains SUP_ID + private final int COFFEES_JOIN_COLUMN_INDEX = 3; + // Column index in SUPPLIERS table which contains SUP_ID + private final int SUPPLIERS_JOIN_COLUMN_INDEX = 1; + + @Override + protected JoinRowSet newInstance() throws SQLException { + return rsf.createJoinRowSet(); + } + + /* + * Initializes the SUPPLIERS metadata + */ + private void initSuppliersMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + + /* + * CREATE TABLE SUPPLIERS ( + * SUP_ID INTEGER NOT NULL, + * SUP_NAME VARCHAR(32) NOT NULL, + * STREET VARCHAR(32) NOT NULL, + * CITY VARCHAR(32) NOT NULL, + * STATE CHAR(2) NOT NULL, + * ZIP CHAR(5) NOT NULL, + * PRIMARY KEY (SUP_ID)) + */ + rsmd.setColumnCount(6); + rsmd.setColumnName(1, "SUP_ID"); + rsmd.setColumnName(2, "SUP_NAME"); + rsmd.setColumnName(3, "STREET"); + rsmd.setColumnName(4, "CITY"); + rsmd.setColumnName(5, "STATE"); + rsmd.setColumnName(6, "ZIP"); + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.VARCHAR); + rsmd.setColumnType(4, Types.VARCHAR); + rsmd.setColumnType(5, Types.CHAR); + rsmd.setColumnType(6, Types.CHAR); + crs.setMetaData(rsmd); + crs.setTableName(SUPPLIERS_TABLE); + } + + /* + * Add rows to SUPPLIERS table + */ + protected void createSuppiersRows(RowSet rs) throws SQLException { + + // insert into SUPPLIERS values(49, 'Superior Coffee', '1 Party Place', + // 'Mendocino', 'CA', '95460') + rs.moveToInsertRow(); + rs.updateInt(1, 49); + rs.updateString(2, "Superior Coffee"); + rs.updateString(3, "1 Party Place"); + rs.updateString(4, "Mendocino"); + rs.updateString(5, "CA"); + rs.updateString(6, "95460"); + rs.insertRow(); + + // insert into SUPPLIERS values(101, 'Acme, Inc.', '99 Market Street', + // 'Groundsville', 'CA', '95199') + rs.moveToInsertRow(); + rs.updateInt(1, 101); + rs.updateString(2, "Acme, Inc."); + rs.updateString(3, "99 Market Street"); + rs.updateString(4, "Groundsville"); + rs.updateString(5, "CA"); + rs.updateString(6, "95199"); + rs.insertRow(); + // insert into SUPPLIERS values(150, 'The High Ground', + // '100 Coffee Lane', 'Meadows', 'CA', '93966') + rs.moveToInsertRow(); + rs.updateInt(1, 150); + rs.updateString(2, "The High Ground"); + rs.updateString(3, "100 Coffee Lane"); + rs.updateString(4, "Meadows"); + rs.updateString(5, "CA"); + rs.updateString(6, "93966"); + rs.insertRow(); + // insert into SUPPLIERS values(456," 'Restaurant Supplies, Inc.', + // '200 Magnolia Street', 'Meadows', 'CA', '93966') + rs.moveToInsertRow(); + rs.updateInt(1, 456); + rs.updateString(2, "Restaurant Supplies, Inc."); + rs.updateString(3, "200 Magnolia Stree"); + rs.updateString(4, "Meadows"); + rs.updateString(5, "CA"); + rs.updateString(6, "93966"); + rs.insertRow(); + // insert into SUPPLIERS values(927, 'Professional Kitchen', + // '300 Daisy Avenue', 'Groundsville'," 'CA', '95199') + rs.moveToInsertRow(); + rs.updateInt(1, 927); + rs.updateString(2, "Professional Kitchen"); + rs.updateString(3, "300 Daisy Avenue"); + rs.updateString(4, "Groundsville"); + rs.updateString(5, "CA"); + rs.updateString(6, "95199"); + rs.insertRow(); + } + + /* + * DataProvider used to set parameters for basic types that are supported + */ + @DataProvider(name = "createCachedRowSetsToUse") + private Object[][] createCachedRowSetsToUse() throws SQLException { + CachedRowSet crs = rsf.createCachedRowSet(); + initCoffeesMetaData(crs); + createCoffeesRows(crs); + // Make sure you are not on the insertRow + crs.moveToCurrentRow(); + CachedRowSet crs1 = rsf.createCachedRowSet(); + initSuppliersMetaData(crs1); + createSuppiersRows(crs1); + // Make sure you are not on the insertRow + crs1.moveToCurrentRow(); + return new Object[][]{ + {crs, crs1} + }; + } + + /* + * Validate that the correct coffees are returned for SUP_ID + */ + private void validateResults(final JoinRowSet jrs) throws SQLException { + List results = new ArrayList<>(); + jrs.beforeFirst(); + while (jrs.next()) { + if (jrs.getInt(JOIN_COLNAME) == SUP_ID) { + results.add(jrs.getInt("COF_ID")); + } + } + assertEquals(results.toArray(), EXPECTED); + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0000(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + jrs.addRowSet(crs, JOIN_COLNAME); + jrs.addRowSet(crs1, JOIN_COLNAME); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0001(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + jrs.addRowSet(crs, COFFEES_JOIN_COLUMN_INDEX); + jrs.addRowSet(crs1, SUPPLIERS_JOIN_COLUMN_INDEX); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + RowSet[] rowsets = {crs, crs1}; + String[] joinCols = {JOIN_COLNAME, JOIN_COLNAME}; + jrs.addRowSet(rowsets, joinCols); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + RowSet[] rowsets = {crs, crs1}; + int[] joinCols = {COFFEES_JOIN_COLUMN_INDEX, + SUPPLIERS_JOIN_COLUMN_INDEX}; + jrs.addRowSet(rowsets, joinCols); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0005(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + crs.setMatchColumn(JOIN_COLNAME); + crs1.setMatchColumn(JOIN_COLNAME); + jrs.addRowSet(crs); + jrs.addRowSet(crs1); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @Test(dataProvider = "createCachedRowSetsToUse") + public void joinRowSetTests0006(CachedRowSet crs, CachedRowSet crs1) + throws Exception { + + try (JoinRowSet jrs = newInstance()) { + crs.setMatchColumn(COFFEES_JOIN_COLUMN_INDEX); + crs1.setMatchColumn(SUPPLIERS_JOIN_COLUMN_INDEX); + + jrs.addRowSet(crs); + jrs.addRowSet(crs1); + validateResults(jrs); + crs.close(); + crs1.close(); + } + } + + // Disabled tests due to bugs in JoinRowSet + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0009(WebRowSet wrs1) throws Exception { + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java b/test/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java new file mode 100644 index 0000000000000000000000000000000000000000..a6756a13a4ad40f623d93c1164171ac1e2a7ef52 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java @@ -0,0 +1,211 @@ +/* + * 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.serial; + +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Ref; +import java.sql.SQLException; +import java.sql.Struct; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import javax.sql.rowset.serial.SQLInputImpl; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubArray; +import util.StubBlob; +import util.StubClob; +import util.StubRef; +import util.StubStruct; +import util.SuperHero; +import util.TestSQLDataImpl; + +public class SQLInputImplTests extends BaseTest { + + // Copy of the array of data type values + private Object[] typeValues; + private TestSQLDataImpl impl; + private Map> map ; + private SuperHero hero; + private final String sqlType = "SUPERHERO"; + + @BeforeMethod + @Override + public void setUpMethod() throws Exception { + map = new HashMap<>(); + impl = new TestSQLDataImpl("TestSQLData"); + typeValues = Arrays.copyOf(TestSQLDataImpl.attributes, + TestSQLDataImpl.attributes.length); + hero = new SuperHero(sqlType, "Bruce", "Wayne", + 1939, "Batman"); + } + + /* + * Validate that a SQLException is thrown if the attribute value is + * null + */ + @Test(expectedExceptions = SQLException.class) + public void test() throws Exception { + SQLInputImpl x = new SQLInputImpl(null, map); + } + + /* + * Validate that a SQLException is thrown if the map value is + * null + */ + @Test(expectedExceptions = SQLException.class) + public void test02() throws Exception { + SQLInputImpl x = new SQLInputImpl(typeValues, null); + } + + /* + * Read in the various datatypes via readSQL (which will exercise the + * various readXXX methods and validate that results are as expected + */ + @Test() + public void test03() throws Exception { + impl.readSQL(new SQLInputImpl(typeValues, map), "misc"); + assertTrue(Arrays.equals(impl.toArray(), typeValues)); + // Null out a field and make sure the arrays do not match + typeValues[2] = null; + assertFalse(Arrays.equals(impl.toArray(), typeValues)); + } + + /* + * Validate that wasNull indicates if a null was read in + */ + @Test() + public void test04() throws Exception { + Object[] values = {"Hello", null, 1}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + String s = sqli.readString(); + assertFalse(sqli.wasNull()); + s = sqli.readString(); + assertTrue(sqli.wasNull()); + int i = sqli.readInt(); + assertFalse(sqli.wasNull()); + } + + /* + * Validate that readObject returns the correct value + */ + @Test() + public void test05() throws Exception { + Object[] values = {hero}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Object o = sqli.readObject(); + assertTrue(hero.equals(o)); + + } + + /* + * Validate a Array can be read + */ + @Test(enabled = true) + public void test06() throws Exception { + Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast", + "Cappuccino"}; + Array a = new StubArray("VARCHAR", coffees); + Object[] values = {a}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Array a2 = sqli.readArray(); + assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray())); + assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName())); + } + + /* + * Validate a Blob can be read + */ + @Test(enabled = true) + public void test07() throws Exception { + Blob b = new StubBlob(); + Object[] values = {b}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Blob b2 = sqli.readBlob(); + assertTrue(Arrays.equals( + b.getBytes(1, (int) b.length()), + b2.getBytes(1, (int) b2.length()))); + } + + /* + * Validate a Clob can be read + */ + @Test(enabled = true) + public void test08() throws Exception { + Clob c = new StubClob(); + Object[] values = {c}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Clob c2 = sqli.readClob(); + assertTrue(c.getSubString(1, + (int) c.length()).equals(c2.getSubString(1, (int) c2.length()))); + } + + /* + * Validate a Ref can be read + */ + @Test(enabled = true) + public void test09() throws Exception { + Ref ref = new StubRef(sqlType, hero); + Object[] values = {ref}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Ref ref2 = sqli.readRef(); + assertTrue(ref.getObject().equals(ref2.getObject())); + assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName())); + } + + /* + * Validate a URL can be read + */ + @Test(enabled = true) + public void test10() throws Exception { + URL u = new URL("http://www.oracle.com/");; + Object[] values = {u}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + URL u2 = sqli.readURL(); + assertTrue(u2.equals(u)); + assertTrue(u2.sameFile(u)); + } + + /* + * Validate that readObject returns the correct value when a Struct is + * next on the stream + */ + @Test() + public void test11() throws Exception { + Object[] attributes = new Object[]{"Bruce", "Wayne", 1939, + "Batman"}; + map.put(sqlType, Class.forName("util.SuperHero")); + Struct struct = new StubStruct(sqlType, attributes); + Object[] values = {struct}; + SQLInputImpl sqli = new SQLInputImpl(values, map); + Object o = sqli.readObject(); + + assertTrue(hero.equals(o)); + + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java b/test/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java new file mode 100644 index 0000000000000000000000000000000000000000..00f62df6f79669f4372f949a5319babebc263c23 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java @@ -0,0 +1,199 @@ +/* + * 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.serial; + +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Ref; +import java.sql.SQLException; +import java.sql.Struct; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; +import javax.sql.rowset.serial.SQLInputImpl; +import javax.sql.rowset.serial.SQLOutputImpl; +import javax.sql.rowset.serial.SerialArray; +import javax.sql.rowset.serial.SerialBlob; +import javax.sql.rowset.serial.SerialClob; +import javax.sql.rowset.serial.SerialDatalink; +import javax.sql.rowset.serial.SerialRef; +import javax.sql.rowset.serial.SerialStruct; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubArray; +import util.StubBlob; +import util.StubClob; +import util.StubRef; +import util.StubStruct; +import util.SuperHero; +import util.TestSQLDataImpl; + +public class SQLOutputImplTests extends BaseTest { + + // Copy of the array of data type values + private Object[] typeValues; + private TestSQLDataImpl impl; + private Map> map = new HashMap<>(); + private Vector results; + private final String sqlType = "SUPERHERO"; + private SuperHero hero; + private SQLOutputImpl outImpl; + + @BeforeMethod + @Override + public void setUpMethod() throws Exception { + results = new Vector(); + impl = new TestSQLDataImpl("TestSQLData"); + typeValues = Arrays.copyOf(TestSQLDataImpl.attributes, + TestSQLDataImpl.attributes.length); + hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman"); + outImpl = new SQLOutputImpl(results, map); + } + + /* + * Validate that a SQLException is thrown if the attribute value is + * null + */ + @Test(expectedExceptions = SQLException.class) + public void test() throws Exception { + SQLOutputImpl x = new SQLOutputImpl(null, map); + } + + /* + * Validate that a SQLException is thrown if the map value is + * null + */ + @Test(expectedExceptions = SQLException.class) + public void test02() throws Exception { + SQLOutputImpl x = new SQLOutputImpl(results, null); + } + + /* + * Read in the various datatypes via readSQL (which will exercise the + * various readXXX methods and validate that results are as expected + */ + @Test() + public void test03() throws Exception { + impl.readSQL(new SQLInputImpl(typeValues, map), "misc"); + impl.writeSQL(outImpl); + assertTrue(Arrays.equals(results.toArray(), typeValues)); + // Null out a field and make sure the arrays do not match + typeValues[2] = null; + assertFalse(Arrays.equals(results.toArray(), typeValues)); + } + + /* + * Validate a Array can be written and returned + */ + @Test(enabled = true) + public void test04() throws Exception { + Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast", + "Cappuccino"}; + Array a = new StubArray("VARCHAR", coffees); + outImpl.writeArray(a); + SerialArray sa = (SerialArray) results.get(0); + assertTrue(Arrays.equals(coffees, (Object[]) sa.getArray())); + assertTrue(a.getBaseTypeName().equals(sa.getBaseTypeName())); + } + + /* + * Validate a Blob can be written and returned + */ + @Test(enabled = true) + public void test05() throws Exception { + Blob b = new StubBlob(); + outImpl.writeBlob(b); + SerialBlob sb = (SerialBlob) results.get(0); + assertTrue(Arrays.equals( + b.getBytes(1, (int) b.length()), + sb.getBytes(1, (int) sb.length()))); + } + + /* + * Validate a Clob can be written and returned + */ + @Test(enabled = true) + public void test06() throws Exception { + Clob c = new StubClob(); + outImpl.writeClob(c); + SerialClob sc = (SerialClob) results.get(0); + assertTrue(c.getSubString(1, + (int) c.length()).equals(sc.getSubString(1, (int) sc.length()))); + } + + /* + * Validate a Ref can be written and returned + */ + @Test(enabled = true) + public void test07() throws Exception { + Ref ref = new StubRef(sqlType, hero); + outImpl.writeRef(ref); + SerialRef sr = (SerialRef) results.get(0); + assertTrue(hero.equals(sr.getObject())); + } + + /* + * Validate a Struct can be written and returned + */ + @Test(enabled = true) + public void test08() throws Exception { + Object[] attributes = new Object[]{"Bruce", "Wayne", 1939, + "Batman"}; + Struct s = new StubStruct(sqlType, attributes); + outImpl.writeStruct(s); + SerialStruct ss = (SerialStruct) results.get(0); + assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes())); + assertTrue(sqlType.equals(ss.getSQLTypeName())); + } + + /* + * Validate a DataLink can be written and returned + */ + @Test(enabled = true) + public void test09() throws Exception { + URL u = new URL("http://www.oracle.com/"); + outImpl.writeURL(u); + SerialDatalink sdl = (SerialDatalink) results.get(0); + URL u2 = sdl.getDatalink(); + assertTrue(u2.equals(u)); + assertTrue(u2.sameFile(u)); + } + + /* + * Validate an Object implementing SQLData can be written and returned + */ + @Test(enabled = true) + public void test10() throws Exception { + Object[] attributes = new Object[]{"Bruce", "Wayne", 1939, + "Batman"}; + outImpl.writeObject(hero); + SerialStruct ss = (SerialStruct) results.get(0); + assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes())); + assertTrue(sqlType.equals(ss.getSQLTypeName())); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialArrayTests.java b/test/javax/sql/testng/test/rowset/serial/SerialArrayTests.java new file mode 100644 index 0000000000000000000000000000000000000000..077ce43da85f38f2601eb1d58c5b299b4578bbd1 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialArrayTests.java @@ -0,0 +1,236 @@ +/* + * 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.serial; + +import java.sql.Array; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import javax.sql.rowset.serial.SerialArray; +import javax.sql.rowset.serial.SerialException; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubArray; + +public class SerialArrayTests extends BaseTest { + + private Object[] coffees; + private final String sqlType = "VARCHAR"; + private Array a; + private Map> map; + + @BeforeMethod + public void setUpMethod() throws Exception { + coffees = new Object[]{"Espresso", "Colombian", "French Roast", + "Cappuccino"}; + a = new StubArray(sqlType, coffees); + map = new HashMap<>(); + } + + /* + * Validate a SerialArray can be created from an Array + */ + @Test + public void test01() throws Exception { + SerialArray sa = new SerialArray(a); + } + + /* + * Validate a SQLException is thrown if the map is null + */ + @Test(expectedExceptions = SQLException.class) + public void test02() throws Exception { + SerialArray sa = new SerialArray(a, null); + } + + /* + * Validate a SerialException is thrown when getResultSet() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test03() throws Exception { + SerialArray sa = new SerialArray(a); + sa.getResultSet(); + } + + /* + * Validate a SerialException is thrown when getResultSet() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test04() throws Exception { + SerialArray sa = new SerialArray(a); + sa.getResultSet(null); + } + + /* + * Validate a SerialException is thrown when getResultSet() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test05() throws Exception { + SerialArray sa = new SerialArray(a); + sa.getResultSet(1, 1); + } + + /* + * Validate a SerialException is thrown when getResultSet() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test06() throws Exception { + SerialArray sa = new SerialArray(a); + sa.getResultSet(1, 1, null); + } + + /* + * Validate a SerialException is thrown when getArray() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test07() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getArray(); + } + + /* + * Validate a SerialException is thrown when getArray() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test08() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getArray(map); + } + + /* + * Validate a SerialException is thrown when getArray() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test09() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getArray(1, 1, map); + } + + /* + * Validate a SerialException is thrown when getArray() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test10() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getArray(1, 1); + } + + /* + * Validate a SerialException is thrown when getBaseType() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test11() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getBaseType(); + } + + /* + * Validate a SerialException is thrown when getBaseTypeName() is invoked after + * free() is called + */ + @Test(expectedExceptions = SerialException.class) + public void test12() throws Exception { + SerialArray sa = new SerialArray(a); + sa.free(); + sa.getBaseTypeName(); + } + + /* + * Validate getArray() returns the same Object[] used to create the + * SerialArray + */ + @Test + public void test13() throws Exception { + SerialArray sa = new SerialArray(a); + Object[] o = (Object[]) sa.getArray(); + assertTrue(Arrays.equals(o, coffees)); + } + + /* + * Validate getArray() returns the same Object[] used to create the + * SerialArray + */ + @Test + public void test14() throws Exception { + SerialArray sa = new SerialArray(a); + Object[] o = (Object[]) sa.getArray(map); + assertTrue(Arrays.equals(o, coffees)); + } + + /* + * Validate getArray() returns the same Object[] used to create the + * SerialArray + */ + @Test + public void test15() throws Exception { + SerialArray sa = new SerialArray(a); + Object[] o = (Object[]) sa.getArray(1, 2); + assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3))); + } + + /* + * Validate getArray() returns the same Object[] used to create the + * SerialArray + */ + @Test + public void test16() throws Exception { + SerialArray sa = new SerialArray(a); + Object[] o = (Object[]) sa.getArray(1, 2, map); + assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3))); + } + + /* + * clone() a SerialArray and check that it is equal to the + * object it was cloned from + */ + @Test + public void test17() throws Exception { + SerialArray sa = new SerialArray(a); + SerialArray sa1 = (SerialArray) sa.clone(); + assertTrue(sa.equals(sa1)); + } + + /* + * Validate that a SerialArray that is serialized & deserialized is equal to + * itself + */ + @Test + public void test18() throws Exception { + SerialArray sa = new SerialArray(a); + SerialArray sa1 = serializeDeserializeObject(sa);; + assertTrue(sa.equals(sa1)); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialBlobTests.java b/test/javax/sql/testng/test/rowset/serial/SerialBlobTests.java new file mode 100644 index 0000000000000000000000000000000000000000..e080b1ca1b9790706c39b263acf200cedab1e750 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialBlobTests.java @@ -0,0 +1,399 @@ +/* + * 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.serial; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import javax.sql.rowset.serial.SerialBlob; +import javax.sql.rowset.serial.SerialException; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubBlob; + +public class SerialBlobTests extends BaseTest { + + // byte[] used to populate SerialBlob + private byte[] bytes = new byte[]{1, 2, 3, 4, 5}; + + /* + * Validate calling free() does not throw an Exception + */ + @Test + public void test() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + } + + /* + * Validate calling getBinaryStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test01() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.getBinaryStream(); + } + + /* + * Validate calling getBinaryStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test02() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.getBinaryStream(1, 5); + } + + /* + * Validate calling getBytes() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test03() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.getBytes(1, 1); + } + + /* + * Validate calling getLength() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test04() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.length(); + } + + /* + * Validate calling position() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test05() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.position(new byte[5], 1); + } + + /* + * Validate calling position() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test06() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.position(new StubBlob(), 1); + } + + /* + * Validate calling free() after calling setBinaryStream() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test07() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.setBinaryStream(5); + } + + /* + * Validate calling free() after calling setBytes() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test08() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.setBytes(1, new byte[5]); + } + + /* + * Validate calling setBytes() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test09() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.setBytes(1, new byte[10], 0, 5); + } + + /* + * Validate calling truncate() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test10() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + sb.free(); + sb.truncate(1); + } + + /* + * Validate getBinaryStream returns the correct bytes + */ + @Test + public void test11() throws Exception { + byte[] expected = new byte[]{1, 2, 3}; + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(1, 3); + for (byte b : expected) { + byte val = (byte) is.read(); + assertTrue(b == val, val + " does not match " + b); + } + } + + /* + * Validate a SerialException is thrown if pos < 0 for getBinaryStream + */ + @Test(expectedExceptions = SerialException.class) + public void test12() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(-1, 3); + } + + /* + * Validate a SerialException is thrown if pos = 0 for getBinaryStream + */ + @Test(expectedExceptions = SerialException.class) + public void test13() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(0, 3); + } + + /* + * Validate a SerialException is thrown if len > the length of the stream + * for getBinaryStream + */ + @Test(expectedExceptions = SerialException.class) + public void test14() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(0, 3); + } + + /* + * Validate a SerialException is thrown if length < 1 + */ + @Test(expectedExceptions = SerialException.class) + public void test15() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(1, 0); + } + + /* + * Validate a SerialException is thrown if length > byte array length + */ + @Test(expectedExceptions = SerialException.class) + public void test16() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(1, 6); + } + + /* + * Validate a SerialException is thrown if pos > byte array length + */ + @Test(expectedExceptions = SerialException.class) + public void test17() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(bytes.length + 2, 6); + } + + /* + * Validate that a cloned SerializedBlob bytes match the original + */ + @Test + public void test18() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + SerialBlob sb2 = (SerialBlob) sb.clone(); + assertTrue( + Arrays.equals(sb.getBytes(1, (int) sb.length()), + sb2.getBytes(1, (int) sb2.length())), + "arrays do not match "); + } + + /* + * Test clone after free has been called that the clone is not accessible + */ + @Test(expectedExceptions = SerialException.class) + public void test19() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + sb.free(); + SerialBlob sb2 = (SerialBlob) sb.clone(); + InputStream is = sb2.getBinaryStream(1, 3); + } + + /* + * Validate that a SerialBlob that is serialized & deserialized is equal to + * itself + */ + @Test + public void test20() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + SerialBlob sb2 = serializeDeserializeObject(sb); + assertTrue(sb.equals(sb2), "SerialBlob not equal"); + } + + /* + * Validate a SerialException is thrown if byte[] is used to + * create the SeriablBlob and setBinaryStream is called + */ + @Test(expectedExceptions = SerialException.class) + public void test21() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + sb.setBinaryStream(3); + } + + /* + * Validate that setBytes will properly write a set of bytes to the + * specified location in the SerialBlob and the correct count is returned + * for bytes written + */ + @Test + public void test22() throws Exception { + byte[] diff = new byte[]{7, 8, 9}; + byte[] expected = new byte[]{1, 7, 8, 9, 5}; + SerialBlob sb = new SerialBlob(bytes); + int written = sb.setBytes(2, diff); + assertEquals(written, diff.length); + assertTrue( + Arrays.equals(sb.getBytes(1, (int) sb.length()), + expected), + "arrays do not match "); + } + + /* + * Validate that setBytes will properly write a set of bytes to the + * specified location in the SerialBlob and the correct count is returned + * for bytes written + */ + @Test + public void test23() throws Exception { + int bytesToWrite = 3; + byte[] diff = new byte[]{7, 8, 9, 0}; + byte[] expected = new byte[]{1, 8, 9, 0, 5}; + SerialBlob sb = new SerialBlob(bytes); + int written = sb.setBytes(2, diff, 1, bytesToWrite); + assertEquals(written, bytesToWrite); + assertTrue( + Arrays.equals(sb.getBytes(1, (int) sb.length()), + expected), + "arrays do not match "); + } + + /* + * Validate that truncate reduces the length of the SerlizedBlob to the + * specified value + */ + @Test + public void test24() throws Exception { + SerialBlob sb = new SerialBlob(bytes); + sb.truncate(0); + assertTrue(sb.length() == 0); + sb = new SerialBlob(bytes); + sb.truncate(3); + assertTrue(sb.length() == 3); + } + + /* + * Validate getBinaryStream returns the correct bytes + */ + @Test + public void test25() throws Exception { + byte[] expected = bytes; + SerialBlob sb = new SerialBlob(bytes); + InputStream is = sb.getBinaryStream(); + for (byte b : expected) { + byte val = (byte) is.read(); + assertTrue(b == val, val + " does not match " + b); + } + } + + /* + * Validate setBinaryStream returns an OutputStream when passed a Blob + */ + @Test + public void test26() throws Exception { + SerialBlob sb = new SerialBlob(new StubBlob()); + OutputStream os = sb.setBinaryStream(0); + assertTrue(os != null); + } + + /* + * Validate that position returns the correct starting location for a + * pattern in the SerialBlob + */ + @Test + public void test27() throws Exception { + long expectedPos = 3; // starting offset is 1 vs 0 + byte[] pattern = new byte[]{3, 4}; + SerialBlob sb = new SerialBlob(bytes); + long pos = sb.position(pattern, 1); + assertEquals(pos, expectedPos); + } + + /* + * Validate that position returns the correct starting location for a + * pattern in the SerialBlob + */ + @Test + public void test28() throws Exception { + long expectedPos = 3; // starting offset is 1 vs 0 + byte[] pattern = new byte[]{3, 4, 5}; + SerialBlob sb = new SerialBlob(bytes); + long pos = sb.position(pattern, 2); + assertEquals(pos, expectedPos); + } + + /* + * Validate that position returns the correct starting location for a + * pattern in the SerialBlob + */ + @Test + public void test29() throws Exception { + long expectedPos = 2; // starting offset is 1 vs 0 + byte[] pattern = new byte[]{4, 6}; + SerialBlob sb = new SerialBlob(new StubBlob()); + long pos = sb.position(pattern, 1); + assertEquals(pos, expectedPos); + } + + /* + * Validate that position returns the correct starting location for a + * pattern in the SerialBlob + */ + @Test + public void test30() throws Exception { + long expectedPos = 3; // starting offset is 1 vs 0 + byte[] pattern = new byte[]{6, 8}; + SerialBlob sb = new SerialBlob(new StubBlob()); + long pos = sb.position(pattern, 2); + assertEquals(pos, expectedPos); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialClobTests.java b/test/javax/sql/testng/test/rowset/serial/SerialClobTests.java new file mode 100644 index 0000000000000000000000000000000000000000..72f42674de092cad6175ebf8492e26d64af8f46a --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialClobTests.java @@ -0,0 +1,499 @@ +/* + * 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.serial; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import javax.sql.rowset.serial.SerialClob; +import javax.sql.rowset.serial.SerialException; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubClob; + +public class SerialClobTests extends BaseTest { + + // char[] used to populate SerialClob + private final char[] chars; + + public SerialClobTests() { + this.chars = new char[]{'h', 'e', 'l', 'l', 'o', ' ', 'w', + 'o', 'r', 'l', 'd'}; + } + + /* + * Validate calling free() does not throw an Exception + */ + @Test + public void test() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + } + + /* + * Validate calling getCharacterStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test01() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.getCharacterStream(); + } + + /* + * Validate calling getCharacterStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test02() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.free(); + sc.getCharacterStream(); + } + + /* + * Validate calling getCharacterStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test03() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.getCharacterStream(1, 5); + } + + /* + * Validate calling getSubString() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test04() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.getSubString(1, 1); + } + + /* + * Validate calling truncate() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test05() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.truncate(1); + } + + /* + * Validate calling getAsciiStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test06() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.getAsciiStream(); + } + + /* + * Validate calling length() after calling free() throws an SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test07() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.length(); + } + + /* + * Validate calling position() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test08() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.position("hello", 1); + } + + /* + * Validate calling position() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test09() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.position(new StubClob(), 1); + } + + /* + * Validate calling setAsciiStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test10() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.setAsciiStream(5); + } + + /* + * Validate calling setCharacterStream() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test11() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.setCharacterStream(5); + } + + /* + * Validate calling setString() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test12() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.setString(1, "hello"); + } + + /* + * Validate calling setString() after calling free() throws an + * SerialException + */ + @Test(expectedExceptions = SerialException.class) + public void test13() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.free(); + sc.setString(1, "hello", 0, 5); + } + + /* + * Test that SerialException is thrown if pos < 0 on a call to + * getCharacterStream + */ + @Test(expectedExceptions = SerialException.class) + public void test14() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.getCharacterStream(-1, 5); + } + + /* + * Test that SerialException is thrown if pos = 0 on a call to + * getCharacterStream + */ + @Test(expectedExceptions = SerialException.class) + public void test15() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.getCharacterStream(0, 5); + } + + /* + * Test that SerialException is thrown if pos = 0 on a call to + * getCharacterStream + */ + @Test(expectedExceptions = SerialException.class) + public void test16() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.getCharacterStream(1, 100); + } + + /* + * Test that SerialException is thrown if length = 0 on a call to + * getCharacterStream + */ + @Test(expectedExceptions = SerialException.class) + public void test17() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.getCharacterStream(1, 0); + } + + /* + * Test that SerialException is thrown if pos > length on a call to + * getCharacterStream + */ + @Test(expectedExceptions = SerialException.class) + public void test18() throws Exception { + SerialClob sc = new SerialClob(chars); + sc.getCharacterStream(100, 5); + } + + /* + * Clone a SerialClob and check that it is equal to itself + */ + @Test + public void test19() throws Exception { + SerialClob sc = new SerialClob(chars); + SerialClob sc1 = (SerialClob) sc.clone(); + assertTrue(sc.equals(sc1), "SerialClobs not equal"); + } + + /* + * Validate that a getAsciiStream() returns an InputStream when a Clob is + * used to create the SerialClob + */ + @Test + public void test20() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + InputStream is = sc.getAsciiStream(); + assertTrue(is != null); + } + + /* + * Validate that a getCharacterStream() returns an Reader when a Clob is + * used to create the SerialClob + */ + @Test + public void test21() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + Reader is = sc.getCharacterStream(); + assertTrue(is != null); + } + + /* + * Validate that a getCharacterStream() returns an Reader when a char[] is + * used to create the SerialClob + */ + @Test + public void test22() throws Exception { + SerialClob sc = new SerialClob(chars); + Reader is = sc.getCharacterStream(); + assertTrue(is != null); + } + + /* + * Validate that a getSubString() returns the correct value when a char[] is + * used to create the SerialClob + */ + @Test + public void test23() throws Exception { + SerialClob sc = new SerialClob(chars); + String expected = "world"; + assertEquals(expected, sc.getSubString(7, 5)); + } + + /* + * Validate that a getSubString() returns the correct value when a Clob is + * used to create the SerialClob + */ + @Test + public void test24() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + String expected = "test string"; + assertEquals(expected, sc.getSubString(5, 11)); + } + + /* + * Validate that position() returns the correct value when a Clob is used to + * create the SerialClob + */ + @Test + public void test25() throws Exception { + long expectedPos = 5; + SerialClob sc = new SerialClob(new StubClob()); + String expected = "test string"; + long pos = sc.position(expected, 1); + assertEquals(expectedPos, pos); + } + + /* + * Validate that position returned is -1 when an the search string is not + * part of the SerialClob + */ + @Test + public void test26() throws Exception { + long expectedPos = -1; + SerialClob sc = new SerialClob(chars); + String expected = "test string"; + long pos = sc.position(expected, 1); + assertEquals(expectedPos, pos); + } + + /* + * Validate that position() returned is -1 when an the search string is not + * part of the SerialClob + */ + @Test + public void test27() throws Exception { + long expectedPos = -1; + SerialClob sc = new SerialClob(new StubClob()); + String expected = "I am Batman"; + long pos = sc.position(expected, 2); + assertEquals(expectedPos, pos); + } + + /* + * Validate that position() returns the correct value when a char[] is used + * to create the SerialClob + */ + @Test + public void test28() throws Exception { + long expectedPos = 2; + SerialClob sc = new SerialClob(chars); + String expected = "ello"; + long pos = sc.position(expected, 1); + assertEquals(expectedPos, pos); + } + + /* + * Validate that position() returns the correct value when a SerialClob is + * used for the search argument + */ + @Test + public void test29() throws Exception { + long expectedPos = 21; + String expected = "Batman"; + String buf = "I am Joker, not the Batman, hahaha"; + SerialClob sc = new SerialClob(expected.toCharArray()); + SerialClob sc1 = new SerialClob(buf.toCharArray()); + long pos = sc1.position(sc, 1); + assertEquals(expectedPos, pos); + } + + /* + * Validate that position() returns the correct value when a SerialClob is + * used for the search argument + */ + @Test + public void test30() throws Exception { + long expectedPos = 17; + String expected = "012"; + SerialClob sc = new SerialClob(expected.toCharArray()); + SerialClob sc1 = new SerialClob(new StubClob()); + long pos = sc1.position(sc, 1); + assertEquals(expectedPos, pos); + } + + /* + * Check that setString() updates the appropriate characters in the + * SerialClob + */ + @Test + public void test31() throws Exception { + String val = "Hello, I am Bruce Wayne"; + String val1 = "the Batman!"; + String expected = "Hello, I am the Batman!"; + SerialClob sc = new SerialClob(val.toCharArray()); + int written = sc.setString(13, val1); + assertEquals(val1.length(), written); + assertTrue(expected.equals(sc.getSubString(1, (int) sc.length()))); + } + + /* + * Check that setString() updates the appropriate characters in the + * SerialClob + */ + @Test(enabled = false) + public void test32() throws Exception { + int expectedWritten = 9; + String val = "Hi, I am Catwoman!!!!!!"; + String val1 = "Hahaha the Joker, who are you?!"; + String expected = "Hi, I am the Joker!"; + SerialClob sc = new SerialClob(val.toCharArray()); + int written = sc.setString(10, val1, 8, expectedWritten+1); + assertEquals(written, expectedWritten); + + } + + /* + * Check that setCharacterStream() returns a non-null Writer for an + * SerialClob created from a Clob + */ + @Test + public void test33() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + Writer w = sc.setCharacterStream(1); + assertTrue(w != null); + } + + /* + * Check that setAsciiStream() returns a non-null OutputStream for an SerialClob + * created from a Clob + */ + @Test + public void test34() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + OutputStream os = sc.setAsciiStream(1); + assertTrue(os != null); + } + + /* + * Check that truncate() truncates the length of the SerialClob to the + * specified size + */ + @Test + public void test35() throws Exception { + SerialClob sc = new SerialClob(new StubClob()); + sc.truncate(0); + assertTrue(sc.length() == 0); + sc = new SerialClob(chars); + sc.truncate(5); + assertTrue(sc.length() == 5); + } + + /* + * Check that getCharacterStream() returns a Reader and that the char[] that + * was specified to create the SerialClob can be returned via the Reader + */ + @Test + public void test36() throws Exception { + SerialClob sc = new SerialClob(chars); + Reader r = sc.getCharacterStream(); + for (char c : chars) { + char val = (char) r.read(); + assertTrue(c == val, val + " does not match " + c); + } + } + + /* + * Check that getCharacterStream() returns a Reader and that the char[] that + * was specified to create the SerialClob can be returned via the Reader + */ + @Test(enabled = false) + public void test37() throws Exception { + SerialClob sc = new SerialClob(chars); + String expected = "ello w"; + Reader r = sc.getCharacterStream(2, 6); + for (char c : expected.toCharArray()) { + char val = (char) r.read(); + assertTrue(c == val, val + " does not match " + c); + } + } + + /* + * Validate that a SerialClob that is serialized & deserialized is equal to + * itself + */ + @Test + public void test38() throws Exception { + SerialClob sc = new SerialClob(chars); + SerialClob sc2 = serializeDeserializeObject(sc); + assertTrue(sc.equals(sc2), "SerialClobs not equal"); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java b/test/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java new file mode 100644 index 0000000000000000000000000000000000000000..8e86d4a8f3d92cdb78e860e09c74b13a083811d1 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialDataLinkTests.java @@ -0,0 +1,110 @@ +/* + * 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.serial; + +import java.net.URL; +import javax.sql.rowset.serial.SerialDatalink; +import javax.sql.rowset.serial.SerialException; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; + +public class SerialDataLinkTests extends BaseTest { + + private URL u; + private URL u1; + private SerialDatalink dl; + + @BeforeMethod + public void setUpMethod() throws Exception { + u = new URL("http://www.oracle.com/"); + u1 = new URL("http://www.usatoday.com/"); + dl = new SerialDatalink(u); + } + + /* + * Validate that a SerialException is thrown if the URL is null + */ + @Test(expectedExceptions = SerialException.class) + public void test() throws Exception { + SerialDatalink dl1 = new SerialDatalink(null); + } + + /* + * Validate that getDatalink() returns the same URL used to create the + * SerialDatalink object + */ + @Test + public void test01() throws Exception { + URL u2 = dl.getDatalink(); + assertTrue(u2.equals(u)); + assertTrue(u2.sameFile(u)); + } + + /* + * Validate that URL returned from getDatalink() differs from a URL that was + * not used to create the SerialDatalink + */ + @Test + public void test02() throws Exception { + URL u2 = dl.getDatalink(); + assertFalse(u2.equals(u1)); + assertFalse(u2.sameFile(u1)); + } + + /* + * Create a clone of a SerialDatalink and validate that it is equal to the + * SerialDatalink it was cloned from + */ + @Test + public void test03() throws Exception { + SerialDatalink dl2 = (SerialDatalink) dl.clone(); + assertTrue(dl.equals(dl2)); + SerialDatalink dl3 = new SerialDatalink(u1); + assertFalse(dl2.equals(dl3)); + } + + /* + * Validate that a SerialDatalink that is serialized & deserialized is + * equal to itself + */ + @Test + public void test04() throws Exception { + SerialDatalink dl2 = serializeDeserializeObject(dl); + SerialDatalink dl3 = new SerialDatalink(u); + assertTrue(dl.equals(dl2)); + assertTrue(dl3.equals(dl2)); + } + + /** + * Validate that a SerialDatalink that is serialized & deserialized is not equal + * to to a SerialDatalink created using a different URL + */ + @Test + public void test05() throws Exception { + SerialDatalink dl2 = serializeDeserializeObject(dl); + SerialDatalink d3 = new SerialDatalink(u1); + assertFalse(d3.equals(dl2)); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java b/test/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..ff963ae7ba84db25d1c9148c13e397c308192c2f --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialExceptionTests.java @@ -0,0 +1,113 @@ +/* + * 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.serial; + +import java.sql.SQLException; +import javax.sql.rowset.serial.SerialException; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; + +public class SerialExceptionTests extends BaseTest { + + /* + * Create SerialException with no-arg constructor + */ + @Test + public void test01() { + SerialException ex = new SerialException(); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Create SerialException with message + */ + @Test + public void test02() { + SerialException ex = new SerialException(reason); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Validate that the ordering of the returned Exceptions is correct using + * for-each loop + */ + @Test + public void test03() { + SerialException ex = new SerialException("Exception 1"); + ex.initCause(t1); + SerialException ex1 = new SerialException("Exception 2"); + SerialException ex2 = new SerialException("Exception 3"); + ex2.initCause(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 test04() { + SQLException ex = new SerialException("Exception 1"); + ex.initCause(t1); + SerialException ex1 = new SerialException("Exception 2"); + SerialException ex2 = new SerialException("Exception 3"); + ex2.initCause(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(); + } + } + + /* + * Serialize a SerialException and make sure you can read it back properly + */ + @Test + public void test05() throws Exception { + SerialException e = new SerialException(reason); + SerialException ex1 = createSerializedException(e); + assertTrue(ex1.getMessage().equals(reason) + && ex1.getSQLState() == null + && ex1.getCause() == null + && ex1.getErrorCode() == 0);; + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java b/test/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java new file mode 100644 index 0000000000000000000000000000000000000000..cc2d184298d7c36e3bfb100c172cf704262670c6 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialJavaObjectTests.java @@ -0,0 +1,100 @@ +/* + * 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.serial; + +import java.lang.reflect.Field; +import java.util.Arrays; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.serial.SerialException; +import javax.sql.rowset.serial.SerialJavaObject; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; + +public class SerialJavaObjectTests extends BaseTest { + + /* + * Validate that an NPE is thrown when null is specified to create + * the SerialJavaObject + */ + @Test(expectedExceptions = NullPointerException.class) + public void test() throws Exception { + SerialJavaObject sjo = new SerialJavaObject(null); + } + + /* + * Validate that an SerialExcepion is thrown when the object specified + * contains public static fields + */ + @Test(expectedExceptions = SerialException.class, enabled = false) + public void test01() throws Exception { + SerialJavaObject sjo = new SerialJavaObject(new RowSetMetaDataImpl()); + } + + /* + * Validate that an getFields()s returns the same Field[] for the object + * used to create the SerialJavaObject + */ + @Test + public void test02() throws Exception { + SerialException e = new SerialException(); + SerialJavaObject sjo = new SerialJavaObject(e); + Field[] f = e.getClass().getFields(); + assertTrue(Arrays.equals(f, sjo.getFields())); + assertFalse(Arrays.equals("hello".getClass().getFields(), + sjo.getFields())); + } + + /* + * clone() a SerialJavaObject and check that it is equal to the + * object it was cloned from + */ + @Test + public void test03() throws Exception { + SerialJavaObject sjo = new SerialJavaObject("Hello"); + SerialJavaObject sjo2 = (SerialJavaObject) sjo.clone(); + assertTrue(sjo.equals(sjo2)); + } + + /** + * Validate that a SerialJavaObject that is serialized & deserialized is + * equal to itself + */ + @Test + public void test04() throws Exception { + SerialJavaObject sjo = new SerialJavaObject("Hello"); + SerialJavaObject sjo2 = serializeDeserializeObject(sjo); + assertTrue(sjo.equals(sjo2)); + } + + /* + * Validate that a getObject() returns an object used to create the + * SerialJavaObject + */ + @Test + public void test05() throws Exception { + String s = "Hello world"; + SerialJavaObject sjo = new SerialJavaObject(s); + assertTrue(s.equals(sjo.getObject())); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialRefTests.java b/test/javax/sql/testng/test/rowset/serial/SerialRefTests.java new file mode 100644 index 0000000000000000000000000000000000000000..8f23de70aa610203b2f569db7b7b28726584a9a5 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialRefTests.java @@ -0,0 +1,131 @@ +/* + * 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.serial; + +import java.sql.Ref; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import javax.sql.rowset.serial.SerialRef; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubRef; +import util.SuperHero; + +public class SerialRefTests extends BaseTest { + + private static Map> map = new HashMap<>(); + private Ref ref; + private final String sqlType = "SUPERHERO"; + private SuperHero hero; + + @BeforeMethod + public void setUpMethod() throws Exception { + map.put(sqlType, Class.forName("util.SuperHero")); + hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman"); + ref = new StubRef(sqlType, hero); + } + + /* + * Validate that a SQLException() is thrown if the Ref is null + */ + @Test(expectedExceptions = SQLException.class) + public void test01() throws Exception { + SerialRef sr = new SerialRef(null); + } + + /* + * Validate that a SQLException() is thrown if the typeName is null in the + * Ref used to create the SerialRef + */ + @Test(expectedExceptions = SQLException.class) + public void test02() throws Exception { + SerialRef sr = new SerialRef(new StubRef(null, hero)); + } + + /* + * Validate that getBaseTypeName() returns the same SQLType specified + * to create the Ref + */ + @Test + public void test03() throws Exception { + SerialRef sr = new SerialRef(ref); + assertEquals(sr.getBaseTypeName(), sqlType); + } + + /* + * Validate that getObject() returns the same object used to create the Ref + */ + @Test + public void test04() throws Exception { + SerialRef sr = new SerialRef(ref); + assertTrue(hero.equals(sr.getObject())); + } + + /* + * Validate that getObject() returns the same object used to create the Ref + */ + @Test(enabled = false) + public void test05() throws Exception { + SerialRef sr = new SerialRef(ref); + assertTrue(hero.equals(sr.getObject(map))); + } + + /* + * Validate that setObject() can be used to change the value of the object + * pointed to by the SerialRef + */ + @Test + public void test06() throws Exception { + SerialRef sr = new SerialRef(ref); + assertTrue(hero.equals(sr.getObject())); + SuperHero h = new SuperHero(sqlType, "Dick", "Grayson", 1940, "Robin"); + sr.setObject(h); + assertFalse(hero.equals(sr.getObject())); + } + + /* + * clone() a SerialRef and check that it is equal to the + * object it was cloned from + */ + @Test + public void test09() throws Exception { + SerialRef sr = new SerialRef(ref); + SerialRef sr1 = (SerialRef) sr.clone(); + assertTrue(sr.equals(sr1)); + } + + /** + * Validate that a SerialRef that is serialized & deserialized is equal to + * itself for the Object & baseTypeName + */ + @Test + public void test10() throws Exception { + SerialRef sr = new SerialRef(ref); + SerialRef sr1 = serializeDeserializeObject(sr); + assertTrue(sr1.getObject().equals(sr.getObject()) + && sr1.getBaseTypeName().equals(sr.getBaseTypeName())); + } +} diff --git a/test/javax/sql/testng/test/rowset/serial/SerialStructTests.java b/test/javax/sql/testng/test/rowset/serial/SerialStructTests.java new file mode 100644 index 0000000000000000000000000000000000000000..84a0ff2aaaf73904b15aeb0014a993e62ea5f98b --- /dev/null +++ b/test/javax/sql/testng/test/rowset/serial/SerialStructTests.java @@ -0,0 +1,140 @@ +/* + * 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.serial; + +import java.sql.Struct; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import javax.sql.rowset.serial.SerialStruct; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubStruct; +import util.SuperHero; + +public class SerialStructTests extends BaseTest { + + private static Map> map = new HashMap<>(); + private Object[] attributes; + private Struct struct; + private final String sqlType = "SUPERHERO"; + private SuperHero hero; + + @BeforeMethod + public void setUpMethod() throws Exception { + attributes = new Object[]{"Bruce", "Wayne", 1939, + "Batman"}; + map.put(sqlType, Class.forName("util.SuperHero")); + struct = new StubStruct(sqlType, attributes); + hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman"); + } + + /* + * Validate that getSQLTypeName() returns the same SQLType specified by + * the Struct used to create the object + */ + @Test + public void test01() throws Exception { + SerialStruct ss = new SerialStruct(struct, map); + assertEquals(ss.getSQLTypeName(), sqlType); + } + + /* + * Validate that getSQLTypeName() returns the same SQLType specified by + * the Struct used to create the object + */ + @Test + public void test02() throws Exception { + SerialStruct ss = new SerialStruct(hero, map); + assertEquals(ss.getSQLTypeName(), sqlType); + } + + /* + * Validate that getAttributes() returns the same attributes specified by + * the Struct used to create the object + */ + @Test + public void test03() throws Exception { + SerialStruct ss = new SerialStruct(struct, map); + assertTrue(Arrays.equals(attributes, + ss.getAttributes())); + } + + /* + * Validate that getAttributes() returns the same attributes specified by + * the Struct used to create the object + */ + @Test + public void test04() throws Exception { + SerialStruct ss = new SerialStruct(hero, map); + assertTrue(Arrays.equals(attributes, + ss.getAttributes())); + } + + /* + * Validate that getAttributes() returns the + same attributes specified by + * the Struct used to create the object + */ + @Test + public void test05() throws Exception { + SerialStruct ss = new SerialStruct(struct, map); + assertTrue(Arrays.equals(attributes, + ss.getAttributes(map))); + } + + /* + * Validate that getAttributes() returns the same attributes specified by + * the Struct used to create the object + */ + @Test + public void test06() throws Exception { + SerialStruct ss = new SerialStruct(hero, map); + assertTrue(Arrays.equals(attributes, + ss.getAttributes(map))); + } + + /* + * clone() a SerialStruct and check that it is equal to the + * object it was cloned from + */ + @Test + public void test07() throws Exception { + SerialStruct ss = new SerialStruct(struct, map); + SerialStruct ss1 = (SerialStruct) ss.clone(); + assertTrue(ss.equals(ss1)); + } + + /** + * Validate that a SerialStruct that is serialized & deserialized is equal + * to itself + */ + @Test + public void test08() throws Exception { + SerialStruct ss = new SerialStruct(struct, map); + SerialStruct ss1 = serializeDeserializeObject(ss);; + assertTrue(ss.equals(ss1)); + } +} diff --git a/test/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java b/test/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..e93a6109ec72c4c12cc506422d9488b6bed64f6a --- /dev/null +++ b/test/javax/sql/testng/test/rowset/spi/SyncFactoryExceptionTests.java @@ -0,0 +1,113 @@ +/* + * 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.spi; + +import java.sql.SQLException; +import javax.sql.rowset.spi.SyncFactoryException; +import static org.testng.Assert.*; +import org.testng.annotations.Test; +import util.BaseTest; + +public class SyncFactoryExceptionTests extends BaseTest { + + /* + * Create SyncFactoryException with no-arg constructor + */ + @Test + public void test01() { + SyncFactoryException ex = new SyncFactoryException(); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Create SyncFactoryException with message + */ + @Test + public void test02() { + SyncFactoryException ex = new SyncFactoryException(reason); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0); + } + + /* + * Validate that the ordering of the returned Exceptions is correct using + * for-each loop + */ + @Test + public void test03() { + SyncFactoryException ex = new SyncFactoryException("Exception 1"); + ex.initCause(t1); + SyncFactoryException ex1 = new SyncFactoryException("Exception 2"); + SyncFactoryException ex2 = new SyncFactoryException("Exception 3"); + ex2.initCause(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 test04() { + SQLException ex = new SyncFactoryException("Exception 1"); + ex.initCause(t1); + SyncFactoryException ex1 = new SyncFactoryException("Exception 2"); + SyncFactoryException ex2 = new SyncFactoryException("Exception 3"); + ex2.initCause(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(); + } + } + + /* + * Serialize a SyncFactoryException and make sure you can read it back properly + */ + @Test + public void test05() throws Exception { + SyncFactoryException e = new SyncFactoryException(reason); + SyncFactoryException ex1 = createSerializedException(e); + assertTrue(ex1.getMessage().equals(reason) + && ex1.getSQLState() == null + && ex1.getCause() == null + && ex1.getErrorCode() == 0); + } +} diff --git a/test/javax/sql/testng/test/rowset/spi/SyncFactoryPermissionsTests.java b/test/javax/sql/testng/test/rowset/spi/SyncFactoryPermissionsTests.java new file mode 100644 index 0000000000000000000000000000000000000000..970d678f8db159797412e33202847e7d0d325887 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/spi/SyncFactoryPermissionsTests.java @@ -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. + */ +package test.rowset.spi; + +import java.security.AccessControlException; +import java.security.Policy; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.naming.Context; +import javax.sql.rowset.spi.SyncFactory; +import javax.sql.rowset.spi.SyncFactoryException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubContext; +import util.TestPolicy; + +public class SyncFactoryPermissionsTests extends BaseTest { + + Context ctx; + private static Policy policy; + private static SecurityManager sm; + private final Logger alogger = Logger.getLogger(this.getClass().getName()); + + /* + * Install a SeeurityManager 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); + } + + /* + * Initialize a Context to be used in our tests. + * Save off the original Policy and SecurityManager + */ + public SyncFactoryPermissionsTests() { + policy = Policy.getPolicy(); + sm = System.getSecurityManager(); + ctx = new StubContext(); + } + + /* + * Validate that AccessControlException is thrown if + * SQLPermission("setSyncFactory") has not been granted + */ + @Test(expectedExceptions = AccessControlException.class) + public void test() throws Exception { + setPolicy(new TestPolicy()); + SyncFactory.setJNDIContext(ctx); + } + + /* + * Validate that a SyncFactoryException is thrown if the Logger is null + */ + @Test(expectedExceptions = SyncFactoryException.class) + public void test00() throws SyncFactoryException { + Logger l = SyncFactory.getLogger(); + } + + /* + * Validate that setJNDIContext succeeds if SQLPermission("setSyncFactory") + * has been granted + */ + @Test + public void test01() throws Exception { + setPolicy(new TestPolicy("setSyncFactory")); + SyncFactory.setJNDIContext(ctx); + } + + /* + * Validate that setJNDIContext succeeds if AllPermissions has been granted + */ + @Test + public void test02() throws Exception { + setPolicy(new TestPolicy("all")); + SyncFactory.setJNDIContext(ctx); + } + + /* + * Validate that AccessControlException is thrown if + * SQLPermission("setSyncFactory") has not been granted + */ + @Test(expectedExceptions = AccessControlException.class) + public void test03() throws Exception { + setPolicy(new TestPolicy()); + SyncFactory.setLogger(alogger); + } + + /* + * Validate that setLogger succeeds if SQLPermission("setSyncFactory") + * has been granted + */ + @Test + public void test04() throws Exception { + setPolicy(new TestPolicy("setSyncFactory")); + SyncFactory.setLogger(alogger); + } + + /* + * Validate that setLogger succeeds if AllPermissions has been granted + */ + @Test + public void test05() throws Exception { + setPolicy(new TestPolicy("all")); + SyncFactory.setLogger(alogger); + } + + /* + * Validate that AccessControlException is thrown if + * SQLPermission("setSyncFactory") has not been granted + */ + @Test(expectedExceptions = AccessControlException.class) + public void test06() throws Exception { + setPolicy(new TestPolicy()); + SyncFactory.setLogger(alogger, Level.INFO); + } + + /* + * Validate that AccessControlException is thrown if + * SQLPermission("setSyncFactory") and LoggingPermission("control", null) + * have not been granted + */ + @Test(expectedExceptions = AccessControlException.class) + public void test07() throws Exception { + setPolicy(new TestPolicy("setSyncFactory")); + SyncFactory.setLogger(alogger, Level.INFO); + } + + /* + * Validate that setLogger succeeds if SQLPermission("setSyncFactory") + * has been granted + */ + @Test + public void test08() throws Exception { + setPolicy(new TestPolicy("setSyncFactoryLogger")); + SyncFactory.setLogger(alogger, Level.INFO); + } + + /* + * Validate that setLogger succeeds if AllPermissions has been granted + */ + @Test + public void test09() throws Exception { + setPolicy(new TestPolicy("all")); + SyncFactory.setLogger(alogger, Level.INFO); + } +} diff --git a/test/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java b/test/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java new file mode 100644 index 0000000000000000000000000000000000000000..415488abb9ffc8d6f70df3c46894baf05b960e1f --- /dev/null +++ b/test/javax/sql/testng/test/rowset/spi/SyncFactoryTests.java @@ -0,0 +1,220 @@ +/* + * 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.spi; + +import com.sun.rowset.providers.RIOptimisticProvider; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.naming.Context; +import javax.sql.rowset.spi.SyncFactory; +import javax.sql.rowset.spi.SyncFactoryException; +import javax.sql.rowset.spi.SyncProvider; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import util.PropertyStubProvider; +import util.StubSyncProvider; +import util.StubContext; + +//com.sun.jndi.ldap.LdapCtxFactory +public class SyncFactoryTests { + private static String origFactory; + + private final String stubProvider = "util.StubSyncProvider"; + private final String propertyStubProvider = "util.PropertyStubProvider"; + private final Logger alogger = Logger.getLogger(this.getClass().getName()); + // Initial providers including those set via a property + List initialProviders; + // All providers including those specifically registered + List allProviders; + private Context ctx= null; + + public SyncFactoryTests() { + + // Add a provider via a property + System.setProperty("rowset.provider.classname", propertyStubProvider); + initialProviders = Arrays.asList( + "com.sun.rowset.providers.RIOptimisticProvider", + "com.sun.rowset.providers.RIXMLProvider", + propertyStubProvider); + allProviders = new ArrayList<>(); + allProviders.addAll(initialProviders); + allProviders.add(stubProvider); + ctx = new StubContext(); + } + + @BeforeMethod + public void setUpMethod() throws Exception { + // Make sure the provider provider that is registered is removed + // before each run + SyncFactory.unregisterProvider(stubProvider); + } + + /* + * Validate a non-null factory is returned + */ + @Test + public void test() throws SyncFactoryException { + SyncFactory syncFactory = SyncFactory.getSyncFactory(); + assertTrue(syncFactory != null); + } + + /* + * Check that the correct SyncProvider is returned for the specified + * providerID for the provider registered via a property + */ + @Test + public void test00() throws SyncFactoryException { + SyncProvider p = SyncFactory.getInstance(propertyStubProvider); + assertTrue(p instanceof PropertyStubProvider); + } + + /* + * Check that the correct SyncProvider is returned for the specified + * providerID + */ + @Test + public void test01() throws SyncFactoryException { + SyncFactory.registerProvider(stubProvider); + SyncProvider p = SyncFactory.getInstance(stubProvider); + assertTrue(p instanceof StubSyncProvider); + } + + /* + * Check that the Default SyncProvider is returned if an empty String is + * passed or if an invalid providerID is specified + */ + @Test + public void test02() throws SyncFactoryException { + SyncProvider p = SyncFactory.getInstance(""); + assertTrue(p instanceof RIOptimisticProvider); + // Attempt to get an invalid provider and get the default provider + p = SyncFactory.getInstance("util.InvalidSyncProvider"); + assertTrue(p instanceof RIOptimisticProvider); + } + + /* + * Validate that a SyncFactoryException is thrown if the ProviderID is null + */ + @Test(expectedExceptions = SyncFactoryException.class) + public void test03() throws SyncFactoryException { + SyncProvider p = SyncFactory.getInstance(null); + } + + /* + * Validate that a SyncFactoryException is thrown if the Logger is null + */ + @Test(expectedExceptions = SyncFactoryException.class,enabled=true) + public void test04() throws SyncFactoryException { + Logger l = SyncFactory.getLogger(); + } + + /* + * Validate that the correct logger is returned by getLogger + */ + @Test + public void test05() throws SyncFactoryException { + SyncFactory.setLogger(alogger); + Logger l = SyncFactory.getLogger(); + assertTrue(l.equals(alogger)); + } + + /* + * Validate that the correct logger is returned by getLogger + */ + @Test + public void test06() throws SyncFactoryException { + SyncFactory.setLogger(alogger, Level.INFO); + Logger l = SyncFactory.getLogger(); + assertTrue(l.equals(alogger)); + } + + /* + * Validate that a driver that is registered is returned by + * getRegisteredProviders and if it is unregistered, that it is + * not returned by getRegisteredProviders + */ + @Test + public void test07() throws SyncFactoryException { + + // Validate that only the default providers and any specified via + // a System property are available + validateProviders(initialProviders); + + // Register a provider and make sure it is avaiable + SyncFactory.registerProvider(stubProvider); + validateProviders(allProviders); + + // Check that if a provider is unregistered, it does not show as + // registered + SyncFactory.unregisterProvider(stubProvider); + validateProviders(initialProviders); + } + + /* + * Validate that setJNDIContext throws a SyncFactoryException if the + * context is null + */ + @Test(expectedExceptions = SyncFactoryException.class, enabled=true) + public void test08() throws Exception { + SyncFactory.setJNDIContext(null); + } + + /* + * Validate that setJNDIContext succeeds + */ + @Test(enabled=true) + public void test09() throws Exception { + SyncFactory.setJNDIContext(ctx); + } + + /* + * Utility method to validate the expected providers are regsitered + */ + private void validateProviders(List expectedProviders) + throws SyncFactoryException { + List results = new ArrayList<>(); + Enumeration providers = SyncFactory.getRegisteredProviders(); + + while (providers.hasMoreElements()) { + SyncProvider p = providers.nextElement(); + results.add(p.getProviderID()); + } + assertTrue(expectedProviders.containsAll(results) + && results.size() == expectedProviders.size()); + } + + /* + * Utility method to dump out SyncProvider info for a registered provider + */ + private void showImpl(SyncProvider impl) { + System.out.println("Provider implementation:" + + "\nVendor: " + impl.getVendor() + + "\nVersion: " + impl.getVersion() + + "\nProviderID: " + impl.getProviderID()); + } +} diff --git a/test/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java b/test/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java new file mode 100644 index 0000000000000000000000000000000000000000..0b576b43fb0570451c22ebb22f3722793ff74010 --- /dev/null +++ b/test/javax/sql/testng/test/rowset/spi/SyncProviderExceptionTests.java @@ -0,0 +1,187 @@ +/* + * 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.spi; + +import com.sun.rowset.internal.SyncResolverImpl; +import java.sql.SQLException; +import javax.sql.rowset.spi.SyncProviderException; +import static org.testng.Assert.*; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubSyncResolver; + +public class SyncProviderExceptionTests extends BaseTest { + @BeforeClass + public static void setUpClass() throws Exception { + System.out.println(System.getProperty("java.naming.factory.initial")); + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + /* + * Create SyncProviderException with no-arg constructor + */ + @Test + public void test() { + SyncProviderException ex = new SyncProviderException(); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0 + && ex.getSyncResolver() instanceof SyncResolverImpl); + } + + /* + * Create SyncProviderException with no-arg constructor and + * call setSyncResolver to indicate the SyncResolver to use + */ + @Test + public void test01() { + SyncProviderException ex = new SyncProviderException(); + ex.setSyncResolver(new StubSyncResolver()); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0 + && ex.getSyncResolver() instanceof StubSyncResolver); + } + + /* + * Create SyncProviderException with message + */ + @Test + public void test02() { + SyncProviderException ex = new SyncProviderException(reason); + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0 + && ex.getSyncResolver() instanceof SyncResolverImpl); + } + + /* + * Create SyncProviderException with message and + * call setSyncResolver to indicate the SyncResolver to use + */ + @Test + public void test03() { + SyncProviderException ex = new SyncProviderException(reason); + ex.setSyncResolver(new StubSyncResolver()); + + assertTrue(ex.getMessage().equals(reason) + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0 + && ex.getSyncResolver() instanceof StubSyncResolver); + } + + /* + * Create SyncProviderException with and specify the SyncResolver to use + */ + @Test + public void test04() { + SyncProviderException ex = new SyncProviderException(new StubSyncResolver()); + assertTrue(ex.getMessage() == null + && ex.getSQLState() == null + && ex.getCause() == null + && ex.getErrorCode() == 0 + && ex.getSyncResolver() instanceof StubSyncResolver); + } + + /* + * Validate that the ordering of the returned Exceptions is correct using + * for-each loop + */ + @Test + public void test05() { + SyncProviderException ex = new SyncProviderException("Exception 1"); + ex.initCause(t1); + SyncProviderException ex1 = new SyncProviderException("Exception 2"); + SyncProviderException ex2 = new SyncProviderException("Exception 3"); + ex2.initCause(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 test06() { + SQLException ex = new SyncProviderException("Exception 1"); + ex.initCause(t1); + SyncProviderException ex1 = new SyncProviderException("Exception 2"); + SyncProviderException ex2 = new SyncProviderException("Exception 3"); + ex2.initCause(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(); + } + } + + /* + * Serialize a SyncProviderException and make sure you can read it back properly + */ + @Test + public void test07() throws Exception { + SyncProviderException e = new SyncProviderException(reason); + SyncProviderException ex1 = createSerializedException(e); + assertTrue(ex1.getMessage().equals(reason) + && ex1.getSQLState() == null + && ex1.getCause() == null + && ex1.getErrorCode() == 0 + && ex1.getSyncResolver() instanceof SyncResolverImpl, ex1.getSyncResolver().getClass().getName()); + } + + /* + * Serialize a SyncProviderException and make sure you can read it back properly + */ + @Test + public void test08() throws Exception { + SyncProviderException e = new SyncProviderException(reason); + e.setSyncResolver(new StubSyncResolver()); + + SyncProviderException ex1 = createSerializedException(e); + assertTrue(ex1.getMessage().equals(reason) + && ex1.getSQLState() == null + && ex1.getCause() == null + && ex1.getErrorCode() == 0 + && ex1.getSyncResolver() instanceof StubSyncResolver); + } +} diff --git a/test/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java b/test/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..ce0801e0fe4e47f2654fe8f3cad3d90d2b56e1ae --- /dev/null +++ b/test/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2015, 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.webrowset; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStreamWriter; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.util.Arrays; +import javax.sql.rowset.WebRowSet; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertEqualsNoOrder; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.Test; +import test.rowset.cachedrowset.CommonCachedRowSetTests; + +public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests { + + protected final String XMLFILEPATH = System.getProperty("test.src", ".") + + File.separatorChar + "xml" + File.separatorChar; + protected final String COFFEE_ROWS_XML = XMLFILEPATH + "COFFEE_ROWS.xml"; + protected final String DELETED_COFFEE_ROWS_XML + = XMLFILEPATH + "DELETED_COFFEE_ROWS.xml"; + protected final String MODFIED_DELETED_COFFEE_ROWS_XML + = XMLFILEPATH + "MODFIED_DELETED_COFFEE_ROWS.xml"; + protected final String UPDATED_COFFEE_ROWS_XML + = XMLFILEPATH + "UPDATED_COFFEE_ROWS.xml"; + protected final String INSERTED_COFFEE_ROWS_XML + = XMLFILEPATH + "INSERTED_COFFEE_ROWS.xml"; + protected final String UPDATED_INSERTED_COFFEE_ROWS_XML + = XMLFILEPATH + "UPDATED_INSERTED_COFFEE_ROWS.xml"; + + + /* + * Utility method to write a WebRowSet XML file via an OutputStream + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + rs.writeXml(oos); + } + return baos; + } + + /* + * Utility method to write a WebRowSet XML file via an OutputStream + * and populating the WebRowSet via a ResultSet + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStream(ResultSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + WebRowSet wrs = rsf.createWebRowSet(); + wrs.writeXml(rs, oos); + } + return baos; + } + + + /* + * Utility method to popoulate a WebRowSet via a InputStream + */ + protected WebRowSet readWebRowSetWithOInputStream(ByteArrayOutputStream baos) throws Exception { + WebRowSet wrs1 = rsf.createWebRowSet(); + try (ObjectInputStream ois + = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) { + wrs1.readXml(ois); + } + return wrs1; + } + + /* + * Utility method to write a WebRowSet XML file via an Writer + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStreamWithWriter(WebRowSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(baos); + rs.writeXml(osw); + return baos; + } + + /* + * Utility method to write a WebRowSet XML file via an Writer and populating + * the WebRowSet via a ResultSet + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStreamWithWriter(ResultSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(baos); + WebRowSet wrs = rsf.createWebRowSet(); + wrs.writeXml(rs, osw); + return baos; + } + + /* + * Utility method to popoulate a WebRowSet via a Readar + */ + protected WebRowSet readWebRowSetWithOInputStreamWithReader(ByteArrayOutputStream baos) throws Exception { + WebRowSet wrs1 = rsf.createWebRowSet(); + InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())); + wrs1.readXml(isr); + return wrs1; + } + + /* + * Validate the expected Rows are contained within the RowSet + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0000(WebRowSet wrs) throws Exception { + assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS); + assertEquals(wrs.size(), COFFEES_ROWS); + wrs.close(); + } + + /* + * Validate the expected Rows are contained within the RowSet + * populated by readXML(Reader) + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0001(WebRowSet wrs1) throws Exception { + + try (FileReader fr = new FileReader(COFFEE_ROWS_XML)) { + wrs1.readXml(fr); + } + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + wrs1.close(); + + } + + /* + * Validate the expected Rows are contained within the RowSet + * populated by readXML(InputStream) + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0002(WebRowSet wrs1) throws Exception { + try (FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML)) { + wrs1.readXml(fis); + } + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + wrs1.close(); + } + + /* + * Write a WebRowSet via writeXML(OutputStream), read it + * back via readXML(InputStream) and validate the primary keys + * are the same + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0003(WebRowSet wrs) throws Exception { + ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(wrs); + try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) { + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + } + } + + /* + * Write a ResultSet via writeXML(OutputStream), read it + * back via readXML(InputStream) and validate the primary keys + * are the same + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0004(WebRowSet wrs) throws Exception { + ResultSet rs = wrs; + rs.beforeFirst(); + ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(rs); + try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) { + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + } + } + + /* + * Write a WebRowSet via writeXML(Writer), read it + * back via readXML(Reader) and validate the primary keys + * are the same + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0005(WebRowSet wrs) throws Exception { + ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(wrs); + try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) { + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + } + } + + /* + * Write a WebRowSet via writeXML(Writer), read it + * back via readXML(Reader) and validate the primary keys + * are the same + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0006(WebRowSet wrs) throws Exception { + ResultSet rs = wrs; + rs.beforeFirst(); + ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(rs); + try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) { + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + assertEquals(wrs1.size(), COFFEES_ROWS); + } + } + + /* + * Validate the expected Rows are contained within the RowSet + * after deleting the specified rows + */ + @Test(dataProvider = "rowsetUsingCoffees", enabled = false) + public void WebRowSetTest0007(WebRowSet wrs) throws Exception { + assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS); + int[] rowsToDelete = {2, 4}; + assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS); + for (int row : rowsToDelete) { + assertTrue(deleteRowByPrimaryKey(wrs, row, 1)); + } + + FileInputStream fis = new FileInputStream(MODFIED_DELETED_COFFEE_ROWS_XML); + try (WebRowSet wrs1 = rsf.createWebRowSet()) { + wrs1.readXml(fis); + // With setShowDeleted(false) which is the default, + // the deleted row should not be visible + for (int row : rowsToDelete) { + assertTrue(findRowByPrimaryKey(wrs1, row, 1)); + } + assertTrue(wrs.size() == COFFEES_ROWS); + // With setShowDeleted(true), the deleted row should be visible + for (int row : rowsToDelete) { + assertTrue(findRowByPrimaryKey(wrs, row, 1)); + } + } + } + + /* + * Validate the expected Rows are contained within the RowSet + * that was populated by reading an xml file with all rows + * marked as a currentRow + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0008(WebRowSet wrs1) throws Exception { + FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == COFFEES_ROWS); + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + // Validate that the rows are not marked as deleted, inserted or updated + wrs1.beforeFirst(); + while (wrs1.next()) { + assertFalse(wrs1.rowDeleted()); + assertFalse(wrs1.rowInserted()); + assertFalse(wrs1.rowUpdated()); + } + wrs1.close(); + } + + /* + * Read an XML file to populate a WebRowSet and validate that the rows + * that are marked as deleted are marked as such in the WebRowSet + * Also validate that they are or are not visible based on the + * setShowDeleted value + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0009(WebRowSet wrs1) throws Exception { + int[] rowsToDelete = {2, 4}; + Object[] expectedRows = {1, 3, 5}; + FileInputStream fis = new FileInputStream(DELETED_COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == COFFEES_ROWS); + assertEquals(getPrimaryKeys(wrs1), expectedRows); + // With setShowDeleted(false) which is the default, + // the deleted row should not be visible + for (int row : rowsToDelete) { + assertFalse(findRowByPrimaryKey(wrs1, row, 1)); + } + // With setShowDeleted(true), the deleted row should be visible + wrs1.setShowDeleted(true); + for (int row : rowsToDelete) { + assertTrue(findRowByPrimaryKey(wrs1, row, 1)); + } + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + wrs1.close(); + + } + + /* + * Validate that the correct row in the WebRowSet that had been created + * from an xml file is marked as updated and contains the correct values + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0010(WebRowSet wrs1) throws Exception { + FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == COFFEES_ROWS); + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + wrs1.beforeFirst(); + while (wrs1.next()) { + if (wrs1.getInt(1) == 3) { + assertTrue(wrs1.rowUpdated()); + assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69); + assertFalse(wrs1.rowDeleted()); + assertFalse(wrs1.rowInserted()); + } else { + assertFalse(wrs1.rowUpdated()); + assertFalse(wrs1.rowDeleted()); + assertFalse(wrs1.rowInserted()); + } + } + wrs1.close(); + } + + /* + * Validate the correct row is marked as inserted in a WebRowSet + * that is read from an xml file + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0011(WebRowSet wrs1) throws Exception { + int expectedSize = COFFEES_ROWS + 2; + int addedRowPK = 15; + int addedRowPK2 = 20; + Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize); + expected[expectedSize - 2] = addedRowPK; + expected[expectedSize - 1] = addedRowPK2; + FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == expectedSize); + assertEqualsNoOrder(getPrimaryKeys(wrs1), expected); + wrs1.beforeFirst(); + while (wrs1.next()) { + if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) { + assertTrue(wrs1.rowInserted()); + assertFalse(wrs1.rowDeleted()); + assertFalse(wrs1.rowUpdated()); + } else { + assertFalse(wrs1.rowInserted()); + assertFalse(wrs1.rowDeleted()); + assertFalse(wrs1.rowUpdated()); + } + } + wrs1.close(); + } + + /* + * Read an xml file which contains a row that was inserted and updated + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0012(WebRowSet wrs1) throws Exception { + int expectedSize = COFFEES_ROWS + 1; + int addedRowPK = 100; + Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize); + expected[expectedSize - 1] = addedRowPK; + FileInputStream fis = new FileInputStream(UPDATED_INSERTED_COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == expectedSize); + assertEquals(getPrimaryKeys(wrs1), expected); + wrs1.beforeFirst(); + while (wrs1.next()) { + if (wrs1.getInt(1) == addedRowPK) { + // Row that was inserted and updated + assertTrue(wrs1.rowUpdated()); + assertTrue( + wrs1.getBigDecimal(4).equals(BigDecimal.valueOf(12.99)) + && wrs1.getInt(6) == 125); + assertFalse(wrs1.rowDeleted()); + assertTrue(wrs1.rowInserted()); + } else { + // Remaining rows should only be inserted + assertFalse(wrs1.rowUpdated()); + assertFalse(wrs1.rowDeleted()); + assertTrue(wrs1.rowInserted()); + } + } + wrs1.close(); + } + +} diff --git a/test/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java b/test/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..5f2890e0b5b36014880138d79ad035a71e57fc7b --- /dev/null +++ b/test/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, 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.webrowset; + +import java.sql.SQLException; +import javax.sql.rowset.WebRowSet; + +public class WebRowSetTests extends CommonWebRowSetTests { + + @Override + protected WebRowSet newInstance() throws SQLException { + return rsf.createWebRowSet(); + } + +} diff --git a/test/javax/sql/testng/util/PropertyStubProvider.java b/test/javax/sql/testng/util/PropertyStubProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..d397cc1c7d4e80cb9c595683486c44421e552088 --- /dev/null +++ b/test/javax/sql/testng/util/PropertyStubProvider.java @@ -0,0 +1,27 @@ +/* + * 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 PropertyStubProvider extends StubSyncProvider { + +} diff --git a/test/javax/sql/testng/util/StubArray.java b/test/javax/sql/testng/util/StubArray.java new file mode 100644 index 0000000000000000000000000000000000000000..1d2ef0e5b6fa34e303ebfca62092cba54660fa37 --- /dev/null +++ b/test/javax/sql/testng/util/StubArray.java @@ -0,0 +1,99 @@ +/* + * 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.JDBCType; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Map; + +public class StubArray implements Array { + + private String typeName; + Object[] elements; + + public StubArray(String name, Object[] values) { + typeName = name; + elements = Arrays.copyOf(values, values.length); + + } + + @Override + public String getBaseTypeName() throws SQLException { + return typeName; + } + + @Override + public int getBaseType() throws SQLException { + return JDBCType.valueOf(typeName).getVendorTypeNumber(); + } + + @Override + public Object getArray() throws SQLException { + return Arrays.copyOf(elements, elements.length); + } + + @Override + public Object getArray(Map> map) throws SQLException { + return getArray(); + } + + @Override + public Object getArray(long index, int count) throws SQLException { + return getArray(); + } + + @Override + public Object getArray(long index, int count, Map> map) throws SQLException { + return getArray(); + } + + @Override + public ResultSet getResultSet() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getResultSet(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getResultSet(long index, int count) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getResultSet(long index, int count, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void free() throws SQLException { + elements = null; + typeName = null; + } + +} diff --git a/test/javax/sql/testng/util/StubBaseRowSet.java b/test/javax/sql/testng/util/StubBaseRowSet.java new file mode 100644 index 0000000000000000000000000000000000000000..e003b522ed9937ddbffda041dc5ee035b84e96fa --- /dev/null +++ b/test/javax/sql/testng/util/StubBaseRowSet.java @@ -0,0 +1,1001 @@ +/* + * 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.Reader; +import java.math.BigDecimal; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.rowset.BaseRowSet; + +public class StubBaseRowSet extends BaseRowSet implements RowSet { + + public StubBaseRowSet() { + super(); + // Must call initParams() as part of initialization + super.initParams(); + } + + public void notifyCursorMoved() throws SQLException { + super.notifyCursorMoved(); + } + + public void notifyRowChanged() throws SQLException { + super.notifyRowChanged(); + } + + public void notifyRowSetChanged() throws SQLException { + super.notifyRowSetChanged(); + } + + public void initParams() { + super.initParams(); + } + + // Methods required by RowSet interace, not used + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public java.net.URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public java.net.URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/test/javax/sql/testng/util/StubBlob.java b/test/javax/sql/testng/util/StubBlob.java new file mode 100644 index 0000000000000000000000000000000000000000..727e8a926d5134294b5c6d4c365a2873fec7790d --- /dev/null +++ b/test/javax/sql/testng/util/StubBlob.java @@ -0,0 +1,100 @@ +/* + * 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.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.sql.Blob; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class StubBlob implements Blob { + + private byte[] bytes; + + public StubBlob() { + bytes = new byte[]{2, 4, 6, 8}; + } + + public long length() throws SQLException { + return bytes.length; + } + + public byte[] getBytes(long pos, int length) + throws SQLException { + return Arrays.copyOfRange(bytes, (int) pos - 1, length); + } + + 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 { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(baos); + } catch (IOException ex) { + Logger.getLogger(StubBlob.class.getName()).log(Level.SEVERE, null, ex); + } + return oos; + } + + public void truncate(long len) + throws SQLException { + } + + public void free() throws SQLException { + } + + public InputStream getBinaryStream(long pos, long length) throws SQLException { + return null; + } +} diff --git a/test/javax/sql/testng/util/StubCachedRowSetImpl.java b/test/javax/sql/testng/util/StubCachedRowSetImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9000deb1b65f5cf45fe1e804257c81e5f42cffcd --- /dev/null +++ b/test/javax/sql/testng/util/StubCachedRowSetImpl.java @@ -0,0 +1,1848 @@ +/* + * 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.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.RowSetEvent; +import javax.sql.RowSetListener; +import javax.sql.RowSetMetaData; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetWarning; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; + +public class StubCachedRowSetImpl implements CachedRowSet { + + public StubCachedRowSetImpl() { + } + + @Override + public void populate(ResultSet data) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(Connection conn) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges() throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges(Connection con) throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void restoreOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void release() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoDelete() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoInsert() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoUpdate() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(int idx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(int column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(String column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SyncProvider getSyncProvider() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSyncProvider(String provider) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMetaData(RowSetMetaData md) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getTableName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTableName(String tabName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getKeyColumns() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setKeyColumns(int[] keys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSet createShared() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopy() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopySchema() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopyNoConstraints() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSetWarning getRowSetWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getShowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShowDeleted(boolean b) 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 rollback(Savepoint s) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet rs, int startRow) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPageSize(int size) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getPageSize() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean nextPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previousPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getMatchColumnIndexes() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getMatchColumnNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/StubClob.java b/test/javax/sql/testng/util/StubClob.java new file mode 100644 index 0000000000000000000000000000000000000000..cb1e0c0a62a4c1fe6987d249ffc86424a79655c5 --- /dev/null +++ b/test/javax/sql/testng/util/StubClob.java @@ -0,0 +1,113 @@ +/* + * 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.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.sql.Clob; +import java.sql.SQLException; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class StubClob implements Clob { + + public String buf = "The test string 0123456789"; + + @Override + public String getSubString(long pos, int length) throws SQLException { + return buf; + } + + @Override + public long length() throws SQLException { + return buf.length(); + } + + @Override + public Reader getCharacterStream() throws SQLException { + return new StringReader(buf); + } + + @Override + public InputStream getAsciiStream() throws SQLException { + return new java.io.StringBufferInputStream(buf); + } + + @Override + public int setString(long pos, String str) throws SQLException { + return str.length(); + } + + @Override + public int setString(long pos, String str, int offset, int len) throws SQLException { + return len; + } + + @Override + public long position(String searchstr, long start) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long position(Clob searchstr, long start) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public OutputStream setAsciiStream(long pos) throws SQLException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(baos); + } catch (IOException ex) { + Logger.getLogger(StubBlob.class.getName()).log(Level.SEVERE, null, ex); + } + return oos; + } + + @Override + public Writer setCharacterStream(long pos) throws SQLException { + return new StringWriter(); + } + + @Override + public void truncate(long len) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void free() throws SQLException { + } + + @Override + public Reader getCharacterStream(long pos, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/test/javax/sql/testng/util/StubContext.java b/test/javax/sql/testng/util/StubContext.java new file mode 100644 index 0000000000000000000000000000000000000000..af03534d991e05f042f1bd9a9934d3269e8f6048 --- /dev/null +++ b/test/javax/sql/testng/util/StubContext.java @@ -0,0 +1,220 @@ +/* + * 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.util.Hashtable; +import javax.naming.Binding; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NameClassPair; +import javax.naming.NameParser; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +@SuppressWarnings("unchecked") +public class StubContext implements Context { + + @Override + public Object lookup(Name name) throws NamingException { + return null; + } + + @Override + public Object lookup(String name) throws NamingException { + return null; + } + + @Override + public void bind(Name name, Object obj) throws NamingException { + + } + + @Override + public void bind(String name, Object obj) throws NamingException { + + } + + @Override + public void rebind(Name name, Object obj) throws NamingException { + + } + + @Override + public void rebind(String name, Object obj) throws NamingException { + + } + + @Override + public void unbind(Name name) throws NamingException { + + } + + @Override + public void unbind(String name) throws NamingException { + + } + + @Override + public void rename(Name oldName, Name newName) throws NamingException { + + } + + @Override + public void rename(String oldName, String newName) throws NamingException { + + } + + @Override + public NamingEnumeration list(Name name) throws NamingException { + return new NamingEnumerationStub(); + } + + @Override + public NamingEnumeration list(String name) throws NamingException { + return new NamingEnumerationStub(); + } + + @Override + public NamingEnumeration listBindings(Name name) throws NamingException { + return new NamingEnumerationStub(); + } + + @Override + public NamingEnumeration listBindings(String name) throws NamingException { + return new NamingEnumerationStub(); + } + + @Override + public void destroySubcontext(Name name) throws NamingException { + + } + + @Override + public void destroySubcontext(String name) throws NamingException { + + } + + @Override + public Context createSubcontext(Name name) throws NamingException { + return null; + } + + @Override + public Context createSubcontext(String name) throws NamingException { + return null; + } + + @Override + public Object lookupLink(Name name) throws NamingException { + return null; + } + + @Override + public Object lookupLink(String name) throws NamingException { + return null; + } + + @Override + public NameParser getNameParser(Name name) throws NamingException { + return new NameParserStub(); + } + + @Override + public NameParser getNameParser(String name) throws NamingException { + return new NameParserStub(); + } + + @Override + public Name composeName(Name name, Name prefix) throws NamingException { + return null; + } + + @Override + public String composeName(String name, String prefix) throws NamingException { + return null; + } + + @Override + public Object addToEnvironment(String propName, Object propVal) throws NamingException { + return null; + } + + @Override + public Object removeFromEnvironment(String propName) throws NamingException { + return null; + } + + @Override + public Hashtable getEnvironment() throws NamingException { + return new Hashtable(); + } + + @Override + public void close() throws NamingException { + + } + + @Override + public String getNameInNamespace() throws NamingException { + return null; + } + + class NamingEnumerationStub implements NamingEnumeration { + + @Override + public Object next() throws NamingException { + return null; + } + + @Override + public boolean hasMore() throws NamingException { + return false; + } + + @Override + public void close() throws NamingException { + + } + + @Override + public boolean hasMoreElements() { + return false; + } + + @Override + public Object nextElement() { + return null; + } + + } + + class NameParserStub implements NameParser { + + @Override + public Name parse(String name) throws NamingException { + return null; + } + + } + +} diff --git a/test/javax/sql/testng/util/StubFilteredRowSetImpl.java b/test/javax/sql/testng/util/StubFilteredRowSetImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8fcbfa4c085650face966effe2e107f11f81220e --- /dev/null +++ b/test/javax/sql/testng/util/StubFilteredRowSetImpl.java @@ -0,0 +1,1892 @@ +/* + * 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.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.RowSetEvent; +import javax.sql.RowSetListener; +import javax.sql.RowSetMetaData; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.FilteredRowSet; +import javax.sql.rowset.Predicate; +import javax.sql.rowset.RowSetWarning; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; + +public class StubFilteredRowSetImpl implements FilteredRowSet { + + public StubFilteredRowSetImpl() { + } + + @Override + public void setFilter(Predicate p) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Predicate getFilter() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void readXml(Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void readXml(InputStream iStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet data) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(Connection conn) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges() throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges(Connection con) throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void restoreOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void release() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoDelete() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoInsert() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoUpdate() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(int idx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(int column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(String column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SyncProvider getSyncProvider() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSyncProvider(String provider) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMetaData(RowSetMetaData md) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getTableName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTableName(String tabName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getKeyColumns() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setKeyColumns(int[] keys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSet createShared() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopy() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopySchema() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopyNoConstraints() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSetWarning getRowSetWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getShowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShowDeleted(boolean b) 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 rollback(Savepoint s) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet rs, int startRow) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPageSize(int size) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getPageSize() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean nextPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previousPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getMatchColumnIndexes() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getMatchColumnNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/test/javax/sql/testng/util/StubJdbcRowSetImpl.java b/test/javax/sql/testng/util/StubJdbcRowSetImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ec59eb6c55622c3d1686d6395b3007a32cff091c --- /dev/null +++ b/test/javax/sql/testng/util/StubJdbcRowSetImpl.java @@ -0,0 +1,1672 @@ +/* + * 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.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; +import javax.sql.RowSetListener; +import javax.sql.rowset.JdbcRowSet; +import javax.sql.rowset.RowSetWarning; + +public class StubJdbcRowSetImpl implements JdbcRowSet { + + @Override + public boolean getShowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShowDeleted(boolean b) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSetWarning getRowSetWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void commit() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getAutoCommit() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rollback() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rollback(Savepoint s) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getMatchColumnIndexes() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getMatchColumnNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/StubJoinRowSetImpl.java b/test/javax/sql/testng/util/StubJoinRowSetImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c7ece7cd523980eb903d961295720bb808942b6c --- /dev/null +++ b/test/javax/sql/testng/util/StubJoinRowSetImpl.java @@ -0,0 +1,1962 @@ +/* + * 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.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.RowSetEvent; +import javax.sql.RowSetListener; +import javax.sql.RowSetMetaData; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.JoinRowSet; +import javax.sql.rowset.Joinable; +import javax.sql.rowset.RowSetWarning; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; + +class StubJoinRowSetImpl implements JoinRowSet { + + public StubJoinRowSetImpl() { + } + + @Override + public void addRowSet(Joinable rowset) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSet(RowSet rowset, int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSet(RowSet rowset, String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSet(RowSet[] rowset, int[] columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSet(RowSet[] rowset, String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection getRowSets() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getRowSetNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet toCachedRowSet() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean supportsCrossJoin() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean supportsInnerJoin() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean supportsLeftOuterJoin() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean supportsRightOuterJoin() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean supportsFullJoin() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setJoinType(int joinType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getWhereClause() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getJoinType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void readXml(Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void readXml(InputStream iStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet data) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(Connection conn) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges() throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges(Connection con) throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void restoreOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void release() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoDelete() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoInsert() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoUpdate() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(int idx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(int column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(String column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SyncProvider getSyncProvider() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSyncProvider(String provider) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMetaData(RowSetMetaData md) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getTableName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTableName(String tabName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getKeyColumns() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setKeyColumns(int[] keys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSet createShared() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopy() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopySchema() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopyNoConstraints() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSetWarning getRowSetWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getShowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShowDeleted(boolean b) 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 rollback(Savepoint s) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet rs, int startRow) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPageSize(int size) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getPageSize() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean nextPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previousPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getMatchColumnIndexes() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getMatchColumnNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/test/javax/sql/testng/util/StubNClob.java b/test/javax/sql/testng/util/StubNClob.java new file mode 100644 index 0000000000000000000000000000000000000000..10682578b9a434acabb467614ba8cd5a55dfa4b5 --- /dev/null +++ b/test/javax/sql/testng/util/StubNClob.java @@ -0,0 +1,29 @@ +/* + * 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.NClob; + +public class StubNClob extends StubClob implements NClob { + +} diff --git a/test/javax/sql/testng/util/StubRef.java b/test/javax/sql/testng/util/StubRef.java new file mode 100644 index 0000000000000000000000000000000000000000..052bd92c740e51186a835a1dde9142bc5352adb4 --- /dev/null +++ b/test/javax/sql/testng/util/StubRef.java @@ -0,0 +1,60 @@ +/* + * 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.Serializable; +import java.sql.Ref; +import java.sql.SQLException; +import java.util.Map; + +public class StubRef implements Ref, Serializable { + + private final String baseTypeName; + private Object obj; + + public StubRef(String type, Object o) { + baseTypeName = type; + obj = o; + } + + @Override + public String getBaseTypeName() throws SQLException { + return baseTypeName; + } + + @Override + public Object getObject(Map> map) throws SQLException { + return obj; + } + + @Override + public Object getObject() throws SQLException { + return getObject(null); + } + + @Override + public void setObject(Object value) throws SQLException { + obj = value; + } + +} diff --git a/test/javax/sql/testng/util/StubRowId.java b/test/javax/sql/testng/util/StubRowId.java new file mode 100644 index 0000000000000000000000000000000000000000..f8e90d49867f0a3e8a31bf329e54144ec912224b --- /dev/null +++ b/test/javax/sql/testng/util/StubRowId.java @@ -0,0 +1,34 @@ +/* + * 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.RowId; + +public class StubRowId implements RowId { + + @Override + public byte[] getBytes() { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/StubRowSetFactory.java b/test/javax/sql/testng/util/StubRowSetFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..624c53af1e76406075ecf15c381cb7b82a8f8632 --- /dev/null +++ b/test/javax/sql/testng/util/StubRowSetFactory.java @@ -0,0 +1,60 @@ +/* + * 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.SQLException; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.FilteredRowSet; +import javax.sql.rowset.JdbcRowSet; +import javax.sql.rowset.JoinRowSet; +import javax.sql.rowset.RowSetFactory; +import javax.sql.rowset.WebRowSet; + +public class StubRowSetFactory implements RowSetFactory { + + @Override + public CachedRowSet createCachedRowSet() throws SQLException { + return new StubCachedRowSetImpl(); + } + + @Override + public FilteredRowSet createFilteredRowSet() throws SQLException { + return new StubFilteredRowSetImpl(); + } + + @Override + public JdbcRowSet createJdbcRowSet() throws SQLException { + return new StubJdbcRowSetImpl(); + } + + @Override + public JoinRowSet createJoinRowSet() throws SQLException { + return new StubJoinRowSetImpl(); + } + + @Override + public WebRowSet createWebRowSet() throws SQLException { + return new StubWebRowSetImpl(); + } + +} diff --git a/test/javax/sql/testng/util/StubSQLXML.java b/test/javax/sql/testng/util/StubSQLXML.java new file mode 100644 index 0000000000000000000000000000000000000000..44d1351b3572fe7ea42808f1bdde2890d47a8f33 --- /dev/null +++ b/test/javax/sql/testng/util/StubSQLXML.java @@ -0,0 +1,81 @@ +/* + * 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.io.Reader; +import java.io.Writer; +import java.sql.SQLException; +import java.sql.SQLXML; +import javax.xml.transform.Result; +import javax.xml.transform.Source; + +public class StubSQLXML implements SQLXML{ + + @Override + public void free() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public OutputStream setBinaryStream() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Writer setCharacterStream() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getSource(Class sourceClass) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T setResult(Class resultClass) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/StubStruct.java b/test/javax/sql/testng/util/StubStruct.java new file mode 100644 index 0000000000000000000000000000000000000000..1dee8028a2cd0e942740fe43028ea18b0fcf405b --- /dev/null +++ b/test/javax/sql/testng/util/StubStruct.java @@ -0,0 +1,55 @@ +/* + * 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.SQLException; +import java.sql.Struct; +import java.util.Arrays; +import java.util.Map; + +public class StubStruct implements Struct { + + private final String type; + private final Object[] attribs; + + public StubStruct(String type, Object[] o) { + this.type = type; + this.attribs = Arrays.copyOf(o, o.length); + } + + @Override + public String getSQLTypeName() throws SQLException { + return type; + } + + @Override + public Object[] getAttributes() throws SQLException { + return attribs; + } + + @Override + public Object[] getAttributes(Map> map) throws SQLException { + return attribs; + } + +} diff --git a/test/javax/sql/testng/util/StubSyncProvider.java b/test/javax/sql/testng/util/StubSyncProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..8947455c70127d652891ab2ecb69fc1e11e1aac7 --- /dev/null +++ b/test/javax/sql/testng/util/StubSyncProvider.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014, 2015, 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 javax.sql.RowSetReader; +import javax.sql.RowSetWriter; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; + +public class StubSyncProvider extends SyncProvider { + + /** + * The unique provider identifier. + */ + private String providerID = "util.StubSyncProvider"; + + /** + * The vendor name of this SyncProvider implementation + */ + private String vendorName = "Oracle Corporation"; + + /** + * The version number of this SyncProvider implementation + */ + private String versionNumber = "1.0"; + + @Override + public String getProviderID() { + return providerID; + } + + @Override + public RowSetReader getRowSetReader() { + return null; + } + + @Override + public RowSetWriter getRowSetWriter() { + return null; + } + + @Override + public int getProviderGrade() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceLock(int datasource_lock) throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getDataSourceLock() throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int supportsUpdatableView() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getVersion() { + return versionNumber; + } + + @Override + public String getVendor() { + return vendorName; + } + +} diff --git a/test/javax/sql/testng/util/StubSyncResolver.java b/test/javax/sql/testng/util/StubSyncResolver.java new file mode 100644 index 0000000000000000000000000000000000000000..02477c7f9be7e69b9cb947ebba11d1f6cbef00a5 --- /dev/null +++ b/test/javax/sql/testng/util/StubSyncResolver.java @@ -0,0 +1,1616 @@ +/* + * 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.Reader; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; +import javax.sql.RowSetListener; +import javax.sql.rowset.spi.SyncResolver; + +public class StubSyncResolver implements SyncResolver, Serializable { + + @Override + public int getStatus() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getConflictValue(int index) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getConflictValue(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setResolvedValue(int index, Object obj) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setResolvedValue(String columnName, Object obj) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean nextConflict() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previousConflict() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/StubWebRowSetImpl.java b/test/javax/sql/testng/util/StubWebRowSetImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..918d5bd0482d14e56d5748da253b8bb1e970f826 --- /dev/null +++ b/test/javax/sql/testng/util/StubWebRowSetImpl.java @@ -0,0 +1,1879 @@ +/* + * 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.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.RowSetEvent; +import javax.sql.RowSetListener; +import javax.sql.RowSetMetaData; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetWarning; +import javax.sql.rowset.WebRowSet; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; + +public class StubWebRowSetImpl implements WebRowSet { + + @Override + public void readXml(Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void readXml(InputStream iStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(Writer writer) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void writeXml(OutputStream oStream) throws SQLException, IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet data) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute(Connection conn) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges() throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void acceptChanges(Connection con) throws SyncProviderException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void restoreOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void release() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoDelete() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoInsert() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void undoUpdate() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(int idx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean columnUpdated(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(int column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection toCollection(String column) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SyncProvider getSyncProvider() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSyncProvider(String provider) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int size() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMetaData(RowSetMetaData md) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginal() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSet getOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setOriginalRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getTableName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTableName(String tabName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getKeyColumns() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setKeyColumns(int[] keys) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSet createShared() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopy() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopySchema() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public CachedRowSet createCopyNoConstraints() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowSetWarning getRowSetWarnings() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getShowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShowDeleted(boolean b) 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 rollback(Savepoint s) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void populate(ResultSet rs, int startRow) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPageSize(int size) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getPageSize() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean nextPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previousPage() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUrl() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUrl(String url) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDataSourceName() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDataSourceName(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setUsername(String name) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getPassword() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setPassword(String password) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getTransactionIsolation() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getTypeMap() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getCommand() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCommand(String cmd) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isReadOnly() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setReadOnly(boolean value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getEscapeProcessing() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setType(int type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setConcurrency(int concurrency) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBoolean(String parameterName, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setByte(String parameterName, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setShort(String parameterName, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setInt(String parameterName, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setLong(String parameterName, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFloat(String parameterName, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDouble(String parameterName, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setString(String parameterName, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBytes(String parameterName, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setAsciiStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBinaryStream(String parameterName, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setCharacterStream(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(String parameterName, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRef(int i, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int i, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setBlob(String parameterName, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int i, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setArray(int i, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setDate(String parameterName, Date x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTime(String parameterName, Time x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void clearParameters() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void execute() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removeRowSetListener(RowSetListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setRowId(String parameterName, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNString(String parameterName, String value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNCharacterStream(String parameterName, Reader value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(String parameterName, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean next() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void close() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean wasNull() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public InputStream getBinaryStream(String columnLabel) 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 String getCursorName() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isAfterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void beforeFirst() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void afterLast() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean first() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean last() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean absolute(int row) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean relative(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean previous() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchDirection() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getFetchSize() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getType() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getConcurrency() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowUpdated() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowInserted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean rowDeleted() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void insertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void deleteRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void refreshRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void cancelRowUpdates() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToInsertRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void moveToCurrentRow() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Statement getStatement() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHoldability() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isClosed() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setMatchColumn(String[] columnNames) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int[] getMatchColumnIndexes() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String[] getMatchColumnNames() throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int columnIdx) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(int[] columnIdxes) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void unsetMatchColumn(String[] columnName) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/test/javax/sql/testng/util/SuperHero.java b/test/javax/sql/testng/util/SuperHero.java new file mode 100644 index 0000000000000000000000000000000000000000..c8afb3831de87382922eaeca5d8976cec04c6916 --- /dev/null +++ b/test/javax/sql/testng/util/SuperHero.java @@ -0,0 +1,110 @@ +/* + * 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.Serializable; +import java.sql.SQLData; +import java.sql.SQLException; +import java.sql.SQLInput; +import java.sql.SQLOutput; + +public class SuperHero implements SQLData, Serializable { + + private String first; + private String last; + private String type = "SUPERHERO"; + private Integer firstYear; + private String secretIdentity; + + public SuperHero() { + + } + + public SuperHero(String sqlType, String fname, String lname, Integer year, + String identity) { + first = fname; + last = lname; + type = sqlType; + firstYear = year; + secretIdentity = identity; + } + + @Override + public String getSQLTypeName() throws SQLException { + return type; + } + + @Override + public void readSQL(SQLInput stream, String typeName) throws SQLException { + first = stream.readString(); + last = stream.readString(); + firstYear = stream.readInt(); + secretIdentity = stream.readString(); + } + + @Override + public void writeSQL(SQLOutput stream) throws SQLException { + stream.writeString(first); + stream.writeString(last); + stream.writeInt(firstYear); + stream.writeString(secretIdentity); + } + + @Override + public String toString() { + return "[ name =" + first + " " + last + " " + + firstYear + " " + secretIdentity + " ]"; + } + + public void setIdentity(String identity) { + secretIdentity = identity; + } + + public String getIdentity() { + return secretIdentity; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof SuperHero) { + SuperHero ss = (SuperHero) obj; + return first.equals(ss.first) && last.equals(ss.last) + && firstYear.equals(ss.firstYear) + && type.equals(ss.type) + && secretIdentity.equals(ss.secretIdentity); + } + return false; + } + + @Override + public int hashCode() { + return ((31 + first.hashCode()) * 31) * 31 + + ((31 + last.hashCode()) * 31) * 31 + + ((31 + firstYear.hashCode()) * 31) * 31 + + ((31 + type.hashCode()) * 31) * 31 + + secretIdentity.hashCode(); + } +} diff --git a/test/javax/sql/testng/util/TestRowSetListener.java b/test/javax/sql/testng/util/TestRowSetListener.java new file mode 100644 index 0000000000000000000000000000000000000000..069ade29ca267464bfd8d2daa79f1ce9caeab9fb --- /dev/null +++ b/test/javax/sql/testng/util/TestRowSetListener.java @@ -0,0 +1,64 @@ +/* + * 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 javax.sql.RowSetEvent; +import javax.sql.RowSetListener; + +public class TestRowSetListener implements RowSetListener { + + // Flags to indicate which listener events should have been notified + public final static int ROWSET_CHANGED = 1; + public final static int ROW_CHANGED = 2; + public final static int CURSOR_MOVED = 4; + private int flag; + + @Override + public void rowSetChanged(RowSetEvent event) { + flag |= ROWSET_CHANGED; + } + + @Override + public void rowChanged(RowSetEvent event) { + flag |= ROW_CHANGED; + } + + @Override + public void cursorMoved(RowSetEvent event) { + flag |= CURSOR_MOVED; + } + + /* + * Clear the flag indicating which events we were notified for + */ + public void resetFlag() { + flag = 0; + } + + /* + * Method used to validate that the correct event was notified + */ + public boolean isNotified( int val) { + return flag == val; + } +} diff --git a/test/javax/sql/testng/util/TestSQLDataImpl.java b/test/javax/sql/testng/util/TestSQLDataImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0694add3ef9e404179b58a0e2f8227b695892f6d --- /dev/null +++ b/test/javax/sql/testng/util/TestSQLDataImpl.java @@ -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. + */ +package util; + +import java.math.BigDecimal; +import java.sql.Date; +import java.sql.SQLData; +import java.sql.SQLException; +import java.sql.SQLInput; +import java.sql.SQLOutput; +import java.sql.Time; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Arrays; + +public class TestSQLDataImpl implements SQLData { + + private final int stringPos = 0; + private final int datePos = 1; + private final int timePos = 2; + private final int timestampPos = 3; + private final int intPos = 4; + private final int longPos = 5; + private final int shortPos = 6; + private final int bigDecimalPos = 7; + private final int doublePos = 8; + private final int booleanPos = 9; + private final int floatPos = 10; + private final int bytePos = 11; + private final int bytesPos = 12; + private final int MAX_TYPES = bytesPos + 1; + private final Object[] types = new Object[MAX_TYPES]; + + private final static byte[] b = {1, 2, 3}; + + // attributes entries must line up with the ordering of the reading and + // writing of the fields in readSQL and writeSQL + public final static Object[] attributes = {"The Dark Knight", + Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()), + Timestamp.valueOf(LocalDateTime.now()), Integer.MAX_VALUE, + Long.MAX_VALUE, Short.MIN_VALUE, BigDecimal.ONE, + Double.MAX_VALUE, true, 1.5f, Byte.MAX_VALUE, b}; + + private String sqlType; + + public TestSQLDataImpl(String type) { + sqlType = type; + } + + @Override + public String getSQLTypeName() throws SQLException { + return sqlType; + } + + @Override + public void readSQL(SQLInput stream, String typeName) throws SQLException { + + sqlType = typeName; + types[stringPos] = stream.readString(); + types[datePos] = stream.readDate(); + types[timePos] = stream.readTime(); + types[timestampPos] = stream.readTimestamp(); + types[intPos] = stream.readInt(); + types[longPos] = stream.readLong(); + types[shortPos] = stream.readShort(); + types[bigDecimalPos] = stream.readBigDecimal(); + types[doublePos] = stream.readDouble(); + types[booleanPos] = stream.readBoolean(); + types[floatPos] = stream.readFloat(); + types[bytePos] = stream.readByte(); + types[bytesPos] = stream.readBytes(); + } + + @Override + public void writeSQL(SQLOutput stream) throws SQLException { + + stream.writeString((String) types[stringPos]); + stream.writeDate((Date) types[datePos]); + stream.writeTime((Time) types[timePos]); + stream.writeTimestamp((Timestamp) types[timestampPos]); + stream.writeInt((Integer) types[intPos]); + stream.writeLong((Long) types[longPos]); + stream.writeShort((Short) types[shortPos]); + stream.writeBigDecimal((BigDecimal) types[bigDecimalPos]); + stream.writeDouble((Double) types[doublePos]); + stream.writeBoolean((Boolean) types[booleanPos]); + stream.writeFloat((Float) types[floatPos]); + stream.writeByte((Byte) types[bytePos]); + stream.writeBytes((byte[]) types[bytesPos]); + } + + public Object[] toArray() { + + Object[] result = Arrays.copyOf(types, types.length); + return result; + } + + @Override + public String toString() { + return "[" + sqlType + " " + types + "]"; + } + +} diff --git a/test/javax/sql/testng/xml/COFFEE_ROWS.xml b/test/javax/sql/testng/xml/COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..e42eb4405b0a7e3e2efda40fd3398fba3b74b35e --- /dev/null +++ b/test/javax/sql/testng/xml/COFFEE_ROWS.xml @@ -0,0 +1,191 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + diff --git a/test/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml b/test/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..6fd38ff4e44e1100cb5a1d507e981b5b5c6a7308 --- /dev/null +++ b/test/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml @@ -0,0 +1,191 @@ + + + + SELECT * FROM COFFEES + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + jdbc:derby://localhost:1527/testDB;create=true + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + diff --git a/test/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml b/test/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..a700bab5c6c50190b16e597731e7719a8f407132 --- /dev/null +++ b/test/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml @@ -0,0 +1,207 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 15 + Hazelnut + 101 + 8.99 + 0 + 0 + + + 20 + French Vanilla + 49 + 9.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + diff --git a/test/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml b/test/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..2c71a5ffd3ade413e3f69a71609ec6df5547825a --- /dev/null +++ b/test/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml @@ -0,0 +1,191 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + diff --git a/test/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml b/test/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..449ba120b175d2b122df3bdd4a2fd85b41a67cc0 --- /dev/null +++ b/test/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml @@ -0,0 +1,193 @@ + + + + SELECT * FROM COFFEES + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + jdbc:derby://localhost:1527/testDB;create=true + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 21 + 0 + 69 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + diff --git a/test/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml b/test/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml new file mode 100644 index 0000000000000000000000000000000000000000..0cfc3c9fc73298ac13574b392a5886de4f285a7b --- /dev/null +++ b/test/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml @@ -0,0 +1,201 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + 100 + Mocha + 49 + 9.99 + 12.99 + 20 + 35 + 125 + + + diff --git a/test/javax/swing/JTextArea/TextViewOOM/TextViewOOM.java b/test/javax/swing/JTextArea/TextViewOOM/TextViewOOM.java new file mode 100644 index 0000000000000000000000000000000000000000..e75c7053d08ce79757f6591d09b18a4727fff020 --- /dev/null +++ b/test/javax/swing/JTextArea/TextViewOOM/TextViewOOM.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015, 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.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +/** + * @test + * @bug 8072775 + * @run main/othervm -Xmx80m TextViewOOM + */ +public class TextViewOOM { + + private static JFrame frame; + private static JTextArea ta; + private static final String STRING = "\uDC00\uD802\uDFFF"; + private static final int N = 5000; + + private static void createAndShowGUI() { + frame = new JFrame(); + final JScrollPane jScrollPane1 = new JScrollPane(); + ta = new JTextArea(); + + ta.setEditable(false); + ta.setColumns(20); + ta.setRows(5); + jScrollPane1.setViewportView(ta); + frame.add(ta); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(final String[] args) throws Exception { + /* Create and display the form */ + EventQueue.invokeAndWait(TextViewOOM::createAndShowGUI); + for (int i = 0; i < 10; i++) { + System.gc(); + Thread.sleep(1000); + } + long mem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.err.println("Memory before creating the text: "+mem); + final StringBuilder sb = new StringBuilder(N * STRING.length()); + for (int i = 0; i < N; i++) { + sb.append(STRING); + } + for (int i = 0; i < 10; i++) { + System.gc(); + Thread.sleep(1000); + } + mem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.err.println("Memory after creating the text: "+mem); + + EventQueue.invokeAndWait(() -> { + ta.setText(sb.toString()); + for (int i = 0; i < 10; i++) { + System.gc(); + try {Thread.sleep(200);} catch (InterruptedException iex) {} + } + long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.err.println("Memory after setting the text: " + mem1); + }); + for (int i = 0; i < 10; i++) { + System.gc(); + Thread.sleep(1000); + } + mem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.err.println("Final memory after everything: " + mem); + EventQueue.invokeAndWait(frame::dispose); + } +} diff --git a/test/javax/swing/RepaintManager/DisplayListenerLeak/DisplayListenerLeak.java b/test/javax/swing/RepaintManager/DisplayListenerLeak/DisplayListenerLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..ea924bb5541223aff336cba36525c0d625ca2038 --- /dev/null +++ b/test/javax/swing/RepaintManager/DisplayListenerLeak/DisplayListenerLeak.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015, 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.BorderLayout; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.GraphicsEnvironment; + +import javax.swing.JFrame; +import javax.swing.JLabel; + +import sun.java2d.SunGraphicsEnvironment; + +/** + * @test + * @bug 8041654 + * @run main/othervm -Xmx80m DisplayListenerLeak + */ +public final class DisplayListenerLeak { + + private static JFrame frame; + private volatile static boolean failed = false; + + private static void createAndShowGUI() { + Thread.currentThread().setUncaughtExceptionHandler((t, e) -> { + e.printStackTrace(); + failed = true; + }); + frame = new JFrame(); + JLabel emptyLabel = new JLabel(""); + emptyLabel.setPreferredSize(new Dimension(600, 400)); + frame.getContentPane().add(emptyLabel, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + } + + public static void main(final String[] args) throws Exception { + GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + if (!(ge instanceof SunGraphicsEnvironment)) { + return; + } + EventQueue.invokeAndWait(() -> createAndShowGUI()); + SunGraphicsEnvironment sge = (SunGraphicsEnvironment) ge; + final long startTime = System.nanoTime(); + while (!failed) { + if (System.nanoTime() - startTime > 60_000_000_000L) { + break; + } + System.gc(); // clear all weak references + EventQueue.invokeAndWait(() -> { + frame.setSize(frame.getHeight(), frame.getWidth()); + frame.pack(); + }); + EventQueue.invokeAndWait(sge::displayChanged); + } + EventQueue.invokeAndWait(frame::dispose); + if (failed) { + throw new RuntimeException(); + } + } +} \ No newline at end of file diff --git a/test/javax/xml/jaxp/common/8032908/TestFunc.java b/test/javax/xml/jaxp/common/8032908/TestFunc.java index 20eb23fa513da3fef777ecb9b3021a95d3ee3437..62a18f777498c046ccb0f6728a7e17ac9b8dae89 100644 --- a/test/javax/xml/jaxp/common/8032908/TestFunc.java +++ b/test/javax/xml/jaxp/common/8032908/TestFunc.java @@ -26,8 +26,9 @@ import org.w3c.dom.Node; public class TestFunc { public static String test(Node node) { - String s = node.getTextContent(); - return s; + String textContent = node.getTextContent(); + String nodeValue = node.getNodeValue(); + return textContent + ":" + nodeValue; } } diff --git a/test/javax/xml/jaxp/common/8032908/XSLT.java b/test/javax/xml/jaxp/common/8032908/XSLT.java index 77ddcbcfaea783facdfcb23663ad700653c6455e..22a4346edae7240ed116896d95562f3d254c7020 100644 --- a/test/javax/xml/jaxp/common/8032908/XSLT.java +++ b/test/javax/xml/jaxp/common/8032908/XSLT.java @@ -23,9 +23,10 @@ /** * @test - * @bug 8032908 + * @bug 8032908 8081392 * @summary Test if Node.getTextContent() function correctly returns children - * content + * content and also check that Node.getNodeValue() returns null value for + * Element nodes * @compile TestFunc.java XSLT.java * @run main/othervm XSLT */ @@ -40,7 +41,7 @@ public class XSLT { static final String XMLTOTRANSFORM = "/in.xml"; static final String XSLTRANSFORMER = "/test.xsl"; - static final String EXPECTEDRESULT = "ABCDEFG"; + static final String EXPECTEDRESULT = "ABCDEFG:null"; public static void main(String[] args) throws TransformerException { ByteArrayOutputStream resStream = new ByteArrayOutputStream(); diff --git a/test/javax/xml/jaxp/transform/8062518/DocumentExtFunc.java b/test/javax/xml/jaxp/transform/8062518/DocumentExtFunc.java index e811aed4b6e79319fa2e9cb32f65cf95628541e7..677e5dbc7a338807b1d4ab41df9e38ff3e89452b 100644 --- a/test/javax/xml/jaxp/transform/8062518/DocumentExtFunc.java +++ b/test/javax/xml/jaxp/transform/8062518/DocumentExtFunc.java @@ -27,6 +27,6 @@ public class DocumentExtFunc { public static String test(NodeList list) { Node node = list.item(0); - return "["+node.getNodeName() + ":" + node.getNodeValue()+"]"; + return "[" + node.getNodeName() + ":" + node.getTextContent() + "]"; } }