You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2005/04/21 11:41:43 UTC
svn commit: r164016 [2/2] - in /incubator/jackrabbit/trunk:
applications/test/repository/nodetypes/ src/test/org/apache/jackrabbit/test/
src/test/org/apache/jackrabbit/test/api/
src/test/org/apache/jackrabbit/test/api/nodetype/
src/test/org/apache/jackrabbit/test/api/version/
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java Thu Apr 21 02:41:39 2005
@@ -164,7 +164,7 @@
Value anyStringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
// note: for assertFalse, use first value of requested type to check
// if not only first value is checked
- Value anyStringValues[] = {dateValue, anyStringValue};
+ Value anyStringValues[] = new Value[] {dateValue, anyStringValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Date and values are of type StringValue " +
"not in date format",
@@ -172,19 +172,19 @@
StringValue dateStringValue =
new StringValue(NodeTypeUtil.getValueOfType(PropertyType.DATE).getString());
- Value dateStringValues[] = {dateStringValue};
+ Value dateStringValues[] = new Value[] {dateStringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Date and values are of type StringValue " +
"in date format",
nodeType.canSetProperty(propDef.getName(), dateStringValues));
- Value dateValues[] = {dateValue};
+ Value dateValues[] = new Value[] {dateValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Date and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value anyBinaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
- Value anyBinaryValues[] = {dateValue, anyBinaryValue};
+ Value anyBinaryValues[] = new Value[] {dateValue, anyBinaryValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Date and values are of type BinaryValue" +
"in UTF-8 but not in date format",
@@ -192,38 +192,38 @@
BinaryValue dateBinaryValue =
new BinaryValue(NodeTypeUtil.getValueOfType(PropertyType.DATE).getString());
- Value dateBinaryValues[] = {dateBinaryValue};
+ Value dateBinaryValues[] = new Value[] {dateBinaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Date and values are of type BinaryValue" +
"in UTF-8 and in date format",
nodeType.canSetProperty(propDef.getName(), dateBinaryValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {doubleValue};
+ Value doubleValues[] = new Value[] {doubleValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Date and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {longValue};
+ Value longValues[] = new Value[] {longValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Date and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {dateValue, booleanValue};
+ Value booleanValues[] = new Value[] {dateValue, booleanValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Date and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {dateValue, nameValue};
+ Value nameValues[] = new Value[] {dateValue, nameValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Date and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
- Value pathValues[] = {dateValue, pathValue};
+ Value pathValues[] = new Value[] {dateValue, pathValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Date and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -244,9 +244,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No date property def with " +
"testable value constraints has been found");
}
@@ -273,15 +272,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple date property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java Thu Apr 21 02:41:39 2005
@@ -162,7 +162,7 @@
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
Value anyStringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
- Value anyStringValues[] = {doubleValue, anyStringValue};
+ Value anyStringValues[] = new Value[] {doubleValue, anyStringValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Double and values are of type StringValue " +
"that are not convertible to DoubleValues",
@@ -170,14 +170,14 @@
Value doubleStringValue =
new StringValue(NodeTypeUtil.getValueOfType(PropertyType.DOUBLE).getString());
- Value doubleStringValues[] = {doubleStringValue};
+ Value doubleStringValues[] = new Value[] {doubleStringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Double and values are of type StringValue " +
"that are convertible to DoubleValues",
nodeType.canSetProperty(propDef.getName(), doubleStringValues));
Value anyBinaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
- Value anyBinaryValues[] = {doubleValue, anyBinaryValue};
+ Value anyBinaryValues[] = new Value[] {doubleValue, anyBinaryValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Double and values are of type BinaryValue " +
"that are not convertible to DoubleValues",
@@ -185,43 +185,43 @@
Value doubleBinaryValue =
new BinaryValue(NodeTypeUtil.getValueOfType(PropertyType.DOUBLE).getString());
- Value doubleBinaryValues[] = {doubleBinaryValue};
+ Value doubleBinaryValues[] = new Value[] {doubleBinaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Double and values are of type BinaryValue " +
"that are convertible to DoubleValues",
nodeType.canSetProperty(propDef.getName(), doubleBinaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {dateValue};
+ Value dateValues[] = new Value[] {dateValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Double and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
- Value doubleValues[] = {doubleValue};
+ Value doubleValues[] = new Value[] {doubleValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Double and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {longValue};
+ Value longValues[] = new Value[] {longValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Double and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {doubleValue, booleanValue};
+ Value booleanValues[] = new Value[] {doubleValue, booleanValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Double and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {doubleValue, nameValue};
+ Value nameValues[] = new Value[] {doubleValue, nameValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Double and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
- Value pathValues[] = {doubleValue, pathValue};
+ Value pathValues[] = new Value[] {doubleValue, pathValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Double and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -242,9 +242,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No double property def with " +
"testable value constraints has been found");
}
@@ -271,15 +270,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple double property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java Thu Apr 21 02:41:39 2005
@@ -162,7 +162,7 @@
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
Value anyStringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
- Value anyStringValues[] = {longValue, anyStringValue};
+ Value anyStringValues[] = new Value[] {longValue, anyStringValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Long and values are of type StringValue " +
"that are not convertible to LongValues",
@@ -170,14 +170,14 @@
Value longStringValue =
new StringValue(NodeTypeUtil.getValueOfType(PropertyType.LONG).getString());
- Value longStringValues[] = {longStringValue};
+ Value longStringValues[] = new Value[] {longStringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Long and values are of type StringValue " +
"that are convertible to LongValues",
nodeType.canSetProperty(propDef.getName(), longStringValues));
Value anyBinaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
- Value anyBinaryValues[] = {longValue, anyBinaryValue};
+ Value anyBinaryValues[] = new Value[] {longValue, anyBinaryValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Long and values are of type BinaryValue " +
"that are not convertible to LongValues",
@@ -185,43 +185,43 @@
Value longBinaryValue =
new BinaryValue(NodeTypeUtil.getValueOfType(PropertyType.LONG).getString());
- Value longBinaryValues[] = {longBinaryValue};
+ Value longBinaryValues[] = new Value[] {longBinaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Long and values are of type BinaryValue " +
"that are convertible to LongValues",
nodeType.canSetProperty(propDef.getName(), longBinaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {dateValue};
+ Value dateValues[] = new Value[] {dateValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Long and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {doubleValue};
+ Value doubleValues[] = new Value[] {doubleValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Long and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
- Value longValues[] = {longValue};
+ Value longValues[] = new Value[] {longValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Long and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {longValue, booleanValue};
+ Value booleanValues[] = new Value[] {longValue, booleanValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Long and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {longValue, nameValue};
+ Value nameValues[] = new Value[] {longValue, nameValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Long and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
- Value pathValues[] = {longValue, pathValue};
+ Value pathValues[] = new Value[] {longValue, pathValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Long and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -242,9 +242,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No long property def with " +
"testable value constraints has been found");
}
@@ -271,15 +270,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple long property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java Thu Apr 21 02:41:39 2005
@@ -80,7 +80,7 @@
NodeType nodeType = propDef.getDeclaringNodeType();
Value value = NodeTypeUtil.getValueOfType(propDef.getRequiredType());
- Value values[] = {value, value};
+ Value values[] = new Value[] {value, value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return true if the property is protected.",
@@ -104,7 +104,7 @@
NodeType nodeType = propDef.getDeclaringNodeType();
Value value = NodeTypeUtil.getValueOfType(propDef.getRequiredType());
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if the property is not multiple",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java Thu Apr 21 02:41:39 2005
@@ -168,71 +168,71 @@
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
Value nameStringValue = new StringValue("abc");
- Value nameStringValues[] = {nameStringValue};
+ Value nameStringValues[] = new Value[] {nameStringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Name and values are of type StringValue " +
"that are convertible to NameValues",
nodeType.canSetProperty(propDef.getName(), nameStringValues));
Value notNameStringValue = new StringValue("a:b:c");
- Value notNameStringValues[] = {nameValue, notNameStringValue};
+ Value notNameStringValues[] = new Value[] {nameValue, notNameStringValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type StringValue " +
"that are not convertible to NameValues ",
nodeType.canSetProperty(propDef.getName(), notNameStringValues));
Value nameBinaryValue = new BinaryValue("abc");
- Value nameBinaryValues[] = {nameBinaryValue};
+ Value nameBinaryValues[] = new Value[] {nameBinaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Name and values are of type BinaryValue " +
"that are convertible to NameValues",
nodeType.canSetProperty(propDef.getName(), nameBinaryValues));
Value notNameBinaryValue = new BinaryValue("a:b:c");
- Value notNameBinaryValues[] = {nameValue, notNameBinaryValue};
+ Value notNameBinaryValues[] = new Value[] {nameValue, notNameBinaryValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type BinaryValue " +
"that are not convertible to NameValues",
nodeType.canSetProperty(propDef.getName(), notNameBinaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {nameValue, dateValue};
+ Value dateValues[] = new Value[] {nameValue, dateValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {nameValue, doubleValue};
+ Value doubleValues[] = new Value[] {nameValue, doubleValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {nameValue, longValue};
+ Value longValues[] = new Value[] {nameValue, longValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {booleanValue};
+ Value booleanValues[] = new Value[] {booleanValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
- Value nameValues[] = {nameValue};
+ Value nameValues[] = new Value[] {nameValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Name and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value namePathValue = PathValue.valueOf("abc");
- Value namePathValues[] = {namePathValue};
+ Value namePathValues[] = new Value[] {namePathValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Name and values are of type PathValue " +
"if Path is relative, is one element long and has no index",
nodeType.canSetProperty(propDef.getName(), namePathValues));
Value notNamePathValue = PathValue.valueOf("/abc");
- Value notNamePathValues[] = {nameValue, notNamePathValue};
+ Value notNamePathValues[] = new Value[] {nameValue, notNamePathValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Name and values are of type PathValue " +
"if Path is not relative, is more than one element long or has an index",
@@ -254,9 +254,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No name property def with " +
"testable value constraints has been found");
}
@@ -283,15 +282,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple name property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java Thu Apr 21 02:41:39 2005
@@ -166,64 +166,64 @@
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
Value pathStringValue = new StringValue("abc");
- Value pathStringValues[] = {pathStringValue};
+ Value pathStringValues[] = new Value[] {pathStringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Path and values are of type StringValue " +
"that are convertible to PathValues",
nodeType.canSetProperty(propDef.getName(), pathStringValues));
Value notPathStringValue = new StringValue("a:b:c");
- Value notPathStringValues[] = {pathValue, notPathStringValue};
+ Value notPathStringValues[] = new Value[] {pathValue, notPathStringValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type StringValue " +
"that are not convertible to PathValues ",
nodeType.canSetProperty(propDef.getName(), notPathStringValues));
Value pathBinaryValue = new BinaryValue("abc");
- Value pathBinaryValues[] = {pathBinaryValue};
+ Value pathBinaryValues[] = new Value[] {pathBinaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Path and values are of type BinaryValue " +
"that are convertible to PathValues",
nodeType.canSetProperty(propDef.getName(), pathBinaryValues));
Value notPathBinaryValue = new BinaryValue("a:b:c");
- Value notPathBinaryValues[] = {pathValue, notPathBinaryValue};
+ Value notPathBinaryValues[] = new Value[] {pathValue, notPathBinaryValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type BinaryValue " +
"that are not convertible to PathValues",
nodeType.canSetProperty(propDef.getName(), notPathBinaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {pathValue, dateValue};
+ Value dateValues[] = new Value[] {pathValue, dateValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {pathValue, doubleValue};
+ Value doubleValues[] = new Value[] {pathValue, doubleValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {pathValue, longValue};
+ Value longValues[] = new Value[] {pathValue, longValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {booleanValue};
+ Value booleanValues[] = new Value[] {booleanValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Path and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {nameValue};
+ Value nameValues[] = new Value[] {nameValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Path and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
- Value pathValues[] = {pathValue, pathValue};
+ Value pathValues[] = new Value[] {pathValue, pathValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Path and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -244,9 +244,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No path property def with " +
"testable value constraints has been found");
}
@@ -273,15 +272,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple path property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java Thu Apr 21 02:41:39 2005
@@ -144,50 +144,50 @@
Value stringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
- Value stringValues[] = {stringValue};
+ Value stringValues[] = new Value[] {stringValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type StringValue",
nodeType.canSetProperty(propDef.getName(), stringValues));
Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
- Value binaryValues[] = {binaryValue};
+ Value binaryValues[] = new Value[] {binaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type BinaryValue " +
"and is UTF-8",
nodeType.canSetProperty(propDef.getName(), binaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {dateValue};
+ Value dateValues[] = new Value[] {dateValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {doubleValue};
+ Value doubleValues[] = new Value[] {doubleValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {longValue};
+ Value longValues[] = new Value[] {longValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
- Value booleanValues[] = {booleanValue};
+ Value booleanValues[] = new Value[] {booleanValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {nameValue};
+ Value nameValues[] = new Value[] {nameValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
- Value pathValues[] = {pathValue};
+ Value pathValues[] = new Value[] {pathValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type String and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -208,9 +208,8 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No string property def with " +
"testable value constraints has been found");
}
@@ -237,15 +236,14 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No multiple string property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- Value values[] = {value};
+ Value values[] = new Value[] {value};
assertFalse("canSetProperty(String propertyName, Value[] values) must " +
"return false if values do not match the value constraints.",
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java Thu Apr 21 02:41:39 2005
@@ -35,7 +35,6 @@
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.util.ISO8601;
-import java.text.ParseException;
import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -43,22 +42,24 @@
/**
* Utility class to locate item definitions in the NodeTyeManager.
*/
-class NodeTypeUtil {
+public class NodeTypeUtil {
/**
* Locate a child node def parsing all node types
*
* @param session: the session to access the node types
- * @param regardDefaultPrimaryType: if true, the default primary type of the returned
- * <code>NodeDef</code> is according to param
- * <code>defaultPrimaryType</code>. If false, the returned
- * <code>NodeDef</code> might have a default primary type
- * or not.
- * @param defaultPrimaryType: if <code>regardDefaultPrimaryType</code> is true:
- * if true, the returned <code>NodeDef</code> has a
- * default primary type, else not
- * @param residual: if true, the returned <code>NodeDef</code> is of
- * the residual name "*", else not
+ * @param regardDefaultPrimaryType: if true, the default primary type of the
+ * returned <code>NodeDef</code> is
+ * according to param <code>defaultPrimaryType</code>.
+ * If false, the returned <code>NodeDef</code>
+ * might have a default primary type or
+ * not.
+ * @param defaultPrimaryType: if <code>regardDefaultPrimaryType</code>
+ * is true: if true, the returned
+ * <code>NodeDef</code> has a default
+ * primary type, else not
+ * @param residual: if true, the returned <code>NodeDef</code>
+ * is of the residual name "*", else not
* @return
* @throws RepositoryException
*/
@@ -132,8 +133,7 @@
* protected, else not
* @param mandatory: if true, the returned <code>NodeDef</code> is
* mandatory, else not
- * @return the first <code>NodeDef</code> found fitting the
- * requirements
+ * @return the first <code>NodeDef</code> found fitting the requirements
*/
public static NodeDefinition locateChildNodeDef(Session session,
boolean isProtected,
@@ -236,12 +236,6 @@
// property def has no constraints
continue;
}
- // check if a value out of constraint is buildable
- Value v = getValueOutOfContstraint(propDef);
- if (v == null) {
- // no value out of the constraint range available
- continue;
- }
}
if (!residual && propDef.getName().equals("*")) {
@@ -378,9 +372,21 @@
}
/**
- * Returns a value out of the value constraints
+ * Returns a value according to the value contraints of a
+ * <code>PropertyDefinition</code>
+ *
+ * @param propDef: The <code>PropertyDefinition</code> whose constraints
+ * will be regarded
+ * @param satisfied If true, the returned <code>Value</code> will satisfying
+ * the constraints - If false, the returned
+ * <code>Value</code> will not satisfying the constraints.
+ * @return Depending on param <code>satisfied</code> a <code>Value</code>
+ * satisfying or not satistying the constraints of
+ * <code>propDef</code> will be returned. Null will be returned if
+ * no accordant <code>Value</code> could be build.
*/
- public static Value getValueOutOfContstraint(PropertyDefinition propDef)
+ public static Value getValueAccordingToValueConstraints(PropertyDefinition propDef,
+ boolean satisfied)
throws ValueFormatException, RepositoryException {
int type = propDef.getRequiredType();
@@ -395,6 +401,11 @@
{
long absMin = 0;
long absMax = 0;
+
+ // indicate if absMin and absMax are already set
+ boolean absMinSet = false;
+ boolean absMaxSet = false;
+
// boundless vars indicate min/max without bounds,
// if constraint is e.g.(min,) or [,max]
boolean maxBoundless = false;
@@ -408,7 +419,10 @@
minBoundless = true;
} else {
long min = Long.valueOf(minStr).longValue();
- if (min < absMin) {
+ if (!absMinSet) {
+ absMin = min;
+ absMinSet = true;
+ } else if (min < absMin) {
absMin = min;
}
}
@@ -419,23 +433,40 @@
maxBoundless = true;
} else {
long max = Long.valueOf(maxStr).longValue();
- if (max > absMax) {
+ if (!absMaxSet) {
absMax = max;
+ absMaxSet = true;
+ } else if (max > absMax) {
+ absMin = max;
}
}
}
}
- if (!minBoundless && absMin > 1) {
- return new BinaryValue("0");
- } else if (!maxBoundless) {
- // build a binary value of size > absMax
+ if (satisfied) {
+ // build a binary value absMin < size > absMax
StringBuffer content = new StringBuffer();
- for (int i = 0; i <= absMax; i = i + 10) {
- content.append("0123456789");
+ for (int i = 0; i <= absMin + 1; i++) {
+ content.append("X");
+ }
+ if (!maxBoundless && content.length() >= absMax) {
+ return null;
+ } else {
+ return new BinaryValue(content.toString());
}
- return new BinaryValue(content.toString());
} else {
- return null;
+ if (!minBoundless && absMin > 1) {
+ // return a value of size < absMin
+ return new BinaryValue("0");
+ } else if (!maxBoundless) {
+ // build a binary value of size > absMax
+ StringBuffer content = new StringBuffer();
+ for (int i = 0; i <= absMax; i = i + 10) {
+ content.append("0123456789");
+ }
+ return new BinaryValue(content.toString());
+ } else {
+ return null;
+ }
}
}
@@ -444,8 +475,12 @@
if (constraints.length > 1) {
return null; // silly constraint
}
- boolean value = !Boolean.valueOf(constraints[0]).booleanValue();
- return new BooleanValue(value);
+ boolean value = Boolean.valueOf(constraints[0]).booleanValue();
+ if (satisfied) {
+ return new BooleanValue(value);
+ } else {
+ return new BooleanValue(!value);
+ }
}
case (PropertyType.DATE):
@@ -483,14 +518,33 @@
}
}
}
- if (!minBoundless) {
- absMin.setTimeInMillis(absMin.getTimeInMillis() - 1);
- return new DateValue(absMin);
- } else if (!maxBoundless) {
- absMax.setTimeInMillis(absMax.getTimeInMillis() + 1);
- return new DateValue(absMax);
+ if (satisfied) {
+ if (absMin != null) {
+ absMin.setTimeInMillis(absMin.getTimeInMillis() + 1);
+ if (absMin.after(absMax)) {
+ return null;
+ }
+ return new DateValue(absMin);
+ } else if (absMax != null) {
+ absMax.setTimeInMillis(absMax.getTimeInMillis() - 1);
+ if (absMax.before(absMin)) {
+ return null;
+ }
+ return new DateValue(absMax);
+ } else {
+ // neither min nor max set: return "now"
+ return new DateValue(Calendar.getInstance());
+ }
} else {
- return null;
+ if (!minBoundless) {
+ absMin.setTimeInMillis(absMin.getTimeInMillis() - 1);
+ return new DateValue(absMin);
+ } else if (!maxBoundless) {
+ absMax.setTimeInMillis(absMax.getTimeInMillis() + 1);
+ return new DateValue(absMax);
+ } else {
+ return null;
+ }
}
}
@@ -499,6 +553,10 @@
double absMin = 0;
double absMax = 0;
+ // indicate if absMin and absMax are already set
+ boolean absMinSet = false;
+ boolean absMaxSet = false;
+
// boundless vars indicate min/max without bounds,
// if constraint is e.g.(min,) or [,max]
boolean maxBoundless = false;
@@ -512,7 +570,10 @@
minBoundless = true;
} else {
double min = Double.valueOf(minStr).doubleValue();
- if (min < absMin) {
+ if (!absMinSet) {
+ absMin = min;
+ absMinSet = true;
+ } else if (min < absMin) {
absMin = min;
}
}
@@ -523,18 +584,34 @@
maxBoundless = true;
} else {
double max = Double.valueOf(maxStr).doubleValue();
- if (max > absMax) {
+ if (!absMaxSet) {
+ absMax = max;
+ absMaxSet = true;
+ } else if (max > absMax) {
absMax = max;
}
}
}
}
- if (!minBoundless) {
- return new DoubleValue(absMin - 1);
- } else if (!maxBoundless) {
- return new DoubleValue(absMax + 1);
+ if (satisfied) {
+ if (minBoundless) {
+ return new DoubleValue(absMax - 1);
+ } else if (maxBoundless) {
+ return new DoubleValue(absMin + 1);
+ } else if (absMin < absMax) {
+ double d = (absMin + absMax) / 2;
+ return new DoubleValue(d);
+ } else {
+ return null;
+ }
} else {
- return null;
+ if (!minBoundless) {
+ return new DoubleValue(absMin - 1);
+ } else if (!maxBoundless) {
+ return new DoubleValue(absMax + 1);
+ } else {
+ return null;
+ }
}
}
@@ -543,6 +620,10 @@
long absMin = 0;
long absMax = 0;
+ // indicate if absMin and absMax are already set
+ boolean absMinSet = false;
+ boolean absMaxSet = false;
+
// boundless vars indicate min/max without bounds,
// if constraint is e.g.(min,) or [,max]
boolean maxBoundless = false;
@@ -556,7 +637,10 @@
minBoundless = true;
} else {
long min = Long.valueOf(minStr).longValue();
- if (min < absMin) {
+ if (!absMinSet) {
+ absMin = min;
+ absMinSet = true;
+ } else if (min < absMin) {
absMin = min;
}
}
@@ -567,47 +651,73 @@
maxBoundless = true;
} else {
long max = Long.valueOf(maxStr).longValue();
- if (max > absMax) {
+ if (!absMaxSet) {
+ absMax = max;
+ absMaxSet = true;
+ } else if (max > absMax) {
absMax = max;
}
}
}
}
- if (!minBoundless) {
- return new LongValue(absMin - 1);
- } else if (!maxBoundless) {
- return new LongValue(absMax + 1);
+ if (satisfied) {
+ if (minBoundless) {
+ return new LongValue(absMax - 1);
+ } else if (maxBoundless) {
+ return new LongValue(absMin + 1);
+ } else if (absMin < absMax - 1) {
+ long x = (absMin + absMax) / 2;
+ return new LongValue(x);
+ } else {
+ return null;
+ }
} else {
- return null;
+ if (!minBoundless) {
+ return new LongValue(absMin - 1);
+ } else if (!maxBoundless) {
+ return new LongValue(absMax + 1);
+ } else {
+ return null;
+ }
}
}
case (PropertyType.NAME):
{
- // build a name that is for sure not part of the constraints
- StringBuffer name = new StringBuffer("X");
- for (int i = 0; i < constraints.length; i++) {
- name.append(constraints[i].replaceAll(":", ""));
+ if (satisfied) {
+ // not in use so far
+ return null;
+ } else {
+ // build a name that is for sure not part of the constraints
+ StringBuffer name = new StringBuffer("X");
+ for (int i = 0; i < constraints.length; i++) {
+ name.append(constraints[i].replaceAll(":", ""));
+ }
+ return NameValue.valueOf(name.toString());
}
- return NameValue.valueOf(name.toString());
}
case (PropertyType.PATH):
{
- // build a path that is for sure not part of the constraints
- StringBuffer path = new StringBuffer("X");
- for (int i = 0; i < constraints.length; i++) {
- path.append(constraints[i]);
- }
- String pathStr = path.toString();
-
- // replace colon to avoid /a/x:b + y:c => /a/x:b:y:c
- // where x:b:y:c is not a legal path element
- pathStr = pathStr.replaceAll(":", "");
- pathStr = pathStr.replaceAll("\\*", "");
- pathStr = pathStr.replaceAll("//", "/");
+ if (satisfied) {
+ // not in use so far
+ return null;
+ } else {
+ // build a path that is for sure not part of the constraints
+ StringBuffer path = new StringBuffer("X");
+ for (int i = 0; i < constraints.length; i++) {
+ path.append(constraints[i]);
+ }
+ String pathStr = path.toString();
+
+ // replace colon to avoid /a/x:b + y:c => /a/x:b:y:c
+ // where x:b:y:c is not a legal path element
+ pathStr = pathStr.replaceAll(":", "");
+ pathStr = pathStr.replaceAll("\\*", "");
+ pathStr = pathStr.replaceAll("//", "/");
- return PathValue.valueOf(pathStr);
+ return PathValue.valueOf(pathStr);
+ }
}
case (PropertyType.UNDEFINED):
@@ -617,21 +727,26 @@
default:
{
- // build a string that will probably not be part of the constraints
- StringBuffer value = new StringBuffer("X");
- for (int i = 0; i < constraints.length; i++) {
- value.append(constraints[i]);
- }
+ if (satisfied) {
+ // not in use so far
+ return null;
+ } else {
+ // build a string that will probably not satisfy the constraints
+ StringBuffer value = new StringBuffer("X");
+ for (int i = 0; i < constraints.length; i++) {
+ value.append(constraints[i]);
+ }
- // test if value does not match any of the constraints
- for (int i = 0; i < constraints.length; i++) {
- Pattern pattern = Pattern.compile(constraints[i]);
- Matcher matcher = pattern.matcher(value);
- if (matcher.matches()) {
- return null;
+ // test if value does not match any of the constraints
+ for (int i = 0; i < constraints.length; i++) {
+ Pattern pattern = Pattern.compile(constraints[i]);
+ Matcher matcher = pattern.matcher(value);
+ if (matcher.matches()) {
+ return null;
+ }
}
+ return new StringValue(value.toString());
}
- return new StringValue(value.toString());
}
}
}
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java?rev=164016&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java Thu Apr 21 02:41:39 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.version;
+
+import javax.jcr.version.Version;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>GetContainingHistoryTest</code> provides test methods covering {@link
+ * javax.jcr.version.Version#getContainingHistory()}.
+ *
+ * @test
+ * @sources GetContainingHistoryTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.GetContainingHistoryTest
+ * @keywords versioning
+ */
+public class GetContainingHistoryTest extends AbstractVersionTest {
+
+ /**
+ * Tests if {@link javax.jcr.version.Version#getContainingHistory()} returns
+ * the correct VersionHistory instance.
+ */
+ public void testGetContainingHistory() throws RepositoryException {
+ // create version
+ versionableNode.checkout();
+ Version version = versionableNode.checkin();
+
+ assertTrue("Method getContainingHistory() must return the same VersionHistory " +
+ "as getVersionHistory() of the corresponding Node.",
+ versionableNode.getVersionHistory().isSame(version.getContainingHistory()));
+ }
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java?rev=164016&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java Thu Apr 21 02:41:39 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.version;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.version.Version;
+
+/**
+ * <code>GetVersionableUUIDTest</code> provides test methods covering {@link
+ * javax.jcr.version.VersionHistory#getVersionableUUID()}.
+ *
+ * @test
+ * @sources GetVersionableUUIDTest.java
+ * @executeClass org.apache.jackrabbit.test.api.version.GetVersionableUUIDTest
+ * @keywords versioning
+ */
+public class GetVersionableUUIDTest extends AbstractVersionTest {
+
+ /**
+ * Tests if VersionHistory.getVersionableUUID() returns the uuid of the
+ * corresponding versionable node.
+ */
+ public void testGetVersionableUUID() throws RepositoryException {
+ // create version
+ versionableNode.checkout();
+ Version version = versionableNode.checkin();
+
+ assertEquals("Method getVersionableUUID() must return the UUID of the corresponding Node.",
+ version.getContainingHistory().getVersionableUUID(),
+ versionableNode.getUUID());
+ }
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java Thu Apr 21 02:41:39 2005
@@ -54,6 +54,8 @@
suite.addTestSuite(GetReferencesNodeTest.class);
suite.addTestSuite(GetPredecessorsTest.class);
suite.addTestSuite(GetCreatedTest.class);
+ suite.addTestSuite(GetContainingHistoryTest.class);
+ suite.addTestSuite(GetVersionableUUIDTest.class);
return suite;
}