/*
* 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.attribute.PosixFileAttributeView
* @library ../..
*/
/**
* Unit test for PosixFileAttributeView, passing silently if this attribute
* view is not available.
*/
public class Basic {
/**
* Use view to update permission to the given mode and check that the
* permissions have been updated.
*/
// change permissions and re-read them.
throw new RuntimeException("Actual permissions: " +
}
// repeat test using setAttribute/getAttribute
throw new RuntimeException("Actual permissions: " +
}
}
/**
* Check that the actual permissions of a file match or make it more
* secure than requested
*/
{
throw new RuntimeException("Actual permissions: " +
" - file is less secure than requested");
}
}
}
/**
* Create file with given mode and check that the file is created with a
* mode that is not less secure
*/
throws IOException
{
try {
.permissions());
} finally {
}
try {
.permissions());
} finally {
}
}
/**
* Test the setPermissions/permissions methods.
*/
throws IOException
{
// create file and test updating and reading its permissions
try {
// get initial permissions so that we can restore them later
.permissions();
// test various modes
try {
} finally {
}
} finally {
}
// create link (to file that doesn't exist) and test reading of
// permissions
try {
PosixFileAttributeView.class,
.readAttributes();
if (!attrs.isSymbolicLink()) {
throw new RuntimeException("not a link");
}
} finally {
}
}
}
/**
* Test creating a file and directory with initial permissios
*/
throws IOException
{
}
/**
* methods to avoid configuration.
*/
throws IOException
{
try {
// repeat test using set/getAttribute
} finally {
}
}
/**
* Test the lookupPrincipalByName/lookupPrincipalByGroupName methods
*/
throws IOException
{
// lookup owner and check it matches file's owner
try {
if (owner instanceof GroupPrincipal)
throw new RuntimeException("owner is a group?");
throw new RuntimeException("owner different from file owner");
} catch (UserPrincipalNotFoundException x) {
}
// lookup group and check it matches file's group-owner
try {
throw new RuntimeException("group different from file group-owner");
} catch (UserPrincipalNotFoundException x) {
}
// test that UserPrincipalNotFoundException is thrown
try {
} catch (UserPrincipalNotFoundException x) {
}
try {
} catch (UserPrincipalNotFoundException x) {
}
}
/**
* Test various exceptions are thrown as expected
*/
@SuppressWarnings("unchecked")
throws IOException
{
// NullPointerException
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
try {
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
// ClassCastException
try {
throw new RuntimeException("ClassCastException not thrown");
} catch (ClassCastException x) {
}
}
try {
return;
}
} finally {
}
}
}