use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testSetBinaryValue.
public void testSetBinaryValue() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binProp");
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals("abc", pi.getValues()[0].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
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());
}
Aggregations