@@ -0,0 +1,2286 @@
+/*%0A * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0%0A * (the %22License%22). You may not use this work except in compliance with the License, which is%0A * available at www.apache.org/licenses/LICENSE-2.0%0A *%0A * This software is distributed on an %22AS IS%22 basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,%0A * either express or implied, as more fully set forth in the License.%0A *%0A * See the NOTICE file distributed with this work for information regarding copyright ownership.%0A */%0A%0Apackage alluxio.cli;%0A%0Aimport com.google.common.collect.ImmutableMap;%0Aimport org.apache.commons.cli.CommandLine;%0Aimport org.junit.Assert;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0Aimport org.mockito.Mockito;%0A%0Aimport java.util.Map;%0A%0A/**%0A * Unit tests for %7B@link AbstractShell%7D.%0A */%0Apublic final class AbstractShellTest %7B%0A%0A  private static final String SHELL_NAME = %22TestShell%22;%0A%0A  @Rule%0A  public ExpectedException mExpectedException = ExpectedException.none();%0A%0A  private final class TestShell extends AbstractShell %7B%0A%0A    public TestShell() %7B%0A      super(ImmutableMap.%3CString, String%5B%5D%3Ebuilder().put(%22cmdAlias%22, new String%5B%5D %7B%22cmd%22, %22-O%22%7D)%0A          .build());%0A    %7D%0A%0A    @Override%0A    protected String getShellName() %7B%0A      return SHELL_NAME;%0A    %7D%0A%0A    @Override%0A    protected Map%3CString, Command%3E loadCommands() %7B%0A      final Command cmd = Mockito.mock(Command.class);%0A      try %7B%0A        Mockito.when(cmd.run(Mockito.any(CommandLine.class))).thenReturn(0);%0A        Mockito.when(cmd.parseAndValidateArgs(Mockito.any(String%5B%5D.class)))%0A            .thenReturn(Mockito.mock(CommandLine.class));%0A      %7D catch (Exception e) %7B%0A        throw new RuntimeException(e);%0A      %7D%0A      return ImmutableMap.%3CString, Command%3Ebuilder().put(%22cmd%22, cmd).build();%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void commandExists() throws Exception %7B%0A    TestShell shell = new TestShell();%0A    Assert.assertEquals(0, shell.run(%22cmd%22));%0A  %7D%0A%0A  @Test%0A  public void commandAliasExists() throws Exception %7B%0A    TestShell shell = new TestShell();%0A    Assert.assertEquals(0, shell.run(%22cmdAlias%22));%0A  %7D%0A%0A  @Test%0A  public void commandDoesNotExist() throws Exception %7B%0A    TestShell shell = new TestShell();%0A    Assert.assertTrue(shell.run(%22cmdNotExist%22) %3C 0);%0A  %7D%0A%7D%0A

Add unit tests for AbstractShell