use of org.apache.jackrabbit.spi.NodeId 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.NodeId 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.NodeId in project jackrabbit by apache.
the class BatchTest method testSetPathValue.
public void testSetPathValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("pathProp");
QValue v = rs.getQValueFactory().create(resolver.getQPath(testPath));
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.PATH, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v.getPath(), pi.getValues()[0].getPath());
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.PATH, pi.getType());
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testSetBooleanValue.
public void testSetBooleanValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("booleanProp");
QValue v = rs.getQValueFactory().create(false);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertFalse(pi.getValues()[0].getBoolean());
assertEquals(PropertyType.BOOLEAN, pi.getType());
pi = getPropertyInfo(nid, propName);
assertFalse(pi.getValues()[0].getBoolean());
assertEquals(PropertyType.BOOLEAN, pi.getType());
}
use of org.apache.jackrabbit.spi.NodeId 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