Search in sources :

Example 11 with ContentImportListener

use of org.apache.sling.jcr.contentloader.ContentImportListener in project sling by apache.

the class DefaultContentCreatorTest method testCreateDateProperty.

@Test
public void testCreateDateProperty() throws RepositoryException, ParseException {
    final String propertyName = "dateProp";
    final String propertyValue = "2012-10-01T09:45:00.000+02:00";
    final ContentImportListener listener = mockery.mock(ContentImportListener.class);
    parentNode = mockery.mock(Node.class);
    prop = mockery.mock(Property.class);
    this.mockery.checking(new Expectations() {

        {
            oneOf(parentNode).hasProperty(with(any(String.class)));
            oneOf(parentNode).setProperty(with(any(String.class)), with(any(Calendar.class)));
            oneOf(parentNode).getProperty(with(any(String.class)));
            will(returnValue(prop));
            oneOf(prop).getPath();
            will(returnValue(""));
            oneOf(listener).onCreate(with(any(String.class)));
        }
    });
    contentCreator.init(ImportOptionsFactory.createImportOptions(false, false, false, false, false), new HashMap<String, ContentReader>(), null, listener);
    contentCreator.prepareParsing(parentNode, null);
    contentCreator.createProperty(propertyName, PropertyType.DATE, propertyValue);
    mockery.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ContentReader(org.apache.sling.jcr.contentloader.ContentReader) ContentImportListener(org.apache.sling.jcr.contentloader.ContentImportListener) Test(org.junit.Test)

Aggregations

ContentImportListener (org.apache.sling.jcr.contentloader.ContentImportListener)11 ContentReader (org.apache.sling.jcr.contentloader.ContentReader)10 Expectations (org.jmock.Expectations)10 Test (org.junit.Test)10 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 RequestParameter (org.apache.sling.api.request.RequestParameter)1 PersistenceException (org.apache.sling.api.resource.PersistenceException)1 ContentImporter (org.apache.sling.jcr.contentloader.ContentImporter)1 ImportOptions (org.apache.sling.jcr.contentloader.ImportOptions)1 Modification (org.apache.sling.servlets.post.Modification)1 VersioningConfiguration (org.apache.sling.servlets.post.VersioningConfiguration)1 RequestProperty (org.apache.sling.servlets.post.impl.helper.RequestProperty)1