jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r786019 - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/nodetype/ main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/
Date Thu, 18 Jun 2009 11:24:07 GMT
Author: angela
Date: Thu Jun 18 11:24:06 2009
New Revision: 786019

URL: http://svn.apache.org/viewvc?rev=786019&view=rev
Log:
JCR-2156: Usage of "qualified name" in JavaDoc and Comments

- spi-commons/nodetype/constraints package (omitted yesterday in order to avoid conflicts)

JCR-2153: Introduce QValueConstraint and change return type of QPropertyDefinition.getValueConstraints()

- introduce constants for the wildcards
- fixing creation of PathConstraint from /*
- fixing testcases (still used to previous internal form for path constraint)
- minor improvement to constraint tests in general


Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java Thu Jun 18 11:24:06 2009
@@ -44,8 +44,8 @@
 import org.apache.jackrabbit.spi.commons.value.QValueValue;
 
 /**
- * <code>NodeTypeDefinitionFactory</code> can be used to convert the qualified
- * node type definitions to JCR {@link NodeTypeDefinition}s.
+ * <code>NodeTypeDefinitionFactory</code> can be used to convert the internal
+ * SPI node type definitions to JCR {@link NodeTypeDefinition}s.
  */
 public class NodeTypeDefinitionFactory {
 
@@ -57,8 +57,8 @@
      * Creates a new node type definition factory that operates on the given
      * sesion to create the templates.
      *
-     * @param session repository session
-     * @throws RepositoryException if an error occurs
+     * @param session repository session.
+     * @throws RepositoryException if an error occurs.
      */
     public NodeTypeDefinitionFactory(Session session)
             throws RepositoryException {
@@ -67,11 +67,12 @@
     }
 
     /**
-     * Create a new node type definitions from a qualified ones.
+     * Create a list of {@link NodeTypeDefinition JCR node type definitions}
+     * from a collection of {@link QNodeTypeDefinition}.
      *
-     * @param defs the qualified node type definitions
-     * @return the JCR node type definitions
-     * @throws RepositoryException if an error occurs
+     * @param defs the SPI node type definitions.
+     * @return the JCR node type definitions.
+     * @throws RepositoryException if an error occurs.
      */
     public List<NodeTypeDefinition> create(Collection<QNodeTypeDefinition> defs)
             throws RepositoryException {
@@ -83,11 +84,12 @@
     }
 
     /**
-     * Create a new node type definition from a qualified one.
+     * Create a new JCR node type definition from the given
+     * <code>QNodeTypeDefinition</code>.
      *
-     * @param qNtd the qualified node type definition
-     * @return the JCR node type definition
-     * @throws RepositoryException if an error occurs
+     * @param qNtd A SPI node type definition.
+     * @return the corresponding JCR node type definition.
+     * @throws RepositoryException if an error occurs.
      */
     @SuppressWarnings("unchecked")
     public NodeTypeDefinition create(QNodeTypeDefinition qNtd)
@@ -112,11 +114,11 @@
     }
 
     /**
-     * Create a new node definition from a qualified one.
+     * Create a new JCR node definition from the given <code>QNodeDefinition</code>.
      *
-     * @param qNd the qualified node definition
-     * @return the JCR node definition
-     * @throws RepositoryException if an error occurs
+     * @param qNd A node definition.
+     * @return The corresponding JCR node definition.
+     * @throws RepositoryException if an error occurs.
      */
     public NodeDefinition create(QNodeDefinition qNd)
             throws RepositoryException {
@@ -133,11 +135,11 @@
     }
 
     /**
-     * Create a new property definition from a qualified one.
+     * Create a new JCR property definition from the given <code>QPropertyDefinition</code>.
      *
-     * @param qPd the qualified propert definition
-     * @return the JCR property definition
-     * @throws RepositoryException if an error occurs
+     * @param qPd A SPI property definition.
+     * @return the corresponding JCR property definition.
+     * @throws RepositoryException if an error occurs.
      */
     public PropertyDefinition create(QPropertyDefinition qPd) throws RepositoryException {
         PropertyDefinitionTemplate pt = ntMgr.createPropertyDefinitionTemplate();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java Thu Jun 18 11:24:06 2009
@@ -47,7 +47,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java Thu Jun 18 11:24:06 2009
@@ -141,7 +141,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java Thu Jun 18 11:24:06 2009
@@ -35,36 +35,36 @@
 
     private final Name name;
 
-    static NameConstraint create(String qualifiedDefinition) {
-        // constraint format: String representation of qualified name
-        return new NameConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
+    static NameConstraint create(String nameString) {
+        // constraint format: String representation of a Name object
+        return new NameConstraint(nameString, NAME_FACTORY.create(nameString));
     }
 
-    static NameConstraint create(String definition, NameResolver resolver)
+    static NameConstraint create(String jcrName, NameResolver resolver)
             throws InvalidConstraintException {
-        // constraint format: JCR name in prefix form
+        // constraint format: A JCR name string.
         try {
-            Name name = resolver.getQName(definition);
+            Name name = resolver.getQName(jcrName);
             return new NameConstraint(name.toString(), name);
         } catch (NameException e) {
-            String msg = "Invalid name constraint: " + definition;
+            String msg = "Invalid name constraint: " + jcrName;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         } catch (NamespaceException e) {
-            String msg = "Invalid name constraint: " + definition;
+            String msg = "Invalid name constraint: " + jcrName;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         }
     }
 
-    private NameConstraint(String qualifiedDefinition, Name name) {
-        super(qualifiedDefinition);
+    private NameConstraint(String nameString, Name name) {
+        super(nameString);
         this.name = name;
     }
 
     /**
      * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
-     * qualified <code>Name</code> into a JCR name.
+     * <code>Name</code> identifying this constraint into a JCR name String.
      *
      * @see ValueConstraint#getDefinition(NamePathResolver)
      * @param resolver name-path resolver
@@ -79,7 +79,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java Thu Jun 18 11:24:06 2009
@@ -129,7 +129,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java Thu Jun 18 11:24:06 2009
@@ -23,6 +23,7 @@
 
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.PathFactory;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
@@ -35,63 +36,72 @@
  */
 class PathConstraint extends ValueConstraint {
 
+    static final String WILDCARD = Path.DELIMITER + NameConstants.ANY_NAME.toString();
+    static final String JCR_WILDCARD = "/*";
+    // TODO improve. don't rely on a specific factory impl
+    private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
+
     private final Path path;
     private final boolean deep;
 
-    static PathConstraint create(String qualifiedDefinition) throws InvalidConstraintException {
-        // constraint format: qualified absolute or relative path with optional trailing wildcard
-        boolean deep = qualifiedDefinition.endsWith("\t{}*");
-        Path path;
-        // TODO improve. don't rely on a specific factory impl
-        if (deep) {
-            path = PathFactoryImpl.getInstance().create(qualifiedDefinition.substring(0, qualifiedDefinition.length() - 4));
+    static PathConstraint create(String pathString) throws InvalidConstraintException {
+        // constraint format: String representation of an absolute or relative
+        // Path object with optionally having a trailing wildcard
+        if (WILDCARD.equals(pathString)) {
+            return new PathConstraint(pathString, PATH_FACTORY.getRootPath(), true);
         } else {
-            path = PathFactoryImpl.getInstance().create(qualifiedDefinition);
+            boolean deep = pathString.endsWith(WILDCARD);
+            Path path;
+            if (deep) {
+                path = PATH_FACTORY.create(pathString.substring(0, pathString.length() - WILDCARD.length()));
+            } else {
+                path = PATH_FACTORY.create(pathString);
+            }
+            return new PathConstraint(pathString, path, deep);
         }
-        return new PathConstraint(qualifiedDefinition, path, deep);
     }
 
-    static PathConstraint create(String definition, PathResolver resolver)
+    static PathConstraint create(String jcrPath, PathResolver resolver)
             throws InvalidConstraintException {
         try {
             // constraint format: absolute or relative path with optional
             // trailing wildcard
-            boolean deep = definition.endsWith("/*");
-            if (deep) {
-                // trim trailing wildcard before building path
-                if (definition.equals("/*")) {
-                    definition = "/";
-                } else {
-                    definition = definition.substring(0, definition.length() - 2);
+            boolean deep = jcrPath.endsWith(JCR_WILDCARD);
+            Path path;
+            if (JCR_WILDCARD.equals(jcrPath)) {
+                path = PATH_FACTORY.getRootPath();
+            } else {
+                if (deep) {
+                    // trim trailing wildcard before building path
+                    jcrPath = jcrPath.substring(0, jcrPath.length() - JCR_WILDCARD.length());
                 }
+                path = resolver.getQPath(jcrPath);
             }
-            Path path = resolver.getQPath(definition);
-            StringBuffer qualifiedDefinition = new StringBuffer(path.getString());
+            StringBuffer definition = new StringBuffer(path.getString());
             if (deep) {
-                qualifiedDefinition.append(Path.DELIMITER);
-                qualifiedDefinition.append(NameConstants.ANY_NAME);
+                definition.append(WILDCARD);
             }
-            return new PathConstraint(qualifiedDefinition.toString(), path, deep);
+            return new PathConstraint(definition.toString(), path, deep);
         } catch (NameException e) {
-            String msg = "Invalid path expression specified as value constraint: " + definition;
+            String msg = "Invalid path expression specified as value constraint: " + jcrPath;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         } catch (NamespaceException e) {
-            String msg = "Invalid path expression specified as value constraint: " + definition;
+            String msg = "Invalid path expression specified as value constraint: " + jcrPath;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         }
     }
 
-    private PathConstraint(String qualifiedDefinition, Path path, boolean deep) throws InvalidConstraintException {
-        super(qualifiedDefinition);
+    private PathConstraint(String pathString, Path path, boolean deep) throws InvalidConstraintException {
+        super(pathString);
         this.path = path;
         this.deep = deep;
     }
 
     /**
      * Uses {@link NamePathResolver#getJCRPath(Path)} to convert the
-     * qualified <code>Path</code> into a JCR path.
+     * <code>Path</code> present with this constraint into a JCR path.
      *
      * @see ValueConstraint#getDefinition(NamePathResolver)
      * @param resolver name-path resolver
@@ -113,7 +123,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java Thu Jun 18 11:24:06 2009
@@ -35,36 +35,36 @@
 
     private final Name ntName;
 
-    static ReferenceConstraint create(String qualifiedDefinition) {
-        // constraint format: String representation of qualified name
-        return new ReferenceConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
+    static ReferenceConstraint create(String nameString) {
+        // constraint format: String representation of Name object.
+        return new ReferenceConstraint(nameString, NAME_FACTORY.create(nameString));
     }
 
-    static ReferenceConstraint create(String definition, NameResolver resolver)
+    static ReferenceConstraint create(String jcrName, NameResolver resolver)
             throws InvalidConstraintException {
         // constraint format: JCR name in prefix form
         try {
-            Name name = resolver.getQName(definition);
+            Name name = resolver.getQName(jcrName);
             return new ReferenceConstraint(name.toString(), name);
         } catch (NameException e) {
-            String msg = "Invalid name constraint: " + definition;
+            String msg = "Invalid name constraint: " + jcrName;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         } catch (NamespaceException e) {
-            String msg = "Invalid name constraint: " + definition;
+            String msg = "Invalid name constraint: " + jcrName;
             log.debug(msg);
             throw new InvalidConstraintException(msg, e);
         }
     }
 
-    private ReferenceConstraint(String qualifiedDefinition, Name ntName) {
-        super(qualifiedDefinition);
+    private ReferenceConstraint(String nameString, Name ntName) {
+        super(nameString);
         this.ntName = ntName;
     }
 
     /**
-     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
-     * qualified <code>Name</code> into a JCR name.
+     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the node type
+     * <code>Name</code> present with this constraint into a JCR name String.
      *
      * @see ValueConstraint#getDefinition(NamePathResolver)
      * @param resolver name-path resolver
@@ -79,7 +79,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {
@@ -99,5 +99,4 @@
                 throw new RepositoryException(msg);
         }
     }
-
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java Thu Jun 18 11:24:06 2009
@@ -48,7 +48,7 @@
     }
 
     /**
-     * @see ValueConstraint#check(QValue)
+     * @see org.apache.jackrabbit.spi.QValueConstraint#check(QValue)
      */
     public void check(QValue value) throws ConstraintViolationException, RepositoryException {
         if (value == null) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java Thu Jun 18 11:24:06 2009
@@ -45,10 +45,10 @@
     // TODO improve. don't rely on a specific factory impl
     static final NameFactory NAME_FACTORY = NameFactoryImpl.getInstance();
 
-    private final String qualifiedDefinition;
+    private final String definition;
 
-    protected ValueConstraint(String qualifiedDefinition) {
-        this.qualifiedDefinition = qualifiedDefinition;
+    protected ValueConstraint(String definition) {
+        this.definition = definition;
     }
 
     /**
@@ -60,49 +60,44 @@
      * <code>ReferenceConstraint</code>) use the given <code>nsResolver</code>
      * to reflect the current mapping in the returned value.
      * In other words: subclasses, that need to make a conversion to JCR value
-     * must overwrite this and return a value that has all qualified names
-     * and path elements resolved.
+     * must overwrite this and return a value that has the <code>Name</code>s
+     * or <code>Path</code> properly resolved to their JCR representation.
      *
      * @return the definition of this constraint.
      * @see #getString ()
      * @param resolver name-path resolver
+     * @see NamePathResolver#getJCRName(org.apache.jackrabbit.spi.Name)
+     * @see NamePathResolver#getJCRPath(org.apache.jackrabbit.spi.Path) 
      */
     public String getDefinition(NamePathResolver resolver) {
-        return qualifiedDefinition;
+        return definition;
     }
 
+    //---------------------------------------------------< QValueConstraint >---
     /**
-     * By default the qualified definition is the same as the JCR definition.
-     *
-     * @return the internal definition String
-     */
+     * @see org.apache.jackrabbit.spi.QValueConstraint#getString()
+     */ 
     public String getString() {
-        return qualifiedDefinition;
+        return definition;
     }
 
+    //---------------------------------------------------< java.lang.Object >---
     /**
      * Same as {@link #getString()}
      * @return the internal definition String
+     * @see Object#toString()
      */
     public String toString() {
         return getString();
     }
 
     /**
-     * Check if the specified value matches the this constraint.
-     *
-     * @param value The value to be tested.
-     * @throws ConstraintViolationException If the specified value is
-     * <code>null</code> or does not matches the constraint.
-     * @throws RepositoryException If another error occurs.
+     * @see Object#equals(Object)
      */
-    public abstract void check(QValue value) throws ConstraintViolationException, RepositoryException;
-
-    //---------------------------------------------------< java.lang.Object >---
     public boolean equals(Object other) {
         return other == this
                 || other instanceof ValueConstraint
-                && qualifiedDefinition.equals(((ValueConstraint) other).qualifiedDefinition);
+                && definition.equals(((ValueConstraint) other).definition);
     }
 
     /**
@@ -112,55 +107,61 @@
      * @see Object#hashCode()
      */
     public int hashCode() {
-        return qualifiedDefinition.hashCode();
+        return definition.hashCode();
     }
 
     //-----------------------------------< static factory and check methods >---
     /**
      * Create a new <code>ValueConstraint</code> from the String representation.
-     * Note, that the definition must be in the qualified format in case the type
-     * indicates {@link PropertyType#NAME}, {@link PropertyType#PATH} or {@link PropertyType#REFERENCE}
+     * Note, that the definition must be independant of session specific namespace
+     * mappings in case of the following constraint types:
+     * <ul><li>{@link PropertyType#NAME},</li>
+     * <li>{@link PropertyType#PATH} or</li>
+     * <li>{@link PropertyType#REFERENCE}</li>
+     * </ul>
      *
      * @param type required type
-     * @param qualifiedDefinition internal definition string
+     * @param definition The internal definition string.
      * @return a new value constraint
-     * @throws InvalidConstraintException if the constraint is not valid
+     * @throws InvalidConstraintException if the constraint is not valid.
+     * @see #create(int, String, NamePathResolver) for the corresponding
+     * method that allows to pass the JCR representation of a constraint
+     * definition.
      */
-    public static ValueConstraint create(int type, String qualifiedDefinition)
+    public static ValueConstraint create(int type, String definition)
         throws InvalidConstraintException {
-        if (qualifiedDefinition == null) {
+        if (definition == null) {
             throw new IllegalArgumentException("illegal definition (null)");
         }
         switch (type) {
             // constraints which are not qName sensitive
             case PropertyType.STRING:
             case PropertyType.URI:
-                return new StringConstraint(qualifiedDefinition);
+                return new StringConstraint(definition);
 
             case PropertyType.BOOLEAN:
-                return new BooleanConstraint(qualifiedDefinition);
+                return new BooleanConstraint(definition);
 
             case PropertyType.BINARY:
-                return new NumericConstraint(qualifiedDefinition);
+                return new NumericConstraint(definition);
 
             case PropertyType.DATE:
-                return new DateConstraint(qualifiedDefinition);
+                return new DateConstraint(definition);
 
             case PropertyType.LONG:
             case PropertyType.DOUBLE:
             case PropertyType.DECIMAL:
-                return new NumericConstraint(qualifiedDefinition);
+                return new NumericConstraint(definition);
 
-            // qName sensitive constraints: create from qualified string
             case PropertyType.NAME:
-                return NameConstraint.create(qualifiedDefinition);
+                return NameConstraint.create(definition);
 
             case PropertyType.PATH:
-                return PathConstraint.create(qualifiedDefinition);
+                return PathConstraint.create(definition);
 
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
-                return ReferenceConstraint.create(qualifiedDefinition);
+                return ReferenceConstraint.create(definition);
 
             default:
                 throw new IllegalArgumentException("unknown/unsupported target type for constraint: "
@@ -169,44 +170,49 @@
     }
 
     /**
-     * Create a new <code>ValueConstraint</code> array from the String representation.
-     * Note, that the definition must be in the qualified format in case the type
-     * indicates {@link PropertyType#NAME}, {@link PropertyType#PATH} or {@link PropertyType#REFERENCE}
+     * Create a new <code>ValueConstraint</code> array from the String
+     * representation. Note, that the definition must be in the internal format
+     * in case of the following types:
+     * <ul><li>{@link PropertyType#NAME},</li>
+     * <li>{@link PropertyType#PATH} or</li>
+     * <li>{@link PropertyType#REFERENCE}</li>
+     * </ul>
      *
      * @param type the required type
-     * @param qualifiedDefinition internal definition strings
+     * @param definition internal definition strings
      * @return the array of constraints
      * @throws InvalidConstraintException if one of the constraints is invalid
      */
-    public static ValueConstraint[] create(int type, String[] qualifiedDefinition)
+    public static ValueConstraint[] create(int type, String[] definition)
             throws InvalidConstraintException {
-        if (qualifiedDefinition == null || qualifiedDefinition.length == 0) {
+        if (definition == null || definition.length == 0) {
             return ValueConstraint.EMPTY_ARRAY;
         }
-        ValueConstraint[] ret = new ValueConstraint[qualifiedDefinition.length];
+        ValueConstraint[] ret = new ValueConstraint[definition.length];
         for (int i=0; i<ret.length; i++) {
-            ret[i] = ValueConstraint.create(type, qualifiedDefinition[i]);
+            ret[i] = ValueConstraint.create(type, definition[i]);
         }
         return ret;
     }
 
     /**
-     * Create a new <code>ValueConstraint</code> array from the JCR representation.
+     * Create a new <code>ValueConstraint</code> array from the specified JCR
+     * representations.
      *
      * @param type the required type
-     * @param definition definition strings
+     * @param jcrDefinition The definition strings as exposed through the JCR API.
      * @param resolver name-path resolver
      * @return the array of constraints
      * @throws InvalidConstraintException if one of the constraints is invalid
      */
-    public static ValueConstraint[] create(int type, String definition[], NamePathResolver resolver)
+    public static ValueConstraint[] create(int type, String jcrDefinition[], NamePathResolver resolver)
             throws InvalidConstraintException {
-        if (definition == null || definition.length == 0) {
+        if (jcrDefinition == null || jcrDefinition.length == 0) {
             return ValueConstraint.EMPTY_ARRAY;
         }
-        ValueConstraint[] ret = new ValueConstraint[definition.length];
+        ValueConstraint[] ret = new ValueConstraint[jcrDefinition.length];
         for (int i=0; i<ret.length; i++) {
-            ret[i] = ValueConstraint.create(type, definition[i], resolver);
+            ret[i] = ValueConstraint.create(type, jcrDefinition[i], resolver);
         }
         return ret;
     }
@@ -214,45 +220,45 @@
     /**
      *
      * @param type required type
-     * @param definition JCR definition
+     * @param jcrDefinition A JCR representation of a value constraint definition.
      * @param resolver name-path resolver
      * @return a new value constraint
      * @throws InvalidConstraintException if the constraint is invalid
      */
-    public static ValueConstraint create(int type, String definition,
+    public static ValueConstraint create(int type, String jcrDefinition,
                                          NamePathResolver resolver)
             throws InvalidConstraintException {
-        if (definition == null) {
+        if (jcrDefinition == null) {
             throw new IllegalArgumentException("Illegal definition (null) for ValueConstraint.");
         }
         switch (type) {
             case PropertyType.STRING:
             case PropertyType.URI:
-                return new StringConstraint(definition);
+                return new StringConstraint(jcrDefinition);
 
             case PropertyType.BOOLEAN:
-                return new BooleanConstraint(definition);
+                return new BooleanConstraint(jcrDefinition);
 
             case PropertyType.BINARY:
-                return new NumericConstraint(definition);
+                return new NumericConstraint(jcrDefinition);
 
             case PropertyType.DATE:
-                return new DateConstraint(definition);
+                return new DateConstraint(jcrDefinition);
 
             case PropertyType.LONG:
             case PropertyType.DOUBLE:
             case PropertyType.DECIMAL:
-                return new NumericConstraint(definition);
+                return new NumericConstraint(jcrDefinition);
 
             case PropertyType.NAME:
-                return NameConstraint.create(definition, resolver);
+                return NameConstraint.create(jcrDefinition, resolver);
 
             case PropertyType.PATH:
-                return PathConstraint.create(definition, resolver);
+                return PathConstraint.create(jcrDefinition, resolver);
 
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
-                return ReferenceConstraint.create(definition, resolver);
+                return ReferenceConstraint.create(jcrDefinition, resolver);
 
             default:
                 throw new IllegalArgumentException("Unknown/unsupported target type for constraint: " + PropertyType.nameFromValue(type));

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -43,7 +43,7 @@
         return PropertyType.BOOLEAN;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() {
+    protected String[] getInvalidQDefinitions() {
         return new String[] {"test", "/abc/d", "12345"};
     }
 
@@ -51,7 +51,7 @@
         return new String[] { Boolean.TRUE.toString()};
     }
 
-    protected String[] getQualifiedDefinitions() {
+    protected String[] getQDefinitions() {
         return getDefinitions();
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -37,7 +37,7 @@
         return PropertyType.DATE;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() {
+    protected String[] getInvalidQDefinitions() {
         return new String[] {"abc", "-18", "1234567"};
     }
 
@@ -57,7 +57,7 @@
         return new String[] {b.toString()};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return getDefinitions();
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -34,7 +34,7 @@
         return PropertyType.NAME;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() {
+    protected String[] getInvalidQDefinitions() {
         return new String[] {"12345", "", "abc"};
     }
 
@@ -42,7 +42,7 @@
         return new String[] {"12345", "abc", "jcr:abc"};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return new String[] {
                 resolver.getQName("12345").toString(),
                 resolver.getQName("abc").toString(),
@@ -59,5 +59,14 @@
         return valueFactory.create(resolver.getQPath("xyz"));
     }
 
-    // TODO: add more
+    public void testGetDefinition() throws RepositoryException {
+        String[] qDefs = getQDefinitions();
+        for (int i = 0; i < qDefs.length; i++) {
+            ValueConstraint vc = createValueConstraint(qDefs[i]);
+            String jcrConstraint = vc.getDefinition(resolver);
+
+            assertFalse(qDefs[i].equals(jcrConstraint));
+            assertEquals(resolver.getJCRName(ValueConstraint.NAME_FACTORY.create(qDefs[i])), jcrConstraint);
+        }
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -46,7 +46,7 @@
         return PropertyType.DOUBLE;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() throws RepositoryException {
+    protected String[] getInvalidQDefinitions() throws RepositoryException {
         return new String[] {"test", resolver.getQPath("/a/b/jcr:c").getString(), "true"};
     }
 
@@ -54,7 +54,7 @@
         return new String[] {"(25, 48.5)", "[0,27)", "(, 74)", "(73, 74.9]"};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return getDefinitions();
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -37,7 +37,7 @@
         return PropertyType.PATH;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
+    protected String[] getInvalidQDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
         return new String[] {"12345", "*"};
     }
 
@@ -45,12 +45,12 @@
         return new String[] {"/abc/*", "/", "abc/*", "/*", "/abc/def"};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return new String[] {
-                resolver.getQPath("/abc").getString() + "/*",
+                resolver.getQPath("/abc").getString() + PathConstraint.WILDCARD,
                 resolver.getQPath("/").getString(),
-                resolver.getQPath("abc").getString() + "/*",
-                resolver.getQPath("/").getString() + "*",
+                resolver.getQPath("abc").getString() + PathConstraint.WILDCARD,
+                PathConstraint.WILDCARD,
                 resolver.getQPath("/abc/def").getString()};
     }
 
@@ -65,5 +65,14 @@
         return valueFactory.create(23);
     }
 
-    // TODO: add more
+    public void testGetDefinition() throws RepositoryException {
+        String[] qDefs = getQDefinitions();
+        for (int i = 0; i < qDefs.length; i++) {
+            ValueConstraint vc = createValueConstraint(qDefs[i]);
+            String jcrConstraint = vc.getDefinition(resolver);
+
+            assertFalse(qDefs[i].equals(jcrConstraint));
+            assertTrue(getDefinitions()[i].equals(jcrConstraint));
+        }
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -38,7 +38,7 @@
         return PropertyType.REFERENCE;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
+    protected String[] getInvalidQDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
         return new String[] {"12345", "", "abc"};
     }
 
@@ -46,7 +46,7 @@
         return new String[] {"12345", "abc", "jcr:abc"};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return new String[] {
                 resolver.getQName("12345").toString(),
                 resolver.getQName("abc").toString(),
@@ -67,5 +67,14 @@
         // not executable
     }
 
-    // TODO: add more
+    public void testGetDefinition() throws RepositoryException {
+        String[] qDefs = getQDefinitions();
+        for (int i = 0; i < qDefs.length; i++) {
+            ValueConstraint vc = createValueConstraint(qDefs[i]);
+            String jcrConstraint = vc.getDefinition(resolver);
+
+            assertFalse(qDefs[i].equals(jcrConstraint));
+            assertEquals(resolver.getJCRName(ValueConstraint.NAME_FACTORY.create(qDefs[i])), jcrConstraint);
+        }
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -49,7 +49,7 @@
         return PropertyType.STRING;
     }
 
-    protected String[] getInvalidQualifiedDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
+    protected String[] getInvalidQDefinitions() throws NamespaceException, IllegalNameException, MalformedPathException {
         return new String[] {"[abc"};
     }
 
@@ -57,7 +57,7 @@
         return new String[] {"[abc] constraint", "abc"};
     }
 
-    protected String[] getQualifiedDefinitions() throws RepositoryException {
+    protected String[] getQDefinitions() throws RepositoryException {
         return getDefinitions();
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java?rev=786019&r1=786018&r2=786019&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java Thu Jun 18 11:24:06 2009
@@ -57,18 +57,18 @@
 
     protected abstract int getType();
 
-    protected abstract String[] getInvalidQualifiedDefinitions() throws RepositoryException;
+    protected abstract String[] getInvalidQDefinitions() throws RepositoryException;
 
     protected abstract String[] getDefinitions() throws RepositoryException;
 
-    protected abstract String[] getQualifiedDefinitions() throws RepositoryException;
+    protected abstract String[] getQDefinitions() throws RepositoryException;
 
     protected abstract QValue[] createNonMatchingValues() throws RepositoryException;
 
     protected abstract QValue createOtherValueType() throws RepositoryException;
 
 
-    private ValueConstraint createValueConstraint(String qDefinition) throws RepositoryException {
+    protected ValueConstraint createValueConstraint(String qDefinition) throws RepositoryException {
         return ValueConstraint.create(getType(), qDefinition);
     }
 
@@ -95,7 +95,7 @@
     }
 
     public void testCreateValueConstraints2() throws RepositoryException {
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
             assertEquals(qDefs[i], vc.getString());
@@ -104,7 +104,7 @@
 
     public void testCreateInvalidValueConstraints() throws RepositoryException {
         try {
-            String[] invalidQDefs = getInvalidQualifiedDefinitions();
+            String[] invalidQDefs = getInvalidQDefinitions();
             for (int i = 0; i < invalidQDefs.length; i++) {
                 createValueConstraint(invalidQDefs[i]);
                 fail("Creating an invalid definition should throw InvalidConstraintException");
@@ -117,23 +117,25 @@
     }
 
     public void testGetDefinition() throws RepositoryException {
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
-            assertNotNull(vc.getDefinition(resolver));
+            String jcrConstraint = vc.getDefinition(resolver);
+            assertNotNull(jcrConstraint);
+            assertEquals(qDefs[i], jcrConstraint);
         }
     }
 
-    public void testGetQualifiedDefinition() throws RepositoryException {
-        String[] qDefs = getQualifiedDefinitions();
+    public void testGetString() throws RepositoryException {
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
-            assertNotNull(vc.getString());
+            assertEquals(qDefs[i], vc.getString());
         }
     }
 
     public void testCheckNullValue() throws RepositoryException {
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
             try {
@@ -148,7 +150,7 @@
     public void testCheckNonMatchingValue() throws RepositoryException {
         QValue[] nonMatching = createNonMatchingValues();
 
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             if (i >= nonMatching.length) {
                 break;
@@ -166,7 +168,7 @@
 
     public void testCheckWrongValueType() throws RepositoryException {
         QValue val = createOtherValueType();
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
             try {
@@ -179,7 +181,7 @@
     }
 
     public void testEquals() throws RepositoryException {
-        String[] qDefs = getQualifiedDefinitions();
+        String[] qDefs = getQDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
             ValueConstraint vc2 = createValueConstraint(qDefs[i]);



Mime
View raw message