Yamls { @SuppressWarnings("unchecked") public static Iterable<Object> parseAll(String yaml) { Iterable<Object> result = newYaml().loadAll(yaml); return getAs(result, List.class); }  @SuppressWarnings({ "unchecked", "rawtypes" }) static T getAs(Object x, Class<T> type); @Beta static Object getAt(String yaml, List<String> path); @Beta @SuppressWarnings("unchecked") static Object getAtPreParsed(Object current, List<String> path); @SuppressWarnings("rawtypes") static void dump(int depth, Object r); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(String yaml); @SuppressWarnings("unchecked") static Iterable<Object> parseAll(Reader yaml); static Object removeMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static Object getMultinameAttribute(Map<String,Object> obj, String ...equivalentNames); static YamlExtract getTextOfYamlAtPath(String yaml, Object ...path);  }
@Test public void testSafeYaml() throws Exception { assertFalse(BrooklynSystemProperties.YAML_TYPE_INSTANTIATION.isEnabled(), "Set property to false (or do not set at all): " + BrooklynSystemProperties.YAML_TYPE_INSTANTIATION.getPropertyName()); try { Yamls.parseAll("!!java.util.Date\n" + "date: 25\n" + "month: 12\n" + "year: 2016"); Asserts.shouldHaveFailedPreviously("Expected exception: " + ConstructorException.class.getCanonicalName()); } catch(ConstructorException e) { Asserts.expectedFailureContains(e, "could not determine a constructor"); } }