DefaultSlingSimulator implements SlingSimulatorBackend, SlingSimulator { static void loadJcrProperties(final @NotNull Map<String, Object> configMap, final @NotNull Node configNode) throws RepositoryException { final PropertyIterator pi = configNode.getProperties(); while (pi.hasNext()) { final Property p = pi.nextProperty(); final String name = p.getName(); if (name.contains(":")) { continue; } if (p.getDefinition().isMultiple()) { Object[] data = null; final Value[] values = p.getValues(); int i = 0; for (Value v : values) { Object o = convertJcrValue(v); if (o != null) { if (i == 0) { data = (Object[]) Array.newInstance(o.getClass(), values.length); } data[i++] = o; } } if (data == null) { data = new String[0]; } configMap.put(name, data); } else { final Object o = convertJcrValue(p.getValue()); if (o != null) { configMap.put(name, o); } } } }  static SlingSimulatorBackend instance(); @Override void startedScan(); @Override void setSession(final Session session); @Override void setPackageManager(final JcrPackageManager packageManager); @Override void setErrorListener(final ErrorListener errorListener); @Override @Nullable SlingInstallable dequeueInstallable(); @SuppressWarnings("unchecked") @Override @NotNull Fun.ThrowingSupplier<ResourceType> open(@NotNull final SlingOpenable<ResourceType> installable); @NotNull JcrPackage openEmbeddedPackage(@NotNull final EmbeddedPackageInstallable installable); @Override @Nullable SlingInstallable addInstallableNode(final @NotNull PackageId parentPackageId,
                                                         final @NotNull Node node);  }
@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: .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())); } } }