use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class ValueMapTest method testModifiableValueMap.
@Test
public void testModifiableValueMap() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap map = resource1.adaptTo(ModifiableValueMap.class);
assertTrue(map instanceof ValueMap && map instanceof ModifiableValueMap);
assertEquals("value1", map.get("prop1"));
map.put("prop1", "value2");
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class ValueMapTest method testValueMapMap_Readonly.
@Test(expected = UnsupportedOperationException.class)
public void testValueMapMap_Readonly() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap map = resource1.adaptTo(ValueMap.class);
map.put("prop1", "value2");
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class ValueMapTest method testMap.
@SuppressWarnings("unchecked")
@Test
public void testMap() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
Map<String, Object> map = resource1.adaptTo(Map.class);
assertTrue(map instanceof ValueMap && !(map instanceof ModifiableValueMap));
assertEquals("value1", map.get("prop1"));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class ValueMapTest method testValueMap.
@Test
public void testValueMap() throws IOException {
Resource resource1 = resourceResolver.getResource(testRoot.getPath() + "/node1");
ValueMap map = resource1.adaptTo(ValueMap.class);
assertTrue(map instanceof ValueMap && !(map instanceof ModifiableValueMap));
assertEquals("value1", map.get("prop1"));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class ContentBuilderTest method testResourceWithProperties_ObjectArray.
@Test
public void testResourceWithProperties_ObjectArray() {
Resource resource = context.create().resource("/content/test1/resource2", "jcr:title", "Test Title", "stringProp", "value1");
assertNotNull(resource);
assertEquals("resource2", resource.getName());
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("Test Title", props.get("jcr:title", String.class));
assertEquals("value1", props.get("stringProp", String.class));
}
Aggregations