3909N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 893N/A * This code is free software; you can redistribute it and/or modify it 893N/A * under the terms of the GNU General Public License version 2 only, as 893N/A * published by the Free Software Foundation. 893N/A * This code is distributed in the hope that it will be useful, but WITHOUT 893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 893N/A * version 2 for more details (a copy is included in the LICENSE file that 893N/A * accompanied this code). 893N/A * You should have received a copy of the GNU General Public License version 893N/A * 2 along with this work; if not, write to the Free Software Foundation, 893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 3471N/A * @bug 4313887 6838333 6917021 7006126 3471N/A * @summary Unit test for java.nio.file.Files copy and move methods 2094N/A * @build CopyAndMove PassThroughFileSystem 2094N/A // Different directories. Use test.dir if possible as it might be 2094N/A // Target is location associated with custom provider 3471N/A // Test copy(InputStream,Path) and copy(Path,OutputStream) 1319N/A // check last modified time 893N/A // move source to target with verification 893N/A // read attributes before file is moved 893N/A // get file attributes of source file 893N/A // hash file contents if regular file 893N/A // record link target if symbolic link 893N/A // read named attributes if available (and file is not a sym link) 893N/A // verify source does not exist 893N/A // verify file contents 893N/A // verify basic attributes 2094N/A // verify other attributes when same provider 3471N/A * Tests all possible ways to invoke move 893N/A * Test: move regular file, target does not exist 893N/A * Test: move regular file, target exists 893N/A * Test: move regular file, target does not exist 893N/A * Test: move regular file, target exists 893N/A * Test: move regular file, target exists and is empty directory 893N/A * Test: move regular file, target exists and is non-empty directory 893N/A * Test atomic move of regular file (same file store) 893N/A * Test atomic move of regular file (different file store) 893N/A * Test: move empty directory, target does not exist 893N/A * Test: move empty directory, target exists 893N/A * Test: move empty directory, target does not exist 893N/A * Test: move empty directory, target exists 893N/A * Test: move empty, target exists and is empty directory 893N/A * Test: move empty directory, target exists and is non-empty directory 893N/A * Test: move non-empty directory (same file system) 893N/A * Test: move non-empty directory (different file store) 893N/A * Test atomic move of directory (same file store) 893N/A // -- symbolic links -- 893N/A * Test: Move symbolic link to file, target does not exist 893N/A * Test: Move symbolic link to directory, target does not exist 893N/A * Test: Move broken symbolic link, target does not exists 893N/A * Test: Move symbolic link, target exists 893N/A * Test: Move regular file, target exists 893N/A * Test: move symbolic link, target exists and is empty directory 893N/A * Test: symbolic link, target exists and is non-empty directory 893N/A * Test atomic move of symbolic link (same file store) 893N/A // copy source to target with verification 893N/A // get attributes of source and target file to verify copy 893N/A // check hash if regular file 893N/A // check link target if symbolic link 893N/A // check that attributes are copied 2094N/A // verify other attributes when same provider 2094N/A // check POSIX attributes are copied 2094N/A // check DOS attributes are copied 2094N/A // check named attributes are copied 3471N/A * Tests all possible ways to invoke copy to copy a file to a file 893N/A * Test: move regular file, target does not exist 893N/A * Test: copy regular file, target exists 893N/A * Test: copy regular file, target does not exist 893N/A * Test: copy regular file, target exists 893N/A * Test: copy regular file, target exists and is empty directory 893N/A * Test: copy regular file, target exists and is non-empty directory 893N/A * Test: copy regular file + attributes 893N/A * Test: copy directory, target does not exist 893N/A * Test: copy directory, target exists 893N/A * Test: copy directory, target does not exist 893N/A * Test: copy directory, target exists 893N/A * Test: copy directory, target exists and is empty directory 893N/A * Test: copy directory, target exists and is non-empty directory 893N/A * Test: copy directory + attributes 893N/A // -- symbolic links -- 893N/A * Test: Copy link (to file) 893N/A * Test: Copy link (to directory) 893N/A * Test: Copy broken link 893N/A * Test: Copy link to UNC (Windows only) 3471N/A * Test copy from an input stream to a file 3471N/A for (
int i=
0; i<
100; i++) {
3471N/A // FileAlreadyExistsException 3471N/A // target file might already exist 3471N/A // copy from stream to file 3471N/A * Test copy from file to output stream 3471N/A for (
int i=
0; i<
100; i++) {
3471N/A // check output stream is open 893N/A // computes simple hash of the given file 893N/A for (
int i=
0; i<n; i++) {
893N/A // create file of random size in given directory 893N/A // create directory in the given directory 893N/A // "randomize" the file attributes of the given file. 893N/A // only set or unset the hidden attribute 893N/A // remove this when copying a direcory copies its named streams 893N/A // create name for file in given directory