use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetReferenceValue.
public void testSetReferenceValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
NodeInfo nInfo = rs.getNodeInfo(si, nid);
if (!Arrays.asList(nInfo.getMixins()).contains(NameConstants.MIX_REFERENCEABLE)) {
Batch b = rs.createBatch(si, nid);
b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
rs.submit(b);
}
String ref = rs.getNodeInfo(si, nid).getId().getUniqueID();
Name propName = resolver.getQName("refProp");
QValue v = rs.getQValueFactory().create(ref, PropertyType.REFERENCE);
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.REFERENCE, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.REFERENCE, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetPropertyTwice.
public void testSetPropertyTwice() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("nameProp");
PropertyId pid = getPropertyId(nid, propName);
QValue v = rs.getQValueFactory().create(NameConstants.JCR_AUTOCREATED);
QValue v2 = rs.getQValueFactory().create(NameConstants.JCR_BASEVERSION);
QValue v3 = rs.getQValueFactory().create(NameConstants.JCR_CONTENT);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
b.setValue(pid, v2);
b.setValue(pid, v3);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
assertEquals(1, pi.getValues().length);
assertEquals(v3, pi.getValues()[0]);
assertEquals(PropertyType.NAME, pi.getType());
pi = getPropertyInfo(nid, propName);
assertFalse(pi.isMultiValued());
assertEquals(1, pi.getValues().length);
assertEquals(v3, pi.getValues()[0]);
assertEquals(PropertyType.NAME, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetEmptyBinaryValue.
public void testSetEmptyBinaryValue() 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[0]));
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertFalse(pi.isMultiValued());
InputStream in = pi.getValues()[0].getStream();
assertTrue(in.read() == -1);
assertEquals("", pi.getValues()[0].getString());
assertEquals(PropertyType.BINARY, pi.getType());
pi = getPropertyInfo(nid, propName);
assertFalse(pi.isMultiValued());
in = pi.getValues()[0].getStream();
assertTrue(in.read() == -1);
assertEquals("", pi.getValues()[0].getString());
assertEquals(PropertyType.BINARY, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testMultiValuedProperty.
public void testMultiValuedProperty() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("mvProperty2");
QValue[] vs = new QValue[] { rs.getQValueFactory().create(111), rs.getQValueFactory().create(222), rs.getQValueFactory().create(333) };
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, vs);
rs.submit(b);
PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertTrue(pi.isMultiValued());
assertEquals(Arrays.asList(vs), Arrays.asList(pi.getValues()));
assertEquals(PropertyType.LONG, pi.getType());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetWeakReferenceValue.
public void testSetWeakReferenceValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
NodeInfo nInfo = rs.getNodeInfo(si, nid);
if (!Arrays.asList(nInfo.getMixins()).contains(NameConstants.MIX_REFERENCEABLE)) {
Batch b = rs.createBatch(si, nid);
b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
rs.submit(b);
}
String ref = rs.getNodeInfo(si, nid).getId().getUniqueID();
Name propName = resolver.getQName("weakRefProp");
QValue v = rs.getQValueFactory().create(ref, PropertyType.WEAKREFERENCE);
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.WEAKREFERENCE, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(PropertyType.WEAKREFERENCE, pi.getType());
}
Aggregations