use of org.apache.sling.jcr.contentloader.ContentReader in project sling by apache.
the class DefaultContentCreatorTest method setup.
@Before
public void setup() throws Exception {
final SlingRepository repo = RepositoryProvider.instance().getRepository();
session = repo.loginAdministrative(null);
contentCreator = new DefaultContentCreator(null);
contentCreator.init(ImportOptionsFactory.createImportOptions(true, true, true, false, false), new HashMap<String, ContentReader>(), null, null);
parentNode = session.getRootNode().addNode(getClass().getSimpleName()).addNode(uniqueId());
}
use of org.apache.sling.jcr.contentloader.ContentReader in project sling by apache.
the class CreateNodeTest method setup.
@Before
public void setup() throws Exception {
final SlingRepository repo = RepositoryProvider.instance().getRepository();
session = repo.loginAdministrative(null);
contentCreator = new DefaultContentCreator(null);
contentCreator.init(ImportOptionsFactory.createImportOptions(true, true, true, false, false), new HashMap<String, ContentReader>(), null, null);
testRoot = session.getRootNode().addNode(getClass().getSimpleName()).addNode(uniqueId());
}
use of org.apache.sling.jcr.contentloader.ContentReader in project sling by apache.
the class DefaultContentCreatorTest method finishNodeWithSingleProperty.
@Test
public void finishNodeWithSingleProperty() throws RepositoryException, NoSuchFieldException {
final String propName = uniqueId();
final String underTestNodeName = uniqueId();
final ContentImportListener listener = mockery.mock(ContentImportListener.class);
this.mockery.checking(new Expectations() {
{
exactly(2).of(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(propName, PropertyType.REFERENCE, underTestNodeName);
contentCreator.createNode(underTestNodeName, null, null);
Node underTest = parentNode.getNode(underTestNodeName);
underTest.addMixin("mix:referenceable");
contentCreator.finishNode();
assertEquals(underTest.getUUID(), parentNode.getProperty(propName).getString());
mockery.assertIsSatisfied();
}
use of org.apache.sling.jcr.contentloader.ContentReader in project sling by apache.
the class DefaultContentCreatorTest method testCreatePropertyWithNewPropertyType.
@Test
public void testCreatePropertyWithNewPropertyType() throws RepositoryException, ParseException {
final String propertyName = "foo";
final String propertyValue = "bar";
final Integer propertyType = -1;
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).getProperty(propertyName);
will(returnValue(prop));
oneOf(parentNode).setProperty(propertyName, propertyValue, propertyType);
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, propertyValue);
mockery.assertIsSatisfied();
}
use of org.apache.sling.jcr.contentloader.ContentReader 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