mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-10 10:28:37 +00:00
Merge
This commit is contained in:
commit
cc54a8a71d
@ -75,6 +75,7 @@ SUNWprivate_1.1 {
|
||||
|
||||
Java_java_io_FileDescriptor_initIDs;
|
||||
Java_java_io_FileDescriptor_sync;
|
||||
Java_java_io_FileDescriptor_getAppend;
|
||||
Java_java_io_FileInputStream_available;
|
||||
Java_java_io_FileInputStream_close0;
|
||||
Java_java_io_FileInputStream_initIDs;
|
||||
|
||||
@ -1588,7 +1588,7 @@ public class File
|
||||
/**
|
||||
* A convenience method to set the owner's read permission for this abstract
|
||||
* pathname. On some platforms it may be possible to start the Java virtual
|
||||
* machine with special privileges that allow it to read files that that are
|
||||
* machine with special privileges that allow it to read files that are
|
||||
* marked as unreadable.
|
||||
*
|
||||
* <p>An invocation of this method of the form <tt>file.setReadable(arg)</tt>
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
package java.io;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
|
||||
|
||||
@ -52,16 +54,17 @@ import sun.nio.ch.FileChannelImpl;
|
||||
public
|
||||
class FileOutputStream extends OutputStream
|
||||
{
|
||||
/**
|
||||
* Access to FileDescriptor internals.
|
||||
*/
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
/**
|
||||
* The system dependent file descriptor.
|
||||
*/
|
||||
private final FileDescriptor fd;
|
||||
|
||||
/**
|
||||
* True if the file is opened for append.
|
||||
*/
|
||||
private final boolean append;
|
||||
|
||||
/**
|
||||
* The associated channel, initialized lazily.
|
||||
*/
|
||||
@ -207,7 +210,6 @@ class FileOutputStream extends OutputStream
|
||||
}
|
||||
this.fd = new FileDescriptor();
|
||||
fd.attach(this);
|
||||
this.append = append;
|
||||
this.path = name;
|
||||
|
||||
open(name, append);
|
||||
@ -245,7 +247,6 @@ class FileOutputStream extends OutputStream
|
||||
security.checkWrite(fdObj);
|
||||
}
|
||||
this.fd = fdObj;
|
||||
this.append = false;
|
||||
this.path = null;
|
||||
|
||||
fd.attach(this);
|
||||
@ -287,7 +288,7 @@ class FileOutputStream extends OutputStream
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(int b) throws IOException {
|
||||
write(b, append);
|
||||
write(b, fdAccess.getAppend(fd));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +311,7 @@ class FileOutputStream extends OutputStream
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(byte b[]) throws IOException {
|
||||
writeBytes(b, 0, b.length, append);
|
||||
writeBytes(b, 0, b.length, fdAccess.getAppend(fd));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,7 +324,7 @@ class FileOutputStream extends OutputStream
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
writeBytes(b, off, len, append);
|
||||
writeBytes(b, off, len, fdAccess.getAppend(fd));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,7 +396,7 @@ class FileOutputStream extends OutputStream
|
||||
public FileChannel getChannel() {
|
||||
synchronized (this) {
|
||||
if (channel == null) {
|
||||
channel = FileChannelImpl.open(fd, path, false, true, append, this);
|
||||
channel = FileChannelImpl.open(fd, path, false, true, this);
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ public abstract class FileStore {
|
||||
* @param attribute
|
||||
* the attribute to read
|
||||
|
||||
* @return the attribute value; {@code null} may be a valid for some
|
||||
* @return the attribute value; {@code null} may be valid for some
|
||||
* attributes
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
* <p> An attribute view provides a read-only or updatable view of the non-opaque
|
||||
* values, or <em>metadata</em>, associated with objects in a file system.
|
||||
* The {@link java.nio.file.attribute.FileAttributeView} interface is
|
||||
* extended by several other interfaces that views to specific sets of file
|
||||
* extended by several other interfaces that provide views to specific sets of file
|
||||
* attributes. {@code FileAttributeViews} are selected by invoking the {@link
|
||||
* java.nio.file.Files#getFileAttributeView} method with a
|
||||
* <em>type-token</em> to identify the required view. Views can also be identified
|
||||
|
||||
@ -518,7 +518,7 @@ public interface Collection<E> extends Iterable<E> {
|
||||
* <p>The default implementation should be overridden by subclasses that
|
||||
* can return a more efficient spliterator. In order to
|
||||
* preserve expected laziness behavior for the {@link #stream()} and
|
||||
* {@link #parallelStream()}} methods, spliterators should either have the
|
||||
* {@link #parallelStream()} methods, spliterators should either have the
|
||||
* characteristic of {@code IMMUTABLE} or {@code CONCURRENT}, or be
|
||||
* <em><a href="Spliterator.html#binding">late-binding</a></em>.
|
||||
* If none of these is practical, the overriding class should describe the
|
||||
|
||||
@ -33,6 +33,8 @@ import java.io.FileDescriptor;
|
||||
public interface JavaIOFileDescriptorAccess {
|
||||
public void set(FileDescriptor obj, int fd);
|
||||
public int get(FileDescriptor fd);
|
||||
public void setAppend(FileDescriptor obj, boolean append);
|
||||
public boolean getAppend(FileDescriptor obj);
|
||||
|
||||
// Only valid on Windows
|
||||
public void setHandle(FileDescriptor obj, long handle);
|
||||
|
||||
@ -44,6 +44,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.JavaIOFileDescriptorAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
public class FileChannelImpl
|
||||
@ -52,6 +54,10 @@ public class FileChannelImpl
|
||||
// Memory allocation size for mapping buffers
|
||||
private static final long allocationGranularity;
|
||||
|
||||
// Access to FileDispatcher internals
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
// Used to make native read and write calls
|
||||
private final FileDispatcher nd;
|
||||
|
||||
@ -61,7 +67,6 @@ public class FileChannelImpl
|
||||
// File access mode (immutable)
|
||||
private final boolean writable;
|
||||
private final boolean readable;
|
||||
private final boolean append;
|
||||
|
||||
// Required to prevent finalization of creating stream (immutable)
|
||||
private final Object parent;
|
||||
@ -77,31 +82,23 @@ public class FileChannelImpl
|
||||
private final Object positionLock = new Object();
|
||||
|
||||
private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
|
||||
boolean writable, boolean append, Object parent)
|
||||
boolean writable, Object parent)
|
||||
{
|
||||
this.fd = fd;
|
||||
this.readable = readable;
|
||||
this.writable = writable;
|
||||
this.append = append;
|
||||
this.parent = parent;
|
||||
this.path = path;
|
||||
this.nd = new FileDispatcherImpl(append);
|
||||
this.nd = new FileDispatcherImpl();
|
||||
}
|
||||
|
||||
// Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
|
||||
// Used by FileInputStream.getChannel(), FileOutputStream.getChannel
|
||||
// and RandomAccessFile.getChannel()
|
||||
public static FileChannel open(FileDescriptor fd, String path,
|
||||
boolean readable, boolean writable,
|
||||
Object parent)
|
||||
{
|
||||
return new FileChannelImpl(fd, path, readable, writable, false, parent);
|
||||
}
|
||||
|
||||
// Used by FileOutputStream.getChannel
|
||||
public static FileChannel open(FileDescriptor fd, String path,
|
||||
boolean readable, boolean writable,
|
||||
boolean append, Object parent)
|
||||
{
|
||||
return new FileChannelImpl(fd, path, readable, writable, append, parent);
|
||||
return new FileChannelImpl(fd, path, readable, writable, parent);
|
||||
}
|
||||
|
||||
private void ensureOpen() throws IOException {
|
||||
@ -109,7 +106,6 @@ public class FileChannelImpl
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
|
||||
// -- Standard channel operations --
|
||||
|
||||
protected void implCloseChannel() throws IOException {
|
||||
@ -258,6 +254,7 @@ public class FileChannelImpl
|
||||
ti = threads.add();
|
||||
if (!isOpen())
|
||||
return 0;
|
||||
boolean append = fdAccess.getAppend(fd);
|
||||
do {
|
||||
// in append-mode then position is advanced to end before writing
|
||||
p = (append) ? nd.size(fd) : position0(fd, -1);
|
||||
@ -284,7 +281,7 @@ public class FileChannelImpl
|
||||
if (!isOpen())
|
||||
return null;
|
||||
do {
|
||||
p = position0(fd, newPosition);
|
||||
p = position0(fd, newPosition);
|
||||
} while ((p == IOStatus.INTERRUPTED) && isOpen());
|
||||
return this;
|
||||
} finally {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
extern jfieldID IO_fd_fdID;
|
||||
extern jfieldID IO_handle_fdID;
|
||||
extern jfieldID IO_append_fdID;
|
||||
|
||||
#ifdef _ALLBSD_SOURCE
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -51,16 +51,22 @@ public final class FileDescriptor {
|
||||
private List<Closeable> otherParents;
|
||||
private boolean closed;
|
||||
|
||||
/**
|
||||
* true, if file is opened for appending.
|
||||
*/
|
||||
private boolean append;
|
||||
|
||||
/**
|
||||
* Constructs an (invalid) FileDescriptor
|
||||
* object.
|
||||
*/
|
||||
public /**/ FileDescriptor() {
|
||||
public FileDescriptor() {
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
private /* */ FileDescriptor(int fd) {
|
||||
private FileDescriptor(int fd) {
|
||||
this.fd = fd;
|
||||
this.append = getAppend(fd);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,6 +155,14 @@ public final class FileDescriptor {
|
||||
return obj.fd;
|
||||
}
|
||||
|
||||
public void setAppend(FileDescriptor obj, boolean append) {
|
||||
obj.append = append;
|
||||
}
|
||||
|
||||
public boolean getAppend(FileDescriptor obj) {
|
||||
return obj.append;
|
||||
}
|
||||
|
||||
public void setHandle(FileDescriptor obj, long handle) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@ -160,6 +174,11 @@ public final class FileDescriptor {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if the file was opened for appending.
|
||||
*/
|
||||
private static native boolean getAppend(int fd);
|
||||
|
||||
/*
|
||||
* Package private methods to track referents.
|
||||
* If multiple streams point to the same FileDescriptor, we cycle
|
||||
|
||||
@ -35,10 +35,6 @@ class FileDispatcherImpl extends FileDispatcher
|
||||
init();
|
||||
}
|
||||
|
||||
FileDispatcherImpl(boolean append) {
|
||||
/* append is ignored */
|
||||
}
|
||||
|
||||
FileDispatcherImpl() {
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ class UnixChannelFactory {
|
||||
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
|
||||
|
||||
FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
|
||||
return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null);
|
||||
return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,6 +288,7 @@ class UnixChannelFactory {
|
||||
// create java.io.FileDescriptor
|
||||
FileDescriptor fdObj = new FileDescriptor();
|
||||
fdAccess.set(fdObj, fd);
|
||||
fdAccess.setAppend(fdObj, flags.append);
|
||||
return fdObj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,9 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "jvm.h"
|
||||
#include "io_util_md.h"
|
||||
|
||||
@ -35,6 +38,9 @@
|
||||
/* field id for jint 'fd' in java.io.FileDescriptor */
|
||||
jfieldID IO_fd_fdID;
|
||||
|
||||
/* field id for jboolean 'append' in java.io.FileDescriptor */
|
||||
jfieldID IO_append_fdID;
|
||||
|
||||
/**************************************************************
|
||||
* static methods to store field ID's in initializers
|
||||
*/
|
||||
@ -42,6 +48,7 @@ jfieldID IO_fd_fdID;
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
|
||||
IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I");
|
||||
IO_append_fdID = (*env)->GetFieldID(env, fdClass, "append", "Z");
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
@ -55,3 +62,9 @@ Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
|
||||
JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_java_io_FileDescriptor_getAppend(JNIEnv *env, jclass fdClass, jint fd) {
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
return ((flags & O_APPEND) == 0) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
@ -107,7 +107,15 @@ fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
|
||||
#endif
|
||||
fd = handleOpen(ps, flags, 0666);
|
||||
if (fd != -1) {
|
||||
jobject fdobj;
|
||||
jboolean append;
|
||||
SET_FD(this, fd, fid);
|
||||
|
||||
fdobj = (*env)->GetObjectField(env, this, fid);
|
||||
if (fdobj != NULL) {
|
||||
append = (flags & O_APPEND) == 0 ? JNI_FALSE : JNI_TRUE;
|
||||
(*env)->SetBooleanField(env, fdobj, IO_append_fdID, append);
|
||||
}
|
||||
} else {
|
||||
throwFileNotFoundException(env, path);
|
||||
}
|
||||
|
||||
@ -50,6 +50,11 @@ public final class FileDescriptor {
|
||||
private List<Closeable> otherParents;
|
||||
private boolean closed;
|
||||
|
||||
/**
|
||||
* true, if file is opened for appending.
|
||||
*/
|
||||
private boolean append;
|
||||
|
||||
/**
|
||||
* Constructs an (invalid) FileDescriptor
|
||||
* object.
|
||||
@ -75,6 +80,14 @@ public final class FileDescriptor {
|
||||
return obj.fd;
|
||||
}
|
||||
|
||||
public void setAppend(FileDescriptor obj, boolean append) {
|
||||
obj.append = append;
|
||||
}
|
||||
|
||||
public boolean getAppend(FileDescriptor obj) {
|
||||
return obj.append;
|
||||
}
|
||||
|
||||
public void setHandle(FileDescriptor obj, long handle) {
|
||||
obj.handle = handle;
|
||||
}
|
||||
|
||||
@ -31,22 +31,14 @@ import sun.misc.JavaIOFileDescriptorAccess;
|
||||
|
||||
class FileDispatcherImpl extends FileDispatcher
|
||||
{
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the dispatcher should first advance the file position
|
||||
* to the end of file when writing.
|
||||
*/
|
||||
private final boolean append;
|
||||
|
||||
FileDispatcherImpl(boolean append) {
|
||||
this.append = append;
|
||||
}
|
||||
|
||||
FileDispatcherImpl() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +63,7 @@ class FileDispatcherImpl extends FileDispatcher
|
||||
}
|
||||
|
||||
int write(FileDescriptor fd, long address, int len) throws IOException {
|
||||
return write0(fd, address, len, append);
|
||||
return write0(fd, address, len, fdAccess.getAppend(fd));
|
||||
}
|
||||
|
||||
int pwrite(FileDescriptor fd, long address, int len, long position)
|
||||
@ -81,7 +73,7 @@ class FileDispatcherImpl extends FileDispatcher
|
||||
}
|
||||
|
||||
long writev(FileDescriptor fd, long address, int len) throws IOException {
|
||||
return writev0(fd, address, len, append);
|
||||
return writev0(fd, address, len, fdAccess.getAppend(fd));
|
||||
}
|
||||
|
||||
int force(FileDescriptor fd, boolean metaData) throws IOException {
|
||||
@ -112,8 +104,6 @@ class FileDispatcherImpl extends FileDispatcher
|
||||
|
||||
FileDescriptor duplicateForMapping(FileDescriptor fd) throws IOException {
|
||||
// on Windows we need to keep a handle to the file
|
||||
JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
FileDescriptor result = new FileDescriptor();
|
||||
long handle = duplicateHandle(fdAccess.getHandle(fd));
|
||||
fdAccess.setHandle(result, handle);
|
||||
|
||||
@ -160,7 +160,7 @@ class WindowsChannelFactory {
|
||||
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
|
||||
|
||||
FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
|
||||
return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null);
|
||||
return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -339,6 +339,7 @@ class WindowsChannelFactory {
|
||||
// create FileDescriptor and return
|
||||
FileDescriptor fdObj = new FileDescriptor();
|
||||
fdAccess.setHandle(fdObj, handle);
|
||||
fdAccess.setAppend(fdObj, flags.append);
|
||||
return fdObj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,9 @@ jfieldID IO_fd_fdID;
|
||||
/* field id for jlong 'handle' in java.io.FileDescriptor */
|
||||
jfieldID IO_handle_fdID;
|
||||
|
||||
/* field id for jboolean 'append' in java.io.FileDescriptor */
|
||||
jfieldID IO_append_fdID;
|
||||
|
||||
/**************************************************************
|
||||
* static methods to store field IDs in initializers
|
||||
*/
|
||||
@ -50,6 +53,7 @@ JNIEXPORT void JNICALL
|
||||
Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
|
||||
CHECK_NULL(IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I"));
|
||||
CHECK_NULL(IO_handle_fdID = (*env)->GetFieldID(env, fdClass, "handle", "J"));
|
||||
CHECK_NULL(IO_append_fdID = (*env)->GetFieldID(env, fdClass, "append", "Z"));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
|
||||
@ -275,7 +275,15 @@ fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
|
||||
{
|
||||
FD h = winFileHandleOpen(env, path, flags);
|
||||
if (h >= 0) {
|
||||
jobject fdobj;
|
||||
jboolean append;
|
||||
SET_FD(this, h, fid);
|
||||
|
||||
fdobj = (*env)->GetObjectField(env, this, fid);
|
||||
if (fdobj != NULL) {
|
||||
append = (flags & O_APPEND) == 0 ? JNI_FALSE : JNI_TRUE;
|
||||
(*env)->SetBooleanField(env, fdobj, IO_append_fdID, append);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ import javax.management.MBeanServerFactory;
|
||||
* <code>DefaultLoaderRepository</code> be rewritten.</p>
|
||||
*
|
||||
* @deprecated Use
|
||||
* {@link javax.management.MBeanServer#getClassLoaderRepository()}}
|
||||
* {@link javax.management.MBeanServer#getClassLoaderRepository()}
|
||||
* instead.
|
||||
*
|
||||
* @since 1.5
|
||||
|
||||
@ -803,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
|
||||
|
||||
@ -200,6 +200,9 @@ java/nio/file/WatchService/LotsOfEvents.java solaris-all
|
||||
|
||||
# jdk_rmi
|
||||
|
||||
# 7140992
|
||||
java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
|
||||
|
||||
# 7146541
|
||||
java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
|
||||
|
||||
|
||||
@ -12,3 +12,6 @@ exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote su
|
||||
|
||||
# Group definitions
|
||||
groups=TEST.groups [closed/TEST.groups]
|
||||
|
||||
# Tests using jtreg 4.1 b10 features
|
||||
requiredVersion=4.1 b10
|
||||
|
||||
54
jdk/test/java/io/FileDescriptor/RememberAppend.java
Normal file
54
jdk/test/java/io/FileDescriptor/RememberAppend.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8023173
|
||||
* @summary FileDescriptor should respect append flag
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
public class RememberAppend {
|
||||
private static final byte[] bytes = "ABC ".getBytes();
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
File f = File.createTempFile("tmp.file", null);
|
||||
f.deleteOnExit();
|
||||
|
||||
try (FileOutputStream fos1 = new FileOutputStream(f.getPath(), true)) {
|
||||
fos1.write(bytes);
|
||||
}
|
||||
|
||||
try (FileOutputStream fos1 = new FileOutputStream(f.getPath(), true);
|
||||
FileOutputStream fos2 = new FileOutputStream(fos1.getFD())) {
|
||||
fos2.write(bytes);
|
||||
}
|
||||
|
||||
if (f.length() != 2 * bytes.length) {
|
||||
throw new RuntimeException("Append flag ignored");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,11 +29,11 @@ import java.net.URLPermission;
|
||||
* @bug 8010464
|
||||
* @library /lib/testlibrary/
|
||||
* @build jdk.testlibrary.SimpleSSLContext
|
||||
* @run main/othervm/policy=policy.1 URLTest one
|
||||
* @run main/othervm/java.security.policy=policy.1 URLTest one
|
||||
* @run main/othervm URLTest one
|
||||
* @run main/othervm/policy=policy.2 URLTest two
|
||||
* @run main/othervm/java.security.policy=policy.2 URLTest two
|
||||
* @run main/othervm URLTest two
|
||||
* @run main/othervm/policy=policy.3 URLTest three
|
||||
* @run main/othervm/java.security.policy=policy.3 URLTest three
|
||||
* @run main/othervm URLTest three
|
||||
*/
|
||||
|
||||
|
||||
@ -37,60 +37,3 @@ grant {
|
||||
permission "java.util.PropertyPermission" "test.src.path", "read";
|
||||
};
|
||||
|
||||
// Normal permissions that aren't granted when run under jtreg
|
||||
grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
|
||||
permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunec";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunEC";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunEC";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunEC";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
|
||||
Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
|
||||
};
|
||||
|
||||
grant codeBase "file:${{java.home}}/jre/lib/rt.jar" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
|
||||
@ -37,60 +37,3 @@ grant {
|
||||
permission "java.util.PropertyPermission" "test.src.path", "read";
|
||||
};
|
||||
|
||||
// Normal permissions that aren't granted when run under jtreg
|
||||
grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
|
||||
permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunec";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunEC";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunEC";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunEC";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
|
||||
Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
|
||||
};
|
||||
|
||||
grant codeBase "file:///export/repos/jdk8/build/linux-x86_64-normal-server-fastdebug/images/j2sdk-image/jre/lib/rt.jar" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
|
||||
@ -36,61 +36,3 @@ grant {
|
||||
permission "java.lang.RuntimePermission" "setFactory";
|
||||
permission "java.util.PropertyPermission" "test.src.path", "read";
|
||||
};
|
||||
|
||||
// Normal permissions that aren't granted when run under jtreg
|
||||
grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
|
||||
permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunec";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunEC";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunEC";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunEC";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
|
||||
Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
|
||||
};
|
||||
|
||||
grant codeBase "file:${{java.home}}/jre/lib/rt.jar" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
* @library ../../../testlibrary
|
||||
* @build TestLibrary RMID ActivationLibrary
|
||||
* ActivateMe ActivateFails_Stub ShutdownThread
|
||||
* @run main/othervm/policy=security.policy/timeout=240 ActivateFails
|
||||
* @run main/othervm/java.security.policy=security.policy/timeout=240 ActivateFails
|
||||
*/
|
||||
|
||||
import java.rmi.*;
|
||||
|
||||
@ -2,10 +2,6 @@
|
||||
* security policy used by the test process
|
||||
*/
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/*" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
grant {
|
||||
// standard test activation permissions
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* @library ../../../testlibrary
|
||||
* @build TestLibrary RMID ActivationLibrary
|
||||
* CanCreateStubs StubClassesPermitted_Stub
|
||||
* @run main/othervm/policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
|
||||
* @run main/othervm/java.security.policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -2,10 +2,6 @@
|
||||
* security policy used by the test process
|
||||
*/
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/*" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
grant {
|
||||
// standard test activation permissions
|
||||
permission java.io.FilePermission "..${/}..${/}test.props", "read";
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @bug 4532506 4999599
|
||||
* @summary Serializing KeyPair on one VM (Sun),
|
||||
* and Deserializing on another (IBM) fails
|
||||
* @run main/othervm/policy=Serial.policy Serial
|
||||
* @run main/othervm/java.security.policy=Serial.policy Serial
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -1,12 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant {
|
||||
// XXX note package access is *not* granted to the 'sun' package
|
||||
};
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @bug 6232513
|
||||
* @summary RMI interoperability issue with DSAPublicKey obj between
|
||||
* JDK1.4 & JDK1.5
|
||||
* @run main/othervm/policy=SerialDSAPubKey.policy -Dsun.security.key.serial.interop=true -Dsun.security.pkcs11.enable-solaris=false SerialDSAPubKey
|
||||
* @run main/othervm/java.security.policy=SerialDSAPubKey.policy -Dsun.security.key.serial.interop=true -Dsun.security.pkcs11.enable-solaris=false SerialDSAPubKey
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @bug 4532506
|
||||
* @summary Serializing KeyPair on one VM (Sun),
|
||||
* and Deserializing on another (IBM) fails
|
||||
* @run main/othervm/policy=SerialOld.policy SerialOld
|
||||
* @run main/othervm/java.security.policy=SerialOld.policy SerialOld
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -1,55 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/ucrypto.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2ucrypto";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
|
||||
permission java.io.FilePermission "${java.home}/lib/security/ucrypto-solaris.cfg", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunec.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunec";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunEC";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunEC";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunEC";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" {
|
||||
Permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "loadLibrary.sunmscapi";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunMSCAPI";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunMSCAPI";
|
||||
};
|
||||
|
||||
grant {
|
||||
|
||||
permission java.io.FilePermission "${test.src}${file.separator}*", "read";
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4420687
|
||||
* @summary Make sure that a removed provider won't be acceessable.
|
||||
* @run main/othervm/policy=RemoveStaticProvider.policy RemoveStaticProvider
|
||||
* @run main/othervm/java.security.policy=RemoveStaticProvider.policy RemoveStaticProvider
|
||||
*/
|
||||
import java.security.*;
|
||||
import javax.crypto.*;
|
||||
|
||||
@ -1,13 +1,3 @@
|
||||
|
||||
grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.SunJCE";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.SunJCE";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.SunJCE";
|
||||
};
|
||||
|
||||
grant {
|
||||
permission java.security.SecurityPermission "removeProvider.SunJCE";
|
||||
permission java.security.SecurityPermission "insertProvider.SunJCE";
|
||||
|
||||
@ -28,11 +28,13 @@ 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 {
|
||||
|
||||
@ -96,4 +98,29 @@ public class BaseTest {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.Blob;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public class StubBlob implements Blob {
|
||||
public long length() throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
public byte[] getBytes(long pos, int length)
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
public InputStream getBinaryStream()
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
public long position(byte[] pattern, long start)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
public long position(Blob pattern, long start)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
public int setBytes(long pos, byte[] bytes)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
public int setBytes(long pos, byte[] bytes, int offset, int len)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
public OutputStream setBinaryStream(long pos)
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
public void truncate(long len)
|
||||
throws SQLException {
|
||||
}
|
||||
/* 6.0 implementation */
|
||||
|
||||
public void free() throws SQLException {}
|
||||
|
||||
public InputStream getBinaryStream(long pos, long length) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
# JDBC unit tests uses TestNG
|
||||
TestNG.dirs= .
|
||||
othervm.dirs= .
|
||||
lib.dirs = /java/sql/
|
||||
|
||||
555
jdk/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java
Normal file
555
jdk/test/javax/sql/testng/test/rowset/RowSetMetaDataTests.java
Normal file
@ -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"}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.security.Policy;
|
||||
import java.sql.SQLException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
protected final String reason = "reason";
|
||||
protected final String state = "SQLState";
|
||||
protected final String cause = "java.lang.Throwable: cause";
|
||||
protected final Throwable t = new Throwable("cause");
|
||||
protected final Throwable t1 = new Throwable("cause 1");
|
||||
protected final Throwable t2 = new Throwable("cause 2");
|
||||
protected final int errorCode = 21;
|
||||
protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
|
||||
"Exception 3", "cause 2"};
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void tearDownMethod() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
* Take some form of SQLException, serialize and deserialize it
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends SQLException> T
|
||||
createSerializedException(T ex)
|
||||
throws IOException, ClassNotFoundException {
|
||||
return (T) serializeDeserializeObject(ex);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility method to serialize and deserialize an object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T serializeDeserializeObject(T o)
|
||||
throws IOException, ClassNotFoundException {
|
||||
T o1;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
oos.writeObject(o);
|
||||
}
|
||||
try (ObjectInputStream ois
|
||||
= new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
o1 = (T) ois.readObject();
|
||||
}
|
||||
return o1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility Method used to set the current Policy
|
||||
*/
|
||||
protected static void setPolicy(Policy p) {
|
||||
Policy.setPolicy(p);
|
||||
}
|
||||
}
|
||||
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.FilePermission;
|
||||
import java.security.AllPermission;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.Permissions;
|
||||
import java.security.Policy;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.security.SecurityPermission;
|
||||
import java.sql.SQLPermission;
|
||||
import java.util.Enumeration;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/*
|
||||
* Simple Policy class that supports the required Permissions to validate the
|
||||
* JDBC concrete classes
|
||||
*/
|
||||
public class TestPolicy extends Policy {
|
||||
|
||||
final PermissionCollection permissions = new Permissions();
|
||||
|
||||
/**
|
||||
* Constructor which sets the minimum permissions allowing testNG to work
|
||||
* with a SecurityManager
|
||||
*/
|
||||
public TestPolicy() {
|
||||
setMinimalPermissions();
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor which determines which permissions are defined for this
|
||||
* Policy used by the JDBC tests Possible values are: all (ALLPermissions),
|
||||
* setLog (SQLPemission("setLog"), deregisterDriver
|
||||
* (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
|
||||
* and setSyncFactory(SQLPermission(setSyncFactory),
|
||||
*
|
||||
* @param policy Permissions to set
|
||||
*/
|
||||
public TestPolicy(String policy) {
|
||||
|
||||
switch (policy) {
|
||||
case "all":
|
||||
permissions.add(new AllPermission());
|
||||
break;
|
||||
case "setLog":
|
||||
setMinimalPermissions();
|
||||
permissions.add(new SQLPermission("setLog"));
|
||||
break;
|
||||
case "deregisterDriver":
|
||||
setMinimalPermissions();
|
||||
permissions.add(new SQLPermission("deregisterDriver"));
|
||||
break;
|
||||
case "setSyncFactory":
|
||||
setMinimalPermissions();
|
||||
permissions.add(new SQLPermission("setSyncFactory"));
|
||||
break;
|
||||
default:
|
||||
setMinimalPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Defines the minimal permissions required by testNG when running these
|
||||
* tests
|
||||
*/
|
||||
private void setMinimalPermissions() {
|
||||
permissions.add(new SecurityPermission("getPolicy"));
|
||||
permissions.add(new SecurityPermission("setPolicy"));
|
||||
permissions.add(new RuntimePermission("getClassLoader"));
|
||||
permissions.add(new RuntimePermission("setSecurityManager"));
|
||||
permissions.add(new RuntimePermission("createSecurityManager"));
|
||||
permissions.add(new PropertyPermission("testng.show.stack.frames",
|
||||
"read"));
|
||||
permissions.add(new PropertyPermission("line.separator", "read"));
|
||||
permissions.add(new PropertyPermission("fileStringBuffer", "read"));
|
||||
permissions.add(new PropertyPermission("dataproviderthreadcount", "read"));
|
||||
permissions.add(new PropertyPermission("java.io.tmpdir", "read"));
|
||||
permissions.add(new FilePermission("<<ALL FILES>>",
|
||||
"read, write, delete"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Overloaded methods from the Policy class
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringJoiner sj = new StringJoiner("\n", "policy: ", "");
|
||||
Enumeration<Permission> perms = permissions.elements();
|
||||
while (perms.hasMoreElements()) {
|
||||
sj.add(perms.nextElement().toString());
|
||||
}
|
||||
return sj.toString();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCollection getPermissions(ProtectionDomain domain) {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCollection getPermissions(CodeSource codesource) {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return permissions.implies(perm);
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,7 @@ import java.io.IOException;
|
||||
* @summary Basic test for zip provider
|
||||
*
|
||||
* @run main Basic
|
||||
* @run main/othervm/policy=test.policy Basic
|
||||
* @run main/othervm/java.security.policy=test.policy Basic
|
||||
*/
|
||||
|
||||
public class Basic {
|
||||
|
||||
@ -33,7 +33,7 @@ import java.io.IOException;
|
||||
* @summary Tests path operations for zip provider.
|
||||
*
|
||||
* @run main PathOps
|
||||
* @run main/othervm/policy=test.policy.readonly PathOps
|
||||
* @run main/othervm/java.security.policy=test.policy.readonly PathOps
|
||||
*/
|
||||
|
||||
public class PathOps {
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @summary ZipFileSystem regression tests
|
||||
*
|
||||
* @run main ZFSTests
|
||||
* @run main/othervm/policy=test.policy ZFSTests
|
||||
* @run main/othervm/java.security.policy=test.policy ZFSTests
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ import static java.nio.file.StandardCopyOption.*;
|
||||
* 7157656 8002390 7012868 7012856 8015728 8038500 8040059
|
||||
* @summary Test Zip filesystem provider
|
||||
* @run main ZipFSTester
|
||||
* @run main/othervm/policy=test.policy ZipFSTester
|
||||
* @run main/othervm/java.security.policy=test.policy ZipFSTester
|
||||
*/
|
||||
|
||||
public class ZipFSTester {
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read,write";
|
||||
permission java.lang.RuntimePermission "fileSystemProvider";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "<<ALL FILES>>","read,write,delete";
|
||||
permission java.util.PropertyPermission "test.jdk","read";
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/zipfs.jar" {
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read,write";
|
||||
permission java.lang.RuntimePermission "fileSystemProvider";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "<<ALL FILES>>","read";
|
||||
permission java.util.PropertyPermission "test.jdk","read";
|
||||
|
||||
@ -1,17 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codebase "file:${user.dir}${/}loader.jar" {
|
||||
permission java.security.AllPermission;
|
||||
};
|
||||
|
||||
@ -1,18 +1,3 @@
|
||||
grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
|
||||
permission java.lang.RuntimePermission "loadLibrary.j2pkcs11";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
permission java.security.SecurityPermission "putProviderProperty.*";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.*";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.*";
|
||||
permission java.security.SecurityPermission "getProperty.auth.login.defaultCallbackHandler";
|
||||
|
||||
permission java.security.SecurityPermission "authProvider.*";
|
||||
// Needed for reading PKCS11 config file and NSS library check
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant {
|
||||
permission java.util.PropertyPermission "*", "read, write";
|
||||
permission java.lang.RuntimePermission "loadLibrary.*";
|
||||
@ -23,6 +8,5 @@ grant {
|
||||
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
permission java.security.SecurityPermission "setProperty.auth.login.defaultCallbackHandler";
|
||||
permission java.security.SecurityPermission "authProvider.SunPKCS11-NSS"
|
||||
;
|
||||
permission java.security.SecurityPermission "authProvider.SunPKCS11-NSS";
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user