public void testGetAttributesForThisTestClass() throws IOException {
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
      System.out.println("WARNING: Unsupported OS, skipping test");
      return;
    }

    URL resource =
        Thread.currentThread()
            .getContextClassLoader()
            .getResource(getClass().getName().replace('.', '/') + ".class");

    if (resource == null) {
      throw new IllegalStateException(
          "SOMETHING IS VERY WRONG. CANNOT FIND THIS TEST CLASS IN THE CLASSLOADER.");
    }

    File f = new File(resource.getPath().replaceAll("%20", " "));

    Map attrs =
        PlexusIoResourceAttributeUtils.getFileAttributesByPath(
            f, new ConsoleLogger(Logger.LEVEL_INFO, "test"), Logger.LEVEL_DEBUG);

    PlexusIoResourceAttributes fileAttrs =
        (PlexusIoResourceAttributes) attrs.get(f.getAbsolutePath());

    System.out.println("Got attributes for: " + f.getAbsolutePath() + fileAttrs);

    assertNotNull(fileAttrs);
    assertTrue(fileAttrs.isOwnerReadable());
    assertEquals(System.getProperty("user.name"), fileAttrs.getUserName());
  }
  public void testMergeAttributesWithNullOverrideGroup() {
    char[] mode = new char[10];
    Arrays.fill(mode, (char) 0);

    FileAttributes override = new FileAttributes(1001, "myUser", -1, null, mode);
    FileAttributes defaults = new FileAttributes(1000, "defaultUser", 1000, "defaultGroup", mode);

    PlexusIoResourceAttributes attributes =
        PlexusIoResourceAttributeUtils.mergeAttributes(override, null, defaults);

    assertEquals(new Integer(1000), attributes.getGroupId());
    assertEquals(new Integer(1001), attributes.getUserId());
  }
  public void testFolderJava7() throws IOException, CommandLineException {

    if (Os.isFamily(Os.FAMILY_WINDOWS) || Os.isFamily(Os.FAMILY_WIN9X)) {
      return; // Nothing to do here.
    }

    URL resource =
        Thread.currentThread()
            .getContextClassLoader()
            .getResource(getClass().getName().replace('.', '/') + ".class");

    if (resource == null) {
      throw new IllegalStateException(
          "SOMETHING IS VERY WRONG. CANNOT FIND THIS TEST CLASS IN THE CLASSLOADER.");
    }

    File f = new File(resource.getPath().replaceAll("%20", " "));
    final File aDir = f.getParentFile().getParentFile().getParentFile();

    Commandline commandLine = new Commandline("chmod");
    commandLine.addArguments(new String[] {"763", f.getAbsolutePath()});

    CommandLineUtils.executeCommandLine(commandLine, null, null);
    Map attrs =
        PlexusIoResourceAttributeUtils.getFileAttributesByPath(
            aDir, new ConsoleLogger(Logger.LEVEL_INFO, "test"), Logger.LEVEL_DEBUG);

    PlexusIoResourceAttributes fileAttrs =
        (PlexusIoResourceAttributes) attrs.get(f.getAbsolutePath());

    assertTrue(fileAttrs.isGroupReadable());
    assertTrue(fileAttrs.isGroupWritable());
    assertFalse(fileAttrs.isGroupExecutable());

    assertTrue(fileAttrs.isOwnerExecutable());
    assertTrue(fileAttrs.isOwnerReadable());
    assertTrue(fileAttrs.isOwnerWritable());

    assertTrue(fileAttrs.isWorldExecutable());
    assertFalse(fileAttrs.isWorldReadable());
    assertTrue(fileAttrs.isWorldWritable());

    assertNotNull(fileAttrs);
  }