use of org.apache.jackrabbit.spi.PropertyInfo 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.PropertyInfo 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.PropertyInfo 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());
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetStringValue.
public void testSetStringValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("stringProp");
QValueFactory vf = rs.getQValueFactory();
List<String> l = new ArrayList<String>();
l.add("String value containing \"double quotes\" and \'single\' and \"undeterminated quote.");
l.add("String value \ncontaining \n\rline \r\nseparators and \t tab.");
l.add("String value containing \r\n\r\r\n\r\n multiple \r\n\r\n line separators in sequence.");
l.add("String value containing >diff -char +act ^ters.");
l.add("String value containing \n>line sep \r+and \r\n-diff\n\r^chars.");
l.add("String value containing سش unicode chars.");
for (String val : l) {
QValue v = vf.create(val, PropertyType.STRING);
Batch b = rs.createBatch(si, nid);
b.addProperty(nid, propName, v);
rs.submit(b);
PropertyInfo pi = getPropertyInfo(nid, propName);
assertEquals(v, pi.getValues()[0]);
assertEquals(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.STRING, pi.getType());
pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
assertEquals(v, pi.getValues()[0]);
assertEquals(v.getString(), pi.getValues()[0].getString());
assertEquals(PropertyType.STRING, pi.getType());
}
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class BatchTest method testSetNameValue.
public void testSetNameValue() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Name propName = resolver.getQName("nameProp");
QValue[] vs = new QValue[] { rs.getQValueFactory().create(NameConstants.JCR_BASEVERSION), rs.getQValueFactory().create(NameConstants.JCR_DEFAULTPRIMARYTYPE), rs.getQValueFactory().create(NameConstants.MIX_LOCKABLE), rs.getQValueFactory().create(NameConstants.JCR_PRIMARYTYPE), rs.getQValueFactory().create(NameConstants.NT_VERSION) };
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.NAME, pi.getType());
pi = getPropertyInfo(nid, propName);
assertEquals(vs[0].getName(), pi.getValues()[0].getName());
assertEquals(Arrays.asList(vs), Arrays.asList(pi.getValues()));
assertEquals(PropertyType.NAME, pi.getType());
}
Aggregations