/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 4313887 6838333
* @summary Unit test for java.nio.file.SecureDirectoryStream
* @library ..
*/
public class SecureDS {
static boolean supportsLinks;
try {
if (!(stream instanceof SecureDirectoryStream)) {
return;
}
// run tests
} finally {
}
}
// Exercise each of SecureDirectoryStream's method (except move)
// create a file, directory, and two sym links in the directory
// myfilelink -> myfile
if (supportsLinks)
// mydirlink -> mydir
if (supportsLinks)
// open directory and then move it so that it is no longer accessible
// via its original path.
// Test: iterate over all entries
int count = 0;
// Test: getFileAttributeView to access directory's attributes
.isDirectory());
// Test: getFileAttributeView to access attributes of entries
.isRegularFile());
.isRegularFile());
.isDirectory());
.isDirectory());
if (supportsLinks) {
.isRegularFile());
.isSymbolicLink());
.isDirectory());
.isSymbolicLink());
}
// Test: newByteChannel
if (supportsLinks) {
try {
} catch (IOException x) { }
}
// Test: newDirectoryStream
if (supportsLinks) {
try {
.close();
} catch (IOException x) { }
}
// Test: delete
if (supportsLinks) {
}
// clean-up
}
// Exercise SecureDirectoryStream's move method
if (supportsLinks)
// target name
// open stream to both directories
if (supportsLinks) {
}
// Test: move between devices
if (testDirAsString != null) {
try {
} catch (AtomicMoveNotSupportedException x) { }
}
}
// clean-up
}
// null and ClosedDirectoryStreamException
// NullPointerException
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
try {
} catch (NullPointerException x) { }
// close stream
// ClosedDirectoryStreamException
try {
} catch (ClosedDirectoryStreamException x) { }
try {
} catch (ClosedDirectoryStreamException x) { }
try {
} catch (ClosedDirectoryStreamException x) { }
try {
} catch (ClosedDirectoryStreamException x) { }
// clean-up
}
static void assertTrue(boolean b) {
if (!b) throw new RuntimeException("Assertion failed");
}
static void shouldNotGetHere() {
assertTrue(false);
}
}