public void testSimpleCRUD()

in src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java [83:119]


    public void testSimpleCRUD() throws Exception {

        // Create a child resource of testRoot, with title and text properties
        final Props props = new Props("title", "hello", "text", "world");
        final String fullPath = resolver.create(testRoot, "child_" + System.currentTimeMillis(), props)
                .getPath();
        resolver.commit();

        {
            // Retrieve and check child resource
            final Resource r = resolver.getResource(fullPath);
            assertNotNull("Expecting Resource at " + fullPath, r);
            final ModifiableValueMap m = r.adaptTo(ModifiableValueMap.class);
            assertValueMap(m, "title", "hello", "text", "world");

            // Update child resource
            m.put("more", "fun");
            m.put("title", "changed");
            resolver.commit();
        }

        {
            // Retrieve and check updated resource
            final Resource r = resolver.getResource(fullPath);
            assertNotNull("Expecting modified Resource at " + fullPath, r);
            assertValueMap(r.adaptTo(ValueMap.class), "title", "changed", "more", "fun", "text", "world");
        }

        {
            // Delete test resource and check that it's gone
            final Resource r = resolver.getResource(fullPath);
            assertNotNull("Expecting non-null resource to delete, at " + fullPath, r);
            resolver.delete(r);
            resolver.commit();
            assertNull("Expecting " + fullPath + " to be deleted", resolver.getResource(fullPath));
        }
    }