/*
* 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 6863864
* @summary Unit test for java.nio.file.Files createSymbolicLink,
* readSymbolicLink, and createLink methods
* @library ..
* @build Links
*/
public class Links {
static final boolean isWindows =
if (!okay)
throw new RuntimeException("Assertion failed");
}
/**
* Exercise createSymbolicLink and readLink methods
*/
// Check if sym links are supported
try {
} catch (UnsupportedOperationException x) {
// sym links not supported
return;
} catch (IOException x) {
// probably insufficient privileges to create sym links (Windows)
return;
}
// Test links to various targets
String[] windowsTargets =
{ "foo", "C:\\foo", "\\foo", "\\\\server\\share\\foo" };
try {
} finally {
}
}
// Test links to directory
try {
// link -> "mydir"
// Test access to directory via link
boolean found = false;
found = true;
break;
}
}
}
// Test link2 -> link -> mydir
try {
} finally {
}
// Remove mydir and re-create link2 before re-creating mydir
// (This is a useful test on Windows to ensure that creating a
// sym link to a directory sym link creates the right type of link).
try {
} finally {
}
} finally {
}
}
/**
* Exercise createLink method
*/
try {
try {
} catch (UnsupportedOperationException x) {
return;
} catch (IOException x) {
// probably insufficient privileges (Windows)
return;
}
try {
} finally {
}
} finally {
}
}
try {
// repeat tests on Windows with long path
if (isWindows) {
try {
} catch (IOException x) {
}
if (dirWithLongPath != null) {
}
}
} finally {
}
}
}