/*
 * Licensed to the University of California, Berkeley under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package tachyon.shell.command;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;

import tachyon.TachyonURI;
import tachyon.client.FileSystemTestUtils;
import tachyon.client.WriteType;
import tachyon.exception.TachyonException;
import tachyon.shell.AbstractTfsShellTest;

/**
 * Tests for chgrp command.
 */
public class ChgrpCommandTest extends AbstractTfsShellTest {
  @Test
  public void chgrpTest() throws IOException, TachyonException {
    clearLoginUser();
    FileSystemTestUtils.createByteFile(mFileSystem, "/testFile", WriteType.MUST_CACHE, 10);
    mFsShell.run("chgrp", "group1", "/testFile");
    String group = mFileSystem.getStatus(new TachyonURI("/testFile")).getGroupName();
    Assert.assertEquals("group1", group);
    mFsShell.run("chgrp", "group2", "/testFile");
    group = mFileSystem.getStatus(new TachyonURI("/testFile")).getGroupName();
    Assert.assertEquals("group2", group);
  }
}

@@ -1722,11 +1722,884 @@
 up);%0A  %7D
+%0A%0A  @Test%0A  public void chgrpRecursiveTest() throws IOException, TachyonException %7B%0A    clearLoginUser();%0A    FileSystemTestUtils.createByteFile(mFileSystem, %22/testDir/testFile%22, WriteType.MUST_CACHE, 10);%0A    // %22chgrp -R group1 /testDir%22 should apply to child file%0A    mFsShell.run(%22chgrp%22, %22-R%22, %22group1%22, %22/testDir%22);%0A    String group = mFileSystem.getStatus(new TachyonURI(%22/testDir/testFile%22)).getGroupName();%0A    Assert.assertEquals(%22group1%22, group);%0A    mFsShell.run(%22chgrp%22, %22-R%22, %22group2%22, %22/testDir%22);%0A    group = mFileSystem.getStatus(new TachyonURI(%22/testDir/testFile%22)).getGroupName();%0A    Assert.assertEquals(%22group2%22, group);%0A    // Also test %22chgrp group3 /testDir -R%22%0A    mFsShell.run(%22chgrp%22, %22group3%22, %22/testDir%22, %22-R%22);%0A    group = mFileSystem.getStatus(new TachyonURI(%22/testDir/testFile%22)).getGroupName();%0A    Assert.assertEquals(%22group3%22, group);%0A  %7D
 %0A%7D%0A

Add unit test for chgrp -R.