コード例 #1
0
  /**
   * A unit test for <code>normalizedFilename()</code>
   *
   * @exception Exception Description of Exception
   * @since
   */
  public void testNormalizedFilename() throws Exception {
    Object[] test_values = {
      new String[] {".", "__"},
      new String[] {"", ""},
      new String[] {"file://", "file_"},
      // was new String[]{"file://", "file_" + File.separator + "_" + File.separator + "_"},
      new String[] {"/a/b/c", "a" + File.separator + "b" + File.separator + "c"},
      new String[] {"\\a\\b\\c", "a" + File.separator + "b" + File.separator + "c"},
      new String[] {"a/b/c", "a" + File.separator + "b" + File.separator + "c"},
      new String[] {"a\\b\\c", "a" + File.separator + "b" + File.separator + "c"},
      new String[] {"a/b/../c", "a" + File.separator + "c"},
      new String[] {"public/final.xml", "public_" + File.separator + "final_xml"},
      new String[] {"123", "_123"}
    };
    for (int i = 0; i < test_values.length; i++) {
      String tests[] = (String[]) test_values[i];
      String test = tests[0];
      String expected = tests[1];

      String result = IOUtils.normalizedFilename(test);
      String message = "Test " + "'" + test + "'";
      assertEquals(message, expected, result);
    }
  }