@Test
public void testLoadJcrProperties() throws Exception {

    final Map<String, Object> props = new HashMap<>();
    OakpalPlan.fromJson(key(keys().repoInits(), arr()
            .val("register nodetypes")
            .val("<<===")
            .val("<'sling'='http://sling.apache.org/jcr/sling/1.0'>")
            .val("[sling:OsgiConfig] > nt:unstructured, nt:hierarchyNode")
            .val("===>>")
            .val("create path (nt:folder) /apps/config/Test(sling:OsgiConfig)")
            .val("set properties on /apps/config/Test")
            .val("  set sling:ResourceType{String} to /x/y/z")
            .val("  set foo{String} to bar")
            .val("  set foos to bar, bar, bar")
            .val("  set ones{Long} to 1, 1, 1")
            .val("end")
    ).get()).toOakMachineBuilder(null, getClass().getClassLoader())
            .build().adminInitAndInspect(session -> {
        Node testNode = session.getNode("/apps/config/Test");
        testNode.setProperty("nothing", new String[0]);
        session.save();
        DefaultSlingSimulator.loadJcrProperties(props, testNode);
    });
    final Map<String, Object> expectProps = new HashMap<>();
    expectProps.put("foo", "bar");
    expectProps.put("foos", Stream.of("bar", "bar", "bar").toArray(String[]::new));
    expectProps.put("ones", Stream.of(1L, 1L, 1L).toArray(Long[]::new));
    expectProps.put("nothing", new String[0]);
    assertEquals("expect same keys", expectProps.keySet(), props.keySet());
    for (Map.Entry<String, Object> entry : expectProps.entrySet()) {
        Object expectValue = entry.getValue();
        if (expectValue.getClass().isArray()) {
            assertArrayEquals("expect equal array for key " + entry.getKey(), (Object[]) expectValue,
                    (Object[]) props.get(entry.getKey()));
        } else {
            assertEquals("expect equal value for key " + entry.getKey(), expectValue,
                    props.get(entry.getKey()));
        }
    }
}