You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/01/20 14:38:38 UTC
svn commit: r736021 - in
/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test:
AbstractJCRTest.java RepositoryStub.java
Author: angela
Date: Tue Jan 20 05:38:37 2009
New Revision: 736021
URL: http://svn.apache.org/viewvc?rev=736021&view=rev
Log:
JCR-1943: jcr-tests: make property value(s) and property type(s) configurable
Modified:
jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=736021&r1=736020&r2=736021&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java Tue Jan 20 05:38:37 2009
@@ -28,6 +28,7 @@
import javax.jcr.NamespaceException;
import javax.jcr.RangeIterator;
import javax.jcr.Value;
+import javax.jcr.ValueFactory;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NodeType;
@@ -464,6 +465,47 @@
}
/**
+ * Returns the value of the configuration property with specified
+ * <code>name</code>. If the property does not exist <code>defaultValue</code> is
+ * returned.
+ * <p/>
+ * Configuration properties are defined in the file:
+ * <code>repositoryStubImpl.properties</code>.
+ *
+ * @param name the name of the property to retrieve.
+ * @param defaultValue the default value if the property does not exist.
+ * @return the value of the property or <code>defaultValue</code> if non existent.
+ * @throws RepositoryException if the configuration file cannot be found.
+ */
+ public String getProperty(String name, String defaultValue) throws RepositoryException {
+ String val = getProperty(name);
+ if (val == null) {
+ val = defaultValue;
+ }
+ return val;
+ }
+
+ /**
+ * Create a JCR value based on the configuration.
+ *
+ * @param s
+ * @param valueProp Name of the config property that contains the property value.
+ * @param typeProp Name of the config property that contains the property type.
+ * If the config parameter is missing, {@link PropertyType#STRING} is used
+ * to create the JCR value.
+ * @param defaultValue Default value to be used if the config does not define
+ * the value property.
+ * @return JCR value to be used for a test.
+ * @throws RepositoryException
+ */
+ public Value getJcrValue(Session s, String valueProp, String typeProp, String defaultValue) throws RepositoryException {
+ ValueFactory vf = s.getValueFactory();
+ String val = getProperty(valueProp, defaultValue);
+ int type = PropertyType.valueFromName(getProperty(typeProp, PropertyType.TYPENAME_STRING));
+ return vf.createValue(val, type);
+ }
+
+ /**
* Returns the size of the <code>RangeIterator</code> <code>it</code>.
* Note, that the <code>RangeIterator</code> might get consumed, because
* {@link RangeIterator#getSize()} might return -1 (information unavailable).
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java?rev=736021&r1=736020&r2=736021&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java Tue Jan 20 05:38:37 2009
@@ -75,6 +75,26 @@
public static final String PROP_PROP_NAME2 = "propertyname2";
+ /**
+ * @since JCR 2.0
+ */
+ public static final String PROP_PROP_VALUE1 = "propertyvalue1";
+
+ /**
+ * @since JCR 2.0
+ */
+ public static final String PROP_PROP_VALUE2 = "propertyvalue2";
+
+ /**
+ * @since JCR 2.0
+ */
+ public static final String PROP_PROP_TYPE1 = "propertytype1";
+
+ /**
+ * @since JCR 2.0
+ */
+ public static final String PROP_PROP_TYPE2 = "propertytype2";
+
public static final String PROP_WORKSPACE_NAME = "workspacename";
public static final String PROP_NAMESPACES = "namespaces";
@@ -89,6 +109,12 @@
*/
public static final String PROP_LOCK_OWNER = "lock.owner";
+ /**
+ * @since JCR 2.0
+ */
+ public static final String PROP_HOLD_NAME = "holdname";
+
+
protected final Properties environment;
protected SimpleCredentials superuser;