jdk/test/java/nio/file/Files/CopyAndMove.java
changeset 16048 e8891a5d639f
parent 14011 3d24d5dcf602
child 30046 cf2c86e1819e
equal deleted inserted replaced
16047:d9d63a853848 16048:e8891a5d639f
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /* @test
    24 /* @test
    25  * @bug 4313887 6838333 6917021 7006126 6950237
    25  * @bug 4313887 6838333 6917021 7006126 6950237 8006645
    26  * @summary Unit test for java.nio.file.Files copy and move methods
    26  * @summary Unit test for java.nio.file.Files copy and move methods
    27  * @library ..
    27  * @library ..
    28  * @build CopyAndMove PassThroughFileSystem
    28  * @build CopyAndMove PassThroughFileSystem
    29  * @run main/othervm CopyAndMove
    29  * @run main/othervm CopyAndMove
    30  */
    30  */
    35 import static java.nio.file.StandardCopyOption.*;
    35 import static java.nio.file.StandardCopyOption.*;
    36 import static java.nio.file.LinkOption.*;
    36 import static java.nio.file.LinkOption.*;
    37 import java.nio.file.attribute.*;
    37 import java.nio.file.attribute.*;
    38 import java.io.*;
    38 import java.io.*;
    39 import java.util.*;
    39 import java.util.*;
       
    40 import java.util.concurrent.TimeUnit;
    40 
    41 
    41 public class CopyAndMove {
    42 public class CopyAndMove {
    42     static final Random rand = new Random();
    43     static final Random rand = new Random();
    43     static boolean heads() { return rand.nextBoolean(); }
    44     static boolean heads() { return rand.nextBoolean(); }
    44     private static boolean testPosixAttributes = false;
    45     private static boolean testPosixAttributes = false;
    92         assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
    93         assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
    93         assertTrue(attrs1.isOther() == attrs2.isOther());
    94         assertTrue(attrs1.isOther() == attrs2.isOther());
    94 
    95 
    95         // check last modified time if not a symbolic link
    96         // check last modified time if not a symbolic link
    96         if (!attrs1.isSymbolicLink()) {
    97         if (!attrs1.isSymbolicLink()) {
    97             long time1 = attrs1.lastModifiedTime().toMillis();
    98             long time1 = attrs1.lastModifiedTime().to(TimeUnit.SECONDS);
    98             long time2 = attrs2.lastModifiedTime().toMillis();
    99             long time2 = attrs2.lastModifiedTime().to(TimeUnit.SECONDS);
    99 
   100 
   100             if (time1 != time2) {
   101             if (time1 != time2) {
   101                 System.err.format("File time for %s is %s\n", attrs1.fileKey(), attrs1.lastModifiedTime());
   102                 System.err.format("File time for %s is %s\n", attrs1.fileKey(), attrs1.lastModifiedTime());
   102                 System.err.format("File time for %s is %s\n", attrs2.fileKey(), attrs2.lastModifiedTime());
   103                 System.err.format("File time for %s is %s\n", attrs2.fileKey(), attrs2.lastModifiedTime());
   103                 assertTrue(false);
   104                 assertTrue(false);