return testRoot;
}
@Test
public void testGetResourcesAndValues() throws IOException, RepositoryException {
Resource resource1 = resourceResolver.getResource(getTestRootNode().getPath() + "/node1");
assertNotNull(resource1);
assertEquals("node1", resource1.getName());
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(STRING_VALUE, props.get("stringProp", String.class));
assertArrayEquals(STRING_ARRAY_VALUE, props.get("stringArrayProp", String[].class));
assertEquals((Integer) INTEGER_VALUE, props.get("integerProp", Integer.class));
assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 0.0001);
assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", Calendar.class).getTime());
Resource binaryPropResource = resource1.getChild("binaryProp");
InputStream is = binaryPropResource.adaptTo(InputStream.class);
byte[] dataFromResource = IOUtils.toByteArray(is);
is.close();
assertArrayEquals(BINARY_VALUE, dataFromResource);
// read second time to ensure not the original input stream was returned
InputStream is2 = binaryPropResource.adaptTo(InputStream.class);
byte[] dataFromResource2 = IOUtils.toByteArray(is2);
is2.close();
assertArrayEquals(BINARY_VALUE, dataFromResource2);
List<Resource> children = ImmutableList.copyOf(resource1.listChildren());