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();
}
Aggregations