Search in sources :

Example 96 with ValueMap

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);
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Date(java.util.Date) Test(org.junit.Test)

Example 97 with ValueMap

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"));
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Example 98 with ValueMap

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));
    }
}
Also used : Node(javax.jcr.Node) ValueMap(org.apache.sling.api.resource.ValueMap)

Example 99 with ValueMap

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);
}
Also used : ContentLoader(org.apache.sling.testing.mock.sling.loader.ContentLoader) ValueMap(org.apache.sling.api.resource.ValueMap) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 100 with ValueMap

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));
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

ValueMap (org.apache.sling.api.resource.ValueMap)278 Resource (org.apache.sling.api.resource.Resource)205 Test (org.junit.Test)160 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)59 HashMap (java.util.HashMap)54 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)44 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)26 Map (java.util.Map)21 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)21 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)20 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)20 Expectations (org.jmock.Expectations)20 ArrayList (java.util.ArrayList)18 PersistenceException (org.apache.sling.api.resource.PersistenceException)17 Calendar (java.util.Calendar)16 Date (java.util.Date)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 NonExistingResource (org.apache.sling.api.resource.NonExistingResource)12 InputStream (java.io.InputStream)11 Node (javax.jcr.Node)11