示例#1
0
  // -------------------------------------------------------------------------
  public void test_equalsHashCode() {
    PropertiesFile a1 = PropertiesFile.of(CharSource.wrap(FILE1));
    PropertiesFile a2 = PropertiesFile.of(CharSource.wrap(FILE1));
    PropertiesFile b = PropertiesFile.of(CharSource.wrap(FILE2));

    assertEquals(a1.equals(a1), true);
    assertEquals(a1.equals(a2), true);
    assertEquals(a1.equals(b), false);
    assertEquals(a1.equals(null), false);
    assertEquals(a1.equals(""), false);
    assertEquals(a1.hashCode(), a2.hashCode());
  }
示例#2
0
 public void test_of_ioException() {
   assertThrows(
       () ->
           PropertiesFile.of(
               Files.asCharSource(new File("src/test/resources"), StandardCharsets.UTF_8)),
       UncheckedIOException.class);
 }
示例#3
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void test_of_invalid_emptyKey() {
   String invalid = "= y\n";
   PropertiesFile.of(CharSource.wrap(invalid));
 }
示例#4
0
 public void test_of_list() {
   PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE2));
   Multimap<String, String> keyValues = ImmutableListMultimap.of("a", "x", "a", "y");
   assertEquals(test.getProperties(), PropertySet.of(keyValues));
   assertEquals(test.toString(), "{a=[x, y]}");
 }