use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testEmptyValueArray2.
public void testEmptyValueArray2() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("mvProperty");
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, new QValue[] { rs.getQValueFactory().create(true) });
rs.submit(b);
PropertyId pid = getPropertyId(nid, propName);
b = rs.createBatch(si, pid);
b.setValue(pid, new QValue[0]);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, pid);
assertTrue(pi.isMultiValued());
assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testUseConsumedBatch.
public void testUseConsumedBatch() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, resolver.getQName("any"), rs.getQValueFactory().create(1.34));
rs.submit(b);
try {
b.remove(nid);
rs.submit(b);
fail();
} catch (IllegalStateException e) {
// success
}
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testBinary.
public void testBinary() throws RepositoryException, IOException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("binProp");
Batch b = rs.createBatch(si, nid);
ClassLoader loader = getClass().getClassLoader();
InputStream in = loader.getResourceAsStream("org/apache/jackrabbit/spi/spi2davex/image.bmp");
if (in != null) {
try {
QValue v = rs.getQValueFactory().create(in);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
String str1 = pi.getValues()[0].getString();
pi = getPropertyInfo(nid, propName);
String str2 = pi.getValues()[0].getString();
assertEquals(str1, str2);
} finally {
in.close();
}
}
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class BatchTest method testReorder.
public void testReorder() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("1"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("3"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("2"), NameConstants.NT_UNSTRUCTURED, null);
rs.submit(b);
b = rs.createBatch(si, nid);
b.reorderNodes(nid, getNodeId(testPath + "/3"), null);
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 testSetBinaryValues.
public void testSetBinaryValues() 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[] { 'd', 'e', 'f' }), 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("def", 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("def", vs[1].getString());
assertEquals("ghi", vs[2].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
Aggregations