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 [1/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/
Author: mreutegg
Date: Thu Apr 21 02:41:39 2005
New Revision: 164016
URL: http://svn.apache.org/viewcvs?rev=164016&view=rev
Log:
Additional test cases for various areas, contributed by Vinzenz Wyser.
Added:
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java (with props)
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java (with props)
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetContainingHistoryTest.java (with props)
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/GetVersionableUUIDTest.java (with props)
Modified:
incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JCRTestResult.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/ExportDocViewTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionReadMethodsTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/version/TestAll.java
Modified: incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml (original)
+++ incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml Thu Apr 21 02:41:39 2005
@@ -76,7 +76,7 @@
<propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
</nodeType>
- <!-- Defines a nodetype for testing NodeType.canSetProperty() -->
+ <!-- Defines a nodetype for tests of NodeType.canSetProperty(), Property.setValue() and Node.setProperty() -->
<nodeType name="test:canSetProperty" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
@@ -179,6 +179,16 @@
<propertyDefinition name="PathMultipleConstraints" requiredType="Path" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
<valueConstraints>
<valueConstraint>/abc</valueConstraint>
+ </valueConstraints>
+ </propertyDefinition>
+ <propertyDefinition name="ReferenceConstraints" requiredType="Reference" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+ <valueConstraints>
+ <valueConstraint>test:canSetProperty</valueConstraint>
+ </valueConstraints>
+ </propertyDefinition>
+ <propertyDefinition name="ReferenceMultipleConstraints" requiredType="Reference" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+ <valueConstraints>
+ <valueConstraint>test:canSetProperty</valueConstraint>
</valueConstraints>
</propertyDefinition>
</nodeType>
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java Thu Apr 21 02:41:39 2005
@@ -398,7 +398,7 @@
* @param testResult the test result.
*/
public void run(TestResult testResult) {
- super.run(new JCRTestResult(testResult));
+ super.run(new JCRTestResult(testResult, log));
}
/**
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JCRTestResult.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JCRTestResult.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JCRTestResult.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/JCRTestResult.java Thu Apr 21 02:41:39 2005
@@ -32,12 +32,17 @@
/** The original TestResult we delegate to */
private final TestResult orig;
+ /** The log writer of the test classes */
+ private final LogPrintWriter log;
+
/**
* Creates a new JCRTestResult that delegates to <code>orig</code>.
* @param orig the original TestResult this result wraps.
+ * @param log the logger
*/
- public JCRTestResult(TestResult orig) {
+ public JCRTestResult(TestResult orig, LogPrintWriter log) {
this.orig = orig;
+ this.log = log;
}
/**
@@ -48,7 +53,7 @@
*/
public synchronized void addError(Test test, Throwable throwable) {
if (throwable instanceof NotExecutableException) {
- // ignore
+ log.println("Test case: " + test.toString() + " not executable");
} else {
orig.addError(test, throwable);
}
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/ExportDocViewTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/ExportDocViewTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/ExportDocViewTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/ExportDocViewTest.java Thu Apr 21 02:41:39 2005
@@ -54,6 +54,7 @@
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
/**
* <code>ExportDocViewTest</code> tests the two Session methods :
@@ -218,7 +219,7 @@
*
* @throws RepositoryException
*/
- private void compareTree() throws RepositoryException {
+ private void compareTree() throws RepositoryException, IOException {
Element root = doc.getDocumentElement();
textValuesStack = new Stack();
// we assume the path is valid
@@ -284,7 +285,8 @@
* @param elem
* @throws RepositoryException
*/
- private void checkChildNodes(Node node, Element elem) throws RepositoryException {
+ private void checkChildNodes(Node node, Element elem)
+ throws RepositoryException, IOException {
NodeIterator nodeIter = node.getNodes();
if (getSize(nodeIter) == 0) {
@@ -334,7 +336,7 @@
* @throws RepositoryException
*/
private void compareChildTree(Node node, Element parentElem)
- throws RepositoryException {
+ throws RepositoryException, IOException {
Element nodeElem;
@@ -488,7 +490,8 @@
* @param elem
* @throws RepositoryException
*/
- private void compareNode(Node node, Element elem) throws RepositoryException {
+ private void compareNode(Node node, Element elem)
+ throws RepositoryException, IOException {
// count the child nodes and compare with the exported child elements
compareChildNumber(node, elem);
// count the properties and compare with attributes exported
@@ -515,7 +518,7 @@
* @throws RepositoryException
*/
private void compareProperty(Property prop, Attr attr)
- throws RepositoryException {
+ throws RepositoryException, IOException {
boolean isMultiple = prop.getDefinition().isMultiple();
boolean isBinary = (prop.getType() == PropertyType.BINARY);
@@ -906,6 +909,19 @@
}
/**
+ * Encodes a given stream to base64.
+ *
+ * @param in the stream to encode.
+ * @return the encoded string in base64.
+ * @throws IOException if an error occurs.
+ */
+ private static String encodeBase64(InputStream in) throws IOException {
+ StringWriter writer = new StringWriter();
+ Base64.encode(in, writer);
+ return writer.getBuffer().toString();
+ }
+
+ /**
* Exports values of a multivalue property and concatenate the values
* separated by a space. (chapter 6.4.4 of the JCR specification).
*
@@ -914,7 +930,8 @@
* @return
* @throws RepositoryException
*/
- private static String exportValues(Property prop, boolean isBinary) throws RepositoryException {
+ private static String exportValues(Property prop, boolean isBinary)
+ throws RepositoryException, IOException {
Value[] vals = prop.getValues();
// order of multi values is preserved.
// multival with empty array is exported as empty string
@@ -922,7 +939,7 @@
if (isBinary) {
for (int i = 0; i < vals.length; i++) {
- exportedVal += vals[i];
+ exportedVal += encodeBase64(vals[i].getStream());
exportedVal += " ";
}
} else {
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionReadMethodsTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionReadMethodsTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SessionReadMethodsTest.java Thu Apr 21 02:41:39 2005
@@ -27,8 +27,6 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.NodeIterator;
-import java.security.AccessControlException;
-
/**
* <code>SessionReadMethodsTest</code>...
*
@@ -163,6 +161,22 @@
}
}
+ /**
+ * Tests if isLive() returns true if the <code>Session</code> is usable by
+ * the client and false if it is not usable
+ */
+ public void testIsLive() {
+ assertTrue("Method isLive() must return true if the session " +
+ "is usable by the client.",
+ session.isLive());
+
+ session.logout();
+ assertFalse("Method isLive() must return false if the session " +
+ "is not usable by the client, e.g. if the session is " +
+ "logged-out.",
+ session.isLive());
+ }
+
//----------------------< internal >----------------------------------------
/**
@@ -207,4 +221,5 @@
}
return referenced;
}
+
}
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java?rev=164016&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java Thu Apr 21 02:41:39 2005
@@ -0,0 +1,431 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.PropertyType;
+import javax.jcr.Value;
+import javax.jcr.Node;
+import javax.jcr.ReferenceValue;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeType;
+
+/**
+ * <code>SetPropertyConstraintViolationExceptionTest</code> tests if
+ * setProperty() throws a ConstraintViolationException either immediately (by
+ * setValue()) or on save, if the change would violate a value constraint.
+ *
+ * @test
+ * @sources SetPropertyConstraintViolationExceptionTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyConstraintViolationExceptionTest
+ * @keywords level2
+ */
+public class SetPropertyConstraintViolationExceptionTest extends AbstractJCRTest {
+
+ /**
+ * Tests if setProperty(String name, boolean value) and setProperty(String
+ * name, Value value) where value is a BooleanValue throw a
+ * ConstraintViolationException either immediately (by setProperty()), or on
+ * save, if the change would violate a node type constraint
+ */
+ public void testBooleanProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, boolean value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied.getBoolean());
+ node.save();
+ fail("setProperty(String name, boolean value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied);
+ node.save();
+ fail("setProperty(String name, boolean value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setProperty(String name, Calendar value) and setProperty(String
+ * name, Value value) where value is a DateValue throw a
+ * ConstraintViolationException either immediately (by setProperty()), or on
+ * save, if the change would violate a node type constraint
+ */
+ public void testDateProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, Calendar value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied.getDate());
+ node.save();
+ fail("setProperty(String name, Calendar value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied);
+ node.save();
+ fail("setProperty(String name, Value value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setProperty(String name, double value) and setProperty(String
+ * name, Value value) where value is a DoubleValue throw a
+ * ConstraintViolationException either immediately (by setProperty()), or on
+ * save, if the change would violate a node type constraint
+ */
+ public void testDoubleProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, double value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied.getDouble());
+ node.save();
+ fail("setProperty(String name, double value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied);
+ node.save();
+ fail("setProperty(String name, Value value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setProperty(String name, InputStream value) and
+ * setProperty(String name, Value value) where value is a BinaryValue throw
+ * a ConstraintViolationException either immediately (by setProperty()), or
+ * on save, if the change would violate a node type constraint
+ */
+ public void testBinaryProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied1 = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ Value valueNotSatisfied2 = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied1 == null || valueNotSatisfied2 == null) {
+ throw new NotExecutableException("No binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, InputStream value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied1.getStream());
+ node.save();
+ fail("setProperty(String name, InputStream value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied2);
+ node.save();
+ fail("setProperty(String name, Value value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setProperty(String name, long value) and setProperty(String
+ * name, Value value) where value is a LongValue throw a
+ * ConstraintViolationException either immediately (by setProperty()), or on
+ * save, if the change would violate a node type constraint
+ */
+ public void testLongProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, long value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied.getLong());
+ node.save();
+ fail("setProperty(String name, long value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), valueNotSatisfied);
+ node.save();
+ fail("setProperty(String name, Value value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setProperty(String name, Node value) and setProperty(String
+ * name, Value value) where value is a ReferenceValue throw a
+ * ConstraintViolationException either immediately (by setProperty()), or on
+ * save, if the change would violate a node type constraint
+ */
+ public void testReferenceProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ String constraints[] = propDef.getValueConstraints();
+ String nodeTypeNotSatisfied = null;
+
+ NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+ NodeTypeIterator types = manager.getAllNodeTypes();
+
+ // find a NodeType which is not satisfying the constraints
+ findNodeTypeNotSatisfied:
+ while (types.hasNext()) {
+ NodeType type = types.nextNodeType();
+ String name = type.getName();
+ for (int i = 0; i < constraints.length; i++) {
+ if (name.equals(constraints[i])) {
+ continue findNodeTypeNotSatisfied;
+ }
+ nodeTypeNotSatisfied = name;
+ break findNodeTypeNotSatisfied;
+ }
+ }
+
+ if (nodeTypeNotSatisfied == null) {
+ throw new NotExecutableException("No reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ Node node;
+ Node nodeNotSatisfied;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+
+ // create a referenceable node not satisfying the constraint
+ nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
+ nodeNotSatisfied.addMixin(mixReferenceable);
+
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setProperty(String name, Node value)
+ try {
+ node.setProperty(propDef.getName(), nodeNotSatisfied);
+ node.save();
+ fail("setProperty(String name, Node value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setProperty(String name, Value value)
+ try {
+ node.setProperty(propDef.getName(), new ReferenceValue(nodeNotSatisfied));
+ node.save();
+ fail("setProperty(String name, Value value) must throw a " +
+ "ConstraintViolationException if the change would violate a " +
+ "node type constraint either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java?rev=164016&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java Thu Apr 21 02:41:39 2005
@@ -0,0 +1,848 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.PropertyType;
+import javax.jcr.Value;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.ReferenceValue;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeType;
+
+/**
+ * <code>SetValueConstraintViolationExceptionTest</code> tests if setValue()
+ * throws a ConstraintViolationException either immediately (by setValue()) or
+ * on save, if the change would violate a value constraint.
+ *
+ * @test
+ * @sources SetValueConstraintViolationExceptionTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest
+ * @keywords level2
+ */
+public class SetValueConstraintViolationExceptionTest extends AbstractJCRTest {
+
+ /**
+ * Tests if setValue(InputStream value) and setValue(Value value) where
+ * value is a BinaryValue throw a ConstraintViolationException if the change
+ * would violate a value constraint
+ */
+ public void testBinaryProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied1 = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ Value valueNotSatisfied2 = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied1 == null || valueNotSatisfied2 == null) {
+ throw new NotExecutableException("No binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), valueSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(InputStream value)
+ try {
+ prop.setValue(valueNotSatisfied1.getStream());
+ node.save();
+ fail("setValue(InputStream value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(valueNotSatisfied2);
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(boolean value) and setValue(Value value) where value is
+ * a BooleanValue throw a ConstraintViolationException if the change would
+ * violate a value constraint
+ */
+ public void testBooleanProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), valueSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(boolean value)
+ try {
+ prop.setValue(valueNotSatisfied.getBoolean());
+ node.save();
+ fail("setValue(boolean value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(valueNotSatisfied);
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Calendar value) and setValue(Value value) where value
+ * is a DateValue throw a ConstraintViolationException if the change would
+ * violate a value constraint
+ */
+ public void testDateProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), valueSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(Calendar value)
+ try {
+ prop.setValue(valueNotSatisfied.getDate());
+ node.save();
+ fail("setValue(Date value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(valueNotSatisfied);
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Double value) and setValue(Value value) where value is
+ * a DoubleValue throw a ConstraintViolationException if the change would
+ * violate a value constraint
+ */
+ public void testDoubleProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), valueSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(double value)
+ try {
+ prop.setValue(valueNotSatisfied.getDouble());
+ node.save();
+ fail("setValue(double value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(valueNotSatisfied);
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Long value) and setValue(Value value) where value is a
+ * LongValue throw a ConstraintViolationException if the change would
+ * violate a value constraint
+ */
+ public void testLongProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), valueSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(long value)
+ try {
+ prop.setValue(valueNotSatisfied.getLong());
+ node.save();
+ fail("setValue(long value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(valueNotSatisfied);
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+
+ /**
+ * Tests if setValue(Node value) and setValue(Value value) where value is a
+ * ReferenceValue throw a ConstraintViolationException if the change would
+ * violate a value constraint
+ */
+ public void testReferenceProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, false, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ String constraints[] = propDef.getValueConstraints();
+ String nodeTypeSatisfied = constraints[0];
+ String nodeTypeNotSatisfied = null;
+
+ NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+ NodeTypeIterator types = manager.getAllNodeTypes();
+
+ // find a NodeType which is not satisfying the constraints
+ findNodeTypeNotSatisfied:
+ while (types.hasNext()) {
+ NodeType type = types.nextNodeType();
+ String name = type.getName();
+ for (int i = 0; i < constraints.length; i++) {
+ if (name.equals(constraints[i])) {
+ continue findNodeTypeNotSatisfied;
+ }
+ nodeTypeNotSatisfied = name;
+ break findNodeTypeNotSatisfied;
+ }
+ }
+
+ if (nodeTypeNotSatisfied == null) {
+ throw new NotExecutableException("No reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ Node nodeSatisfied;
+ Node nodeNotSatisfied;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+
+ // create a referenceable node satisfying the constraint
+ nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
+ nodeSatisfied.addMixin(mixReferenceable);
+
+ // create a referenceable node not satisfying the constraint
+ nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
+ nodeNotSatisfied.addMixin(mixReferenceable);
+
+ prop = node.setProperty(propDef.getName(), nodeSatisfied);
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(Node value)
+ try {
+ prop.setValue(nodeNotSatisfied);
+ node.save();
+ fail("setValue(Node value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(new ReferenceValue(nodeNotSatisfied));
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type BinaryValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleBinaryProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No multiple binary property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ try {
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value[] values) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type BooleanValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleBooleanProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No multiple boolean property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ try {
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value[] values) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type DateValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleDateProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DATE, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No multiple date property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ try {
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value[] values) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type DoubleValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleDoubleProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No multiple double property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value[] values) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type LongValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleLongProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.LONG, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does not satisfy the ValueConstraints of propDef
+ Value valueNotSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
+ if (valueNotSatisfied == null) {
+ throw new NotExecutableException("No multiple long property def with " +
+ "testable value constraints has been found");
+ }
+
+ // find a Value that does satisfy the ValueConstraints of propDef
+ Value valueSatisfied = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, true);
+ if (valueSatisfied == null) {
+ throw new NotExecutableException("The value constraints do not allow any value.");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value value) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+ /**
+ * Tests if setValue(Value[] values) where values are of type ReferenceValue
+ * throw a ConstraintViolationException if the change would violate a value
+ * constraint
+ */
+ public void testMultipleReferenceProperty()
+ throws NotExecutableException, RepositoryException {
+
+ // locate a PropertyDefinition with ValueConstraints
+ Session session = helper.getReadWriteSession();
+ PropertyDefinition propDef =
+ NodeTypeUtil.locatePropertyDef(session, PropertyType.REFERENCE, true, false, true, false);
+
+ if (propDef == null) {
+ throw new NotExecutableException("No multiple reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ String constraints[] = propDef.getValueConstraints();
+ String nodeTypeSatisfied = constraints[0];
+ String nodeTypeNotSatisfied = null;
+
+ NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+ NodeTypeIterator types = manager.getAllNodeTypes();
+
+ // find a NodeType which is not satisfying the constraints
+ findNodeTypeNotSatisfied:
+ while (types.hasNext()) {
+ NodeType type = types.nextNodeType();
+ String name = type.getName();
+ for (int i = 0; i < constraints.length; i++) {
+ if (name.equals(constraints[i])) {
+ continue findNodeTypeNotSatisfied;
+ }
+ nodeTypeNotSatisfied = name;
+ break findNodeTypeNotSatisfied;
+ }
+ }
+
+ if (nodeTypeNotSatisfied == null) {
+ throw new NotExecutableException("No multiple reference property def with " +
+ "testable value constraints has been found");
+ }
+
+ // create a sub node of testRootNode of type propDef.getDeclaringNodeType()
+ // and add a property with constraints to this node
+ Node node;
+ Property prop;
+ Node nodeSatisfied;
+ Node nodeNotSatisfied;
+ try {
+ String nodeType = propDef.getDeclaringNodeType().getName();
+ node = testRootNode.addNode(nodeName2, nodeType);
+
+ // create a referenceable node satisfying the constraint
+ nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
+ nodeSatisfied.addMixin(mixReferenceable);
+ Value valueSatisfied = new ReferenceValue(nodeSatisfied);
+
+ // create a referenceable node not satisfying the constraint
+ nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
+ nodeNotSatisfied.addMixin(mixReferenceable);
+
+ prop = node.setProperty(propDef.getName(), new Value[]{valueSatisfied});
+ testRootNode.save();
+ } catch (ConstraintViolationException e) {
+ // implementation specific constraints do not allow to set up test environment
+ throw new NotExecutableException("Not able to create required test items.");
+ }
+
+ // test of signature setValue(Value value)
+ try {
+ Value valueNotSatisfied = new ReferenceValue(nodeNotSatisfied);
+ prop.setValue(new Value[]{valueNotSatisfied});
+ node.save();
+ fail("setValue(Value[] values) must throw a ConstraintViolationException " +
+ "if the change would violate a node type constraint " +
+ "either immediately or on save");
+ } catch (ConstraintViolationException e) {
+ // success
+ }
+ }
+
+}
\ No newline at end of file
Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Thu Apr 21 02:41:39 2005
@@ -85,6 +85,7 @@
suite.addTestSuite(SetValueLongTest.class);
suite.addTestSuite(SetValueReferenceTest.class);
suite.addTestSuite(SetValueStringTest.class);
+ suite.addTestSuite(SetValueConstraintViolationExceptionTest.class);
suite.addTestSuite(SetPropertyBooleanTest.class);
suite.addTestSuite(SetPropertyCalendarTest.class);
@@ -94,6 +95,7 @@
suite.addTestSuite(SetPropertyNodeTest.class);
suite.addTestSuite(SetPropertyStringTest.class);
suite.addTestSuite(SetPropertyValueTest.class);
+ suite.addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
suite.addTestSuite(NodeItemIsModifiedTest.class);
suite.addTestSuite(NodeItemIsNewTest.class);
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java Thu Apr 21 02:41:39 2005
@@ -144,48 +144,48 @@
Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
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 Binary and values are of type StringValue",
nodeType.canSetProperty(propDef.getName(), stringValues));
- Value binaryValues[] = {binaryValue};
+ Value binaryValues[] = new Value[] {binaryValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Binary and values are of type BinaryValue",
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 Binary 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 Binary 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 Binary 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 Binary 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 Binary 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 Binary and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -206,18 +206,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 binary property def with " +
"testable value constraints has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
- // todo: canSetProperty does not return true if size in range
- // ?: jackrabbit bug or does it not work like i did? (without stream)
- // reported to sguggis 05-03-10
assertFalse("canSetProperty(String propertyName, Value value) must " +
"return false if value does not match the value constraints.",
nodeType.canSetProperty(propDef.getName(), value));
@@ -238,15 +234,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 binary 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/CanSetPropertyBooleanTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java?rev=164016&r1=164015&r2=164016&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java Thu Apr 21 02:41:39 2005
@@ -146,48 +146,48 @@
Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
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 Boolean 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 Boolean and values are of type BinaryValue",
nodeType.canSetProperty(propDef.getName(), binaryValues));
Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
- Value dateValues[] = {booleanValue, dateValue};
+ Value dateValues[] = new Value[] {booleanValue, dateValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Boolean and values are of type DateValue",
nodeType.canSetProperty(propDef.getName(), dateValues));
Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
- Value doubleValues[] = {booleanValue, doubleValue};
+ Value doubleValues[] = new Value[] {booleanValue, doubleValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Boolean and values are of type DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValues));
Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
- Value longValues[] = {booleanValue, longValue};
+ Value longValues[] = new Value[] {booleanValue, longValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Boolean and values are of type LongValue",
nodeType.canSetProperty(propDef.getName(), longValues));
- Value booleanValues[] = {booleanValue};
+ Value booleanValues[] = new Value[] {booleanValue};
assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
"true if the property is of type Boolean and values are of type BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValues));
Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
- Value nameValues[] = {booleanValue, nameValue};
+ Value nameValues[] = new Value[] {booleanValue, nameValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Boolean and values are of type NameValue",
nodeType.canSetProperty(propDef.getName(), nameValues));
Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
- Value pathValues[] = {booleanValue, pathValue};
+ Value pathValues[] = new Value[] {booleanValue, pathValue};
assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
"false if the property is of type Boolean and values are of type PathValue",
nodeType.canSetProperty(propDef.getName(), pathValues));
@@ -208,10 +208,9 @@
"testable value constraints has been found");
}
- Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+ Value value = NodeTypeUtil.getValueAccordingToValueConstraints(propDef, false);
System.out.println(value.getString());
if (value == null) {
- // value should never be null since this is catched already in locatePropertyDef
throw new NotExecutableException("No boolean property def with " +
"testable value constraints has been found");
}
@@ -238,15 +237,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 boolean 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.",