use of javax.jcr.Value in project jackrabbit by apache.
the class HoldEffectTest method assertEffect.
private void assertEffect(Node targetNode, String childName, String propName, String childName2, String propName2) throws RepositoryException {
Session s = targetNode.getSession();
try {
Node child = targetNode.getNode(childName);
child.remove();
s.save();
fail("Hold present must prevent a child node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.remove();
s.save();
fail("Hold present must prevent a child property from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.setValue("test2");
s.save();
fail("Hold present must prevent the child property from being modified.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
targetNode.addNode(childName2);
s.save();
fail("Hold present must prevent the target node from having new nodes added.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test");
targetNode.setProperty(propName2, v);
s.save();
fail("Hold present must prevent the target node from having new properties set.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
NodeType[] mixins = targetNode.getMixinNodeTypes();
if (mixins.length > 0) {
try {
targetNode.removeMixin(mixins[0].getName());
s.save();
fail("Hold present must prevent the target node from having it's mixin types changed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
}
try {
targetNode.remove();
s.save();
fail("Hold present must prevent the target node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
}
use of javax.jcr.Value in project jackrabbit by apache.
the class HoldEffectTest method setUp.
protected void setUp() throws Exception {
super.setUp();
childN = testRootNode.addNode(nodeName2);
Value v = getJcrValue(superuser, RepositoryStub.PROP_PROP_VALUE1, RepositoryStub.PROP_PROP_TYPE1, "test");
childP = testRootNode.setProperty(propertyName1, v);
superuser.save();
otherS = getHelper().getSuperuserSession();
}
use of javax.jcr.Value in project jackrabbit by apache.
the class QueryObjectModelFactoryTest method testLiteral.
/**
* Test case for {@link QueryObjectModelFactory#literal(Value)}
*/
public void testLiteral() throws RepositoryException {
Value v = superuser.getValueFactory().createValue("test");
Literal literal = qf.literal(v);
assertEquals("Wrong literal value", v.getString(), literal.getLiteralValue().getString());
}
use of javax.jcr.Value in project jackrabbit by apache.
the class RowTest method testGetValues.
public void testGetValues() throws RepositoryException {
Row r = getRow();
Value[] values = r.getValues();
assertEquals("wrong number of columns", 1, values.length);
assertEquals("property value does not match", TEST_VALUE, values[0].getString());
}
use of javax.jcr.Value in project jackrabbit by apache.
the class VersionHistoryTest method testSetProperty.
/**
* Tests if <ul> <li><code>VersionHistory.setProperty(String,
* String[])</code></li> <li><code>VersionHistory.setProperty(String,
* String[], int)</code></li> <li><code>VersionHistory.setProperty(String,
* Value[])</code></li> <li><code>VersionHistory.setProperty(String,
* Value[], int)</code></li> <li><code>VersionHistory.setProperty(String,
* boolean)</code></li> <li><code>VersionHistory.setProperty(String,
* double)</code></li> <li><code>VersionHistory.setProperty(String,
* InputStream)</code></li> <li><code>VersionHistory.setProperty(String,
* String)</code></li> <li><code>VersionHistory.setProperty(String,
* Calendar)</code></li> <li><code>VersionHistory.setProperty(String,
* Node)</code></li> <li><code>VersionHistory.setProperty(String,
* Value)</code></li> <li><code>VersionHistory.setProperty(String,
* long)</code></li> </ul> all throw a {@link javax.jcr.nodetype.ConstraintViolationException}
*/
public void testSetProperty() throws Exception {
// create Value[] object
Value[] vArray = new Value[3];
vArray[0] = superuser.getValueFactory().createValue("abc");
vArray[1] = superuser.getValueFactory().createValue("xyz");
vArray[2] = superuser.getValueFactory().createValue("123");
// create String array
String[] s = { "abc", "xyz", "123" };
try {
vHistory.setProperty(propertyName1, s);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,String[]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, s, PropertyType.STRING);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,String[],int) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, vArray);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,Value[]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, vArray, PropertyType.STRING);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,Value[],int]) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, true);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,boolean) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, 123);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,double) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
byte[] bytes = { 73, 26, 32, -36, 40, -43, -124 };
InputStream inpStream = new ByteArrayInputStream(bytes);
vHistory.setProperty(propertyName1, inpStream);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,InputStream) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, "abc");
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,String) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
Calendar c = new GregorianCalendar(1945, 1, 6, 16, 20, 0);
vHistory.setProperty(propertyName1, c);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,Calendar) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, vHistory);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,Node) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
Value v = superuser.getValueFactory().createValue("abc");
vHistory.setProperty(propertyName1, v);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,Value) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
try {
vHistory.setProperty(propertyName1, -2147483650L);
vHistory.getSession().save();
fail("VersionHistory should be read-only: VersionHistory.setProperty(String,long) did not throw a ConstraintViolationException");
} catch (ConstraintViolationException success) {
}
}
Aggregations