use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractNoSqlResourceProviderTest method testCalendarPropertyToDate.
@Test
public void testCalendarPropertyToDate() throws IOException {
Resource resource1 = context.resourceResolver().getResource(testRoot().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
Date dateValue = props.get("calendarProp", Date.class);
assertNotNull(dateValue);
assertEquals(CALENDAR_VALUE.getTime(), dateValue);
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractContentLoaderJsonTest method testUTF8Chars.
@Test
public void testUTF8Chars() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content");
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("äöü߀", props.get("utf8Property"));
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractContentLoaderJsonTest method assertPrimaryNodeType.
private void assertPrimaryNodeType(final Resource resource, final String nodeType) throws RepositoryException {
Node node = resource.adaptTo(Node.class);
if (node != null) {
assertEquals(nodeType, node.getPrimaryNodeType().getName());
} else {
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals(nodeType, props.get(JcrConstants.JCR_PRIMARYTYPE));
}
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractJcrNamespaceTest method testSling4362.
@Test
public void testSling4362() throws RepositoryException {
BundleContext bundleContext = MockOsgi.newBundleContext();
ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType(), bundleContext);
ContentLoader contentLoader = new ContentLoader(resolver);
contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("fooType", props.get("sling:resourceType"));
assertEquals("fooType", resource.getResourceType());
MockOsgi.shutdown(bundleContext);
}
use of org.apache.sling.api.resource.ValueMap in project sling by apache.
the class AbstractSlingCrudResourceResolverTest method testSimpleProperties.
@Test
public void testSimpleProperties() throws IOException {
Resource resource1 = context.resourceResolver().getResource(getTestRootResource().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((Long) LONG_VALUE, props.get("longProp", Long.class));
assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 0.0001);
assertEquals(BIGDECIMAL_VALUE, props.get("bigDecimalProp", BigDecimal.class));
assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
}
Aggregations