@Test
public void testParse() {

  String[] invalidFlavors = new String[] {
          null,
          "",
          "/",
          "valid/",
          "/valid",
          " \r \n \t /",
          " \r \n \t /valid",
          "/ \r \n \t ",
          "valid/ \r \n \t ",
          " \r \n \t / \r \n \t ",
          "too/many/slashes",
          "/ \r \n \t too \r / \r many   / \t \r \n slashes \t"
  };
  for (String invalid : invalidFlavors) {
    try {
      MediaPackageElementFlavor.parseFlavor(invalid);
    } catch (Throwable t) {
      assertEquals(format("Catched unexpected exception. The message was: %s", t.getMessage()),
              IllegalArgumentException.class, t.getClass());
      continue;
    }
    fail(format("Invalid flavor should fail but was parsed without errors: \"%s\"", invalid));
  }
}