use of org.apache.jackrabbit.spi.Batch in project jackrabbit by apache.
the class BatchTest method testReorder1.
public void testReorder1() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("2"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("3"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("1"), NameConstants.NT_UNSTRUCTURED, null);
rs.submit(b);
b = rs.createBatch(si, nid);
b.reorderNodes(nid, getNodeId(testPath + "/1"), getNodeId(testPath + "/2"));
rs.submit(b);
Iterator<ChildInfo> it = rs.getChildInfos(si, nid);
int i = 1;
while (it.hasNext()) {
ChildInfo ci = it.next();
assertEquals(i, Integer.parseInt(ci.getName().getLocalName()));
i++;
}
}
use of org.apache.jackrabbit.spi.Batch in project jackrabbit by apache.
the class BatchTest method testSetEmptyBinaryValues.
public void testSetEmptyBinaryValues() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binPropMV");
Batch b = rs.createBatch(si, nid);
QValue[] vs = new QValue[] { rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[0]) };
b.addProperty(nid, propName, vs);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertTrue(pi.isMultiValued());
vs = pi.getValues();
assertEquals("", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
pi = getPropertyInfo(nid, propName);
vs = pi.getValues();
assertEquals("", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
use of org.apache.jackrabbit.spi.Batch in project jackrabbit by apache.
the class BatchTest method testMove.
public void testMove() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("anyNode"), NameConstants.NT_UNSTRUCTURED, null);
rs.submit(b);
NodeId id = getNodeId(testPath + "/anyNode");
b = rs.createBatch(si, nid);
b.move(id, nid, resolver.getQName("moved"));
rs.submit(b);
try {
rs.getItemInfos(si, id);
fail();
} catch (RepositoryException e) {
// ok
}
rs.getNodeInfo(si, getNodeId(testPath + "/moved"));
}
use of org.apache.jackrabbit.spi.Batch in project jackrabbit by apache.
the class BatchTest method testSetMixedBinaryValues.
public void testSetMixedBinaryValues() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binPropMV");
Batch b = rs.createBatch(si, nid);
QValue[] vs = new QValue[] { rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }), rs.getQValueFactory().create(new byte[0]), rs.getQValueFactory().create(new byte[] { 'g', 'h', 'i' }) };
b.addProperty(nid, propName, vs);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertTrue(pi.isMultiValued());
vs = pi.getValues();
assertEquals("abc", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("ghi", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
pi = getPropertyInfo(nid, propName);
vs = pi.getValues();
assertEquals("abc", vs[0].getString());
assertEquals("", vs[1].getString());
assertEquals("ghi", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
use of org.apache.jackrabbit.spi.Batch in project jackrabbit by apache.
the class BatchTest method testAddNode.
public void testAddNode() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("aNode"), NameConstants.NT_UNSTRUCTURED, null);
b.addProperty(nid, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
b.addProperty(nid, resolver.getQName("aName"), new QValue[] { rs.getQValueFactory().create(NameConstants.JCR_ENCODING), rs.getQValueFactory().create(NameConstants.JCR_DATA) });
b.addProperty(nid, resolver.getQName("aBinary"), rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
rs.submit(b);
NodeId id = rs.getIdFactory().createNodeId(nid, resolver.getQPath("aNode"));
Iterator<? extends ItemInfo> it = rs.getItemInfos(si, id);
while (it.hasNext()) {
ItemInfo info = it.next();
if (info.denotesNode()) {
NodeInfo nInfo = (NodeInfo) info;
assertEquals(NameConstants.NT_UNSTRUCTURED, nInfo.getNodetype());
Iterator<ChildInfo> childIt = nInfo.getChildInfos();
assertTrue(childIt == null || !childIt.hasNext());
assertEquals(id, nInfo.getId());
}
}
b = rs.createBatch(si, nid);
b.remove(id);
rs.submit(b);
}
Aggregations