petersomogyi commented on code in PR #107:
URL: 
https://github.com/apache/hbase-operator-tools/pull/107#discussion_r901785940


##########
hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java:
##########
@@ -108,17 +112,261 @@ public void testVersionOption() throws IOException {
     properties.load(inputStream);
     String expectedVersionOutput = properties.getProperty("version");
     // Get hbck version option output.
-    String actualVersionOutput = retrieveOptionOutput("-v").trim();
+    String actualVersionOutput = retrieveOptionOutput(new 
String[]{"-v"}).trim();
     assertEquals(expectedVersionOutput, actualVersionOutput);
   }
 
-  private String retrieveOptionOutput(String option) throws IOException {
+  @Test
+  public void testReplicationNoOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);

Review Comment:
   nit: Using String::contains might be easier to read than indexOf.



##########
hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKCommandLineParsing.java:
##########
@@ -108,17 +112,261 @@ public void testVersionOption() throws IOException {
     properties.load(inputStream);
     String expectedVersionOutput = properties.getProperty("version");
     // Get hbck version option output.
-    String actualVersionOutput = retrieveOptionOutput("-v").trim();
+    String actualVersionOutput = retrieveOptionOutput(new 
String[]{"-v"}).trim();
     assertEquals(expectedVersionOutput, actualVersionOutput);
   }
 
-  private String retrieveOptionOutput(String option) throws IOException {
+  @Test
+  public void testReplicationNoOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+  }
+
+  @Test
+  public void testReplicationFixShortOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication",  "-f"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+  }
+
+  @Test
+  public void testReplicationFixShortOptionTable() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication",  "-f", 
"table"});
+    assertTrue(
+      output.indexOf("ERROR: No replication barrier(s) on table: table\n") >= 
0);
+    assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+  }
+
+  @Test
+  public void testReplicationFixShortOptionInputFile() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "-f", "-i", 
input.getPath() });
+      assertTrue(
+        output.indexOf("ERROR: No replication barrier(s) on table: table\n") 
>= 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -i") < 0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testReplicationFixLongOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication",  
"--fix"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+  }
+
+  @Test
+  public void testReplicationFixLongOptionTable() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"replication",  "--fix", 
"table"});
+    assertTrue(
+      output.indexOf("ERROR: No replication barrier(s) on table: table\n") >= 
0);
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+  }
+
+  @Test
+  public void testReplicationFixLongOptionInputFile() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "--fix", "-i", 
input.getPath() });
+      assertTrue(
+        output.indexOf("ERROR: No replication barrier(s) on table: table\n") 
>= 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -i") < 0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testReplicationFixShortOptionInputFileLong() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "-f", 
"--inputFiles", input.getPath() });
+      assertTrue(
+        output.indexOf("ERROR: No replication barrier(s) on table: table\n") 
>= 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --inputFiles") < 
0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testReplicationFixLongOptionInputFileLong() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "--fix", 
"--inputFiles",
+          input.getPath() });
+      assertTrue(
+        output.indexOf("ERROR: No replication barrier(s) on table: table\n") 
>= 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --inoutFiles") < 
0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testReplicationInputFileLong() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "--inputFiles", 
input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --inputFiles") < 
0);
+
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testReplicationInputFile() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "replication", "-i", 
input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -i") < 0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  private File createInputFile() throws Exception {
+    File f = new File("input");
+    try(BufferedWriter writer = new BufferedWriter(
+      new OutputStreamWriter(new FileOutputStream(f)))) {
+      writer.write("table");
+      writer.flush();
+    }
+    return f;
+  }
+
+  @Test
+  public void testFilesystemFixShortOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"filesystem",  "-f"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+  }
+
+  @Test
+  public void testFilesystemFixShortOptionTable() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"filesystem",  "-f", 
"table"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+  }
+
+  @Test
+  public void testFilesystemFixShortOptionInputFile() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "filesystem", "-f", "-i", 
input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -i") < 0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testFilesystemFixLongOption() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"filesystem",  "--fix"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+  }
+
+  @Test
+  public void testFilesystemFixLongOptionTable() throws IOException {
+    String output = retrieveOptionOutput(new String[]{"filesystem",  "--fix", 
"table"});
+    assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+  }
+
+  @Test
+  public void testFilesystemFixLongOptionInputFile() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "filesystem", "--fix", "-i", 
input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -i") < 0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testFilesystemFixShortOptionInputFileLong() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "filesystem", "-f", 
"--inputFiles", input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: -f") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --inputFiles") < 
0);
+    } finally {
+      input.delete();
+    }
+  }
+
+  @Test
+  public void testFilesystemFixLongOptionInputFileLong() throws Exception {
+    File input = null;
+    try {
+      input = createInputFile();
+      String output =
+        retrieveOptionOutput(new String[] { "filesystem", "--fix", 
"--inputFiles",
+          input.getPath() });
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --fix") < 0);
+      assertTrue(output.indexOf("ERROR: Unrecognized option: --inoutFiles") < 
0);

Review Comment:
   Typo in --inoutFiles



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to