Exemplo n.º 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());
  }
  @SuppressWarnings("unchecked")
  public ModAccessTransformer() throws Exception {
    super(ModAccessTransformer.class);
    // We are in the new ClassLoader here, so we need to get the static field from the other
    // ClassLoader.
    ClassLoader classLoader =
        this.getClass()
            .getClassLoader()
            .getClass()
            .getClassLoader(); // Bit odd but it gets the class loader that loaded our current class
                               // loader yay java!
    Class<?> otherClazz = Class.forName(this.getClass().getName(), true, classLoader);
    Field otherField = otherClazz.getDeclaredField("embedded");
    otherField.setAccessible(true);
    embedded = (Map<String, String>) otherField.get(null);

    for (Map.Entry<String, String> e : embedded.entrySet()) {
      int old_count = getModifiers().size();
      processATFile(CharSource.wrap(e.getValue()));
      int added = getModifiers().size() - old_count;
      if (added > 0) {
        FMLRelaunchLog.fine(
            "Loaded %d rules from AccessTransformer mod jar file %s\n", added, e.getKey());
      }
    }
  }
Exemplo n.º 3
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void test_of_invalid_emptyKey() {
   String invalid = "= y\n";
   PropertiesFile.of(CharSource.wrap(invalid));
 }
Exemplo n.º 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]}");
 }
 /** Append the contents of the string to the supplied appendable. */
 public void appendTo(Appendable out, DependencyInfo info, String content) throws IOException {
   appendTo(out, info, CharSource.wrap(content));
 }