Example #1
0
 public void testLargeDocument() throws Exception {
   File f = new File("yml/testLargeDocument.yml");
   Map m = new HashMap();
   List largeList = new ArrayList();
   for (int i = 0; i < 100000; i++) largeList.add(i);
   m.put("large list", largeList);
   Yaml.dump(m, f);
   Map result = (Map) Yaml.load(f);
   assertEquals(100000, ((List) m.get("large list")).size());
 }
Example #2
0
  /**
   * Load rules from JAML file path
   *
   * @param path path to rules file
   * @return rules
   * @throws FileNotFoundException if file path not exist
   */
  public static Rules loadRules(String path) throws FileNotFoundException {
    File rule;
    if (path == null || path.isEmpty()) path = "rules.yml";

    rule = new File(path);
    return Yaml.loadType(rule, Rules.class);
  }
Example #3
0
  public void testLargeFile() throws Exception {
    File f = new File("yml/testLargeFile.yml");
    Yaml.dumpStream(
        new Iterator() {
          int count = 0;

          public boolean hasNext() {
            return count < 1000000; // about 11M file
          }

          public Object next() {
            return count++;
          }

          public void remove() {}
        },
        f);
    int count = 0;
    for (Object n : Yaml.loadStream(f)) {
      assertEquals(count++, n);
    }
  }
Example #4
0
 /** {@inheritDoc} */
 protected void save() throws DelegateException {
   //        FileOutputStream fout = null;
   try {
     Yaml.dump(folderExt, getFile(), true);
     //            fout = new FileOutputStream(getFile());
     //            yamlConfig.dump(folderExt, fout);
   } catch (IOException ioe) {
     throw new DelegateException("Error saving metadata", ioe);
   }
   //        finally {
   //            if (fout != null) {
   //                try {
   //                    fout.close();
   //                }
   //                catch (IOException ioe) {}
   //            }
   //        }
 }