You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2009/05/05 16:04:30 UTC
svn commit: r771732 - in
/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom:
AbstractQOMTest.java BindVariableValueTest.java LengthTest.java
NodeLocalNameTest.java NodeNameTest.java UpperLowerCaseTest.java
Author: reschke
Date: Tue May 5 14:04:29 2009
New Revision: 771732
URL: http://svn.apache.org/viewvc?rev=771732&view=rev
Log:
JCR-2085: remove dependencies on SPI Operator enum
Modified:
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractQOMTest.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/BindVariableValueTest.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/LengthTest.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeLocalNameTest.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeNameTest.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractQOMTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractQOMTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractQOMTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/AbstractQOMTest.java Tue May 5 14:04:29 2009
@@ -38,6 +38,11 @@
*/
public class AbstractQOMTest extends AbstractQueryTest {
+ // Constants broken in JCR 2.0 PFD
+ // TODO remove when API is fixed
+ protected static String JCR_OPERATOR_EQUAL_TO = "{http://www.jcp.org/jcr/1.0}operatorEqualTo";
+ protected static String JCR_OPERATOR_NOT_EQUAL_TO = "{http://www.jcp.org/jcr/1.0}operatorNotEqualTo";
+
protected QueryObjectModelFactory qomFactory;
protected void setUp() throws Exception {
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/BindVariableValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/BindVariableValueTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/BindVariableValueTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/BindVariableValueTest.java Tue May 5 14:04:29 2009
@@ -16,16 +16,14 @@
*/
package org.apache.jackrabbit.api.jsr283.query.qom;
-import javax.jcr.RepositoryException;
+import java.util.Calendar;
+
import javax.jcr.Node;
-import javax.jcr.ValueFactory;
+import javax.jcr.RepositoryException;
import javax.jcr.Value;
+import javax.jcr.ValueFactory;
import javax.jcr.query.Query;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
-
-import java.util.Calendar;
-
/**
* <code>BindVariableValueTest</code>...
*/
@@ -52,9 +50,9 @@
qomFactory.selector(testNodeType, "s"),
qomFactory.and(
qomFactory.childNode("s", testRoot),
- Operator.EQ.comparison(
- qomFactory,
+ qomFactory.comparison(
qomFactory.propertyValue("s", propertyName1),
+ AbstractQOMTest.JCR_OPERATOR_EQUAL_TO,
qomFactory.bindVariable("v")
)
), null, null);
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/LengthTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/LengthTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/LengthTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/LengthTest.java Tue May 5 14:04:29 2009
@@ -16,20 +16,20 @@
*/
package org.apache.jackrabbit.api.jsr283.query.qom;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Calendar;
+import org.apache.jackrabbit.test.NotExecutableException;
import javax.jcr.Node;
-import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
-import javax.jcr.query.InvalidQueryException;
+import javax.jcr.PropertyType;
import javax.jcr.query.QueryResult;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.qom.QueryObjectModelConstants;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
-import org.apache.jackrabbit.test.NotExecutableException;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Calendar;
/**
* <code>LengthTest</code> performs tests with the Query Object Model length
@@ -132,7 +132,7 @@
node.save();
String length = String.valueOf(node.getProperty(propertyName1).getLength());
- executeQuery(propertyName1, Operator.EQ, vf.createValue(length));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(length));
}
public void testLengthBinaryLiteral() throws RepositoryException {
@@ -141,7 +141,7 @@
String length = String.valueOf(node.getProperty(propertyName1).getLength());
InputStream in = new ByteArrayInputStream(length.getBytes());
- executeQuery(propertyName1, Operator.EQ, vf.createValue(in));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(in));
}
public void testLengthDoubleLiteral() throws RepositoryException {
@@ -149,7 +149,7 @@
node.save();
double length = node.getProperty(propertyName1).getLength();
- executeQuery(propertyName1, Operator.EQ, vf.createValue(length));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(length));
}
public void testLengthDateLiteral() throws RepositoryException {
@@ -158,12 +158,12 @@
Calendar length = Calendar.getInstance();
length.setTimeInMillis(node.getProperty(propertyName1).getLength());
- executeQuery(propertyName1, Operator.EQ, vf.createValue(length));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(length));
}
public void testLengthBooleanLiteral() throws RepositoryException {
try {
- executeQuery(propertyName1, Operator.EQ, vf.createValue(false));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(false));
fail("Boolean literal cannot be converted to long");
} catch (InvalidQueryException e) {
// expected
@@ -172,7 +172,7 @@
public void testLengthNameLiteral() throws RepositoryException {
try {
- executeQuery(propertyName1, Operator.EQ, vf.createValue(
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(
propertyName1, PropertyType.NAME));
fail("Name literal cannot be converted to long");
} catch (InvalidQueryException e) {
@@ -182,7 +182,7 @@
public void testLengthPathLiteral() throws RepositoryException {
try {
- executeQuery(propertyName1, Operator.EQ, vf.createValue(
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(
node.getPath(), PropertyType.PATH));
fail("Path literal cannot be converted to long");
} catch (InvalidQueryException e) {
@@ -200,7 +200,7 @@
throw new NotExecutableException("Cannot add mix:referenceable to node");
}
try {
- executeQuery(propertyName1, Operator.EQ, vf.createValue(node));
+ executeQuery(propertyName1, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, vf.createValue(node));
fail("Reference literal cannot be converted to long");
} catch (InvalidQueryException e) {
// expected
@@ -223,27 +223,27 @@
private void checkOperators(String propertyName,
long length) throws RepositoryException {
- checkLength(propertyName, Operator.EQ, length, true);
- checkLength(propertyName, Operator.EQ, length - 1, false);
+ checkLength(propertyName, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, length, true);
+ checkLength(propertyName, AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, length - 1, false);
- checkLength(propertyName, Operator.GT, length - 1, true);
- checkLength(propertyName, Operator.GT, length, false);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, length - 1, true);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, length, false);
- checkLength(propertyName, Operator.GE, length, true);
- checkLength(propertyName, Operator.GE, length + 1, false);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, length, true);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, length + 1, false);
- checkLength(propertyName, Operator.LT, length + 1, true);
- checkLength(propertyName, Operator.LT, length, false);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, length + 1, true);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, length, false);
- checkLength(propertyName, Operator.LE, length, true);
- checkLength(propertyName, Operator.LE, length - 1, false);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, length, true);
+ checkLength(propertyName, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, length - 1, false);
- checkLength(propertyName, Operator.NE, length - 1, true);
- checkLength(propertyName, Operator.NE, length, false);
+ checkLength(propertyName, AbstractQOMTest.JCR_OPERATOR_NOT_EQUAL_TO, length - 1, true);
+ checkLength(propertyName, AbstractQOMTest.JCR_OPERATOR_NOT_EQUAL_TO, length, false);
}
private void checkLength(String propertyName,
- Operator operator,
+ String operator,
long length,
boolean matches) throws RepositoryException {
Node[] result;
@@ -256,25 +256,26 @@
}
private QueryResult executeQuery(String propertyName,
- Operator operator,
+ String operator,
long length) throws RepositoryException {
Value v = vf.createValue(length);
return executeQuery(propertyName, operator, v);
}
private QueryResult executeQuery(String propertyName,
- Operator operator,
+ String operator,
Value length) throws RepositoryException {
return qomFactory.createQuery(
qomFactory.selector(testNodeType, "s"),
qomFactory.and(
qomFactory.childNode("s", testRoot),
- operator.comparison(
- qomFactory,
+ qomFactory.comparison(
qomFactory.length(
qomFactory.propertyValue(
"s", propertyName)),
+ operator,
qomFactory.literal(length))
+
), null, null).execute();
}
}
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeLocalNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeLocalNameTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeLocalNameTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeLocalNameTest.java Tue May 5 14:04:29 2009
@@ -16,15 +16,14 @@
*/
package org.apache.jackrabbit.api.jsr283.query.qom;
-import java.util.Calendar;
-
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
import javax.jcr.query.Query;
+import javax.jcr.query.qom.QueryObjectModelConstants;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import java.util.Calendar;
/**
* <code>NodeLocalNameTest</code> checks if conversion of literals is correctly
@@ -56,32 +55,32 @@
public void testStringLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(nodeLocalName);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testStringLiteralInvalidName() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue("[" + nodeLocalName);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
public void testBinaryLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeLocalName, PropertyType.BINARY);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testDateLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(Calendar.getInstance());
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
public void testDoubleLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(Math.PI);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
@@ -91,37 +90,37 @@
public void testLongLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(283);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
public void testBooleanLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(true);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
public void testNameLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeLocalName, PropertyType.NAME);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testPathLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeLocalName, PropertyType.PATH);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
literal = superuser.getValueFactory().createValue(
node1.getPath(), PropertyType.PATH);
- q = createQuery(Operator.EQ, literal);
+ q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
literal = superuser.getValueFactory().createValue(
nodeName1 + "/" + nodeName1, PropertyType.PATH);
- q = createQuery(Operator.EQ, literal);
+ q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
@@ -131,7 +130,7 @@
}
node1.save();
Value literal = superuser.getValueFactory().createValue(node1);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{});
}
@@ -144,36 +143,36 @@
}
public void testEqualTo() throws RepositoryException {
- checkOperator(Operator.EQ, false, true, false);
+ checkOperator(AbstractQOMTest.JCR_OPERATOR_EQUAL_TO, false, true, false);
}
public void testGreaterThan() throws RepositoryException {
- checkOperator(Operator.GT, true, false, false);
+ checkOperator(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, true, false, false);
}
public void testGreaterThanOrEqualTo() throws RepositoryException {
- checkOperator(Operator.GE, true, true, false);
+ checkOperator(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, true, true, false);
}
public void testLessThan() throws RepositoryException {
- checkOperator(Operator.LT, false, false, true);
+ checkOperator(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, false, false, true);
}
public void testLessThanOrEqualTo() throws RepositoryException {
- checkOperator(Operator.LE, false, true, true);
+ checkOperator(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, false, true, true);
}
public void testLike() throws RepositoryException {
- checkOperator(Operator.LIKE, false, true, false);
+ checkOperator(QueryObjectModelConstants.JCR_OPERATOR_LIKE, false, true, false);
}
public void testNotEqualTo() throws RepositoryException {
- checkOperator(Operator.NE, true, false, true);
+ checkOperator(AbstractQOMTest.JCR_OPERATOR_NOT_EQUAL_TO, true, false, true);
}
//------------------------------< helper >----------------------------------
- private void checkOperator(Operator operator,
+ private void checkOperator(String operator,
boolean matchesLesser,
boolean matchesEqual,
boolean matchesGreater)
@@ -183,8 +182,9 @@
checkOperatorSingleLiteral(createLexicographicallyGreater(nodeLocalName), operator, matchesGreater);
}
- private void checkOperatorSingleLiteral(
- String literal, Operator operator, boolean matches)
+ private void checkOperatorSingleLiteral(String literal,
+ String operator,
+ boolean matches)
throws RepositoryException {
Value value = superuser.getValueFactory().createValue(literal);
Query q = createQuery(operator, value);
@@ -203,16 +203,17 @@
return tmp.toString();
}
- private Query createQuery(Operator operator, Value literal)
+ private Query createQuery(String operator, Value literal)
throws RepositoryException {
return qomFactory.createQuery(
qomFactory.selector(testNodeType, "s"),
qomFactory.and(
qomFactory.childNode("s", testRoot),
- operator.comparison(
- qomFactory,
+ qomFactory.comparison(
qomFactory.nodeLocalName("s"),
- qomFactory.literal(literal))
+ operator,
+ qomFactory.literal(literal)
+ )
), null, null);
}
}
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeNameTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeNameTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/NodeNameTest.java Tue May 5 14:04:29 2009
@@ -22,9 +22,6 @@
import javax.jcr.PropertyType;
import javax.jcr.query.Query;
import javax.jcr.query.InvalidQueryException;
-
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
-
import java.util.Calendar;
/**
@@ -48,14 +45,14 @@
public void testStringLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(nodeName1);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testStringLiteralInvalidName() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue("[" + nodeName1);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with STRING that cannot be converted to NAME must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -65,14 +62,14 @@
public void testBinaryLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeName1, PropertyType.BINARY);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testDateLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(Calendar.getInstance());
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with DATE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -82,7 +79,7 @@
public void testDoubleLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(Math.PI);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with DOUBLE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -96,7 +93,7 @@
public void testLongLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(283);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with LONG must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -106,7 +103,7 @@
public void testBooleanLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(true);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with BOOLEAN must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -116,20 +113,20 @@
public void testNameLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeName1, PropertyType.NAME);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
}
public void testPathLiteral() throws RepositoryException {
Value literal = superuser.getValueFactory().createValue(
nodeName1, PropertyType.PATH);
- Query q = createQuery(Operator.EQ, literal);
+ Query q = createQuery(JCR_OPERATOR_EQUAL_TO, literal);
checkResult(q.execute(), new Node[]{node1});
literal = superuser.getValueFactory().createValue(
node1.getPath(), PropertyType.PATH);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with absolute PATH must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -138,7 +135,7 @@
literal = superuser.getValueFactory().createValue(
nodeName1 + "/" + nodeName1, PropertyType.PATH);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with PATH length >1 must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -152,7 +149,7 @@
node1.save();
Value literal = superuser.getValueFactory().createValue(node1);
try {
- createQuery(Operator.EQ, literal).execute();
+ createQuery(JCR_OPERATOR_EQUAL_TO, literal).execute();
fail("NodeName comparison with REFERENCE must fail with InvalidQueryException");
} catch (InvalidQueryException e) {
// expected
@@ -177,16 +174,16 @@
}
public void testEqualTo() throws RepositoryException {
- checkOperator(Operator.EQ, false, true, false);
+ checkOperator(JCR_OPERATOR_EQUAL_TO, false, true, false);
}
public void testNotEqualTo() throws RepositoryException {
- checkOperator(Operator.NE, true, false, true);
+ checkOperator(JCR_OPERATOR_NOT_EQUAL_TO, true, false, true);
}
//------------------------------< helper >----------------------------------
- private void checkOperator(Operator operator,
+ private void checkOperator(String operator,
boolean matchesLesser,
boolean matchesEqual,
boolean matchesGreater)
@@ -197,7 +194,7 @@
}
private void checkOperatorSingleLiteral(String literal,
- Operator operator,
+ String operator,
boolean matches)
throws RepositoryException {
Value value = superuser.getValueFactory().createValue(literal);
@@ -217,14 +214,14 @@
return tmp.toString();
}
- private Query createQuery(Operator operator, Value literal) throws RepositoryException {
+ private Query createQuery(String operator, Value literal) throws RepositoryException {
return qomFactory.createQuery(
qomFactory.selector(testNodeType, "s"),
qomFactory.and(
qomFactory.childNode("s", testRoot),
- operator.comparison(
- qomFactory,
+ qomFactory.comparison(
qomFactory.nodeName("s"),
+ operator,
qomFactory.literal(literal)
)
), null, null);
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java?rev=771732&r1=771731&r2=771732&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/query/qom/UpperLowerCaseTest.java Tue May 5 14:04:29 2009
@@ -24,8 +24,6 @@
import javax.jcr.query.Query;
import javax.jcr.query.qom.DynamicOperand;
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
-
/**
* <code>UpperLowerCaseTest</code> performs tests with upper- and lower-case
* operands.
@@ -70,26 +68,26 @@
// upper case
checkQueries(qomFactory.propertyValue("s", propertyName1),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.NAME,
new boolean[]{false, false, false, false, true});
checkQueries(qomFactory.propertyValue("s", propertyName2),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.NAME,
new boolean[]{false, false, false, false, true});
// lower case
checkQueries(qomFactory.propertyValue("s", propertyName1),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.NAME,
new boolean[]{true, false, false, false, false});
checkQueries(qomFactory.propertyValue("s", propertyName2),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.NAME,
new boolean[]{true, false, false, false, false});
@@ -98,26 +96,26 @@
public void testPropertyValue() throws RepositoryException {
// upper case
checkQueries(qomFactory.propertyValue("s", propertyName1),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{false, false, false, false, true});
checkQueries(qomFactory.propertyValue("s", propertyName2),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{false, false, false, false, true});
// lower case
checkQueries(qomFactory.propertyValue("s", propertyName1),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{true, false, false, false, false});
checkQueries(qomFactory.propertyValue("s", propertyName2),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{true, false, false, false, false});
@@ -126,7 +124,7 @@
public void testUpperLowerCase() throws RepositoryException {
// first upper case, then lower case again
checkQueries(qomFactory.upperCase(qomFactory.propertyValue("s", propertyName1)),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{true, false, false, false, false});
@@ -135,7 +133,7 @@
public void testUpperCaseTwice() throws RepositoryException {
// upper case twice
checkQueries(qomFactory.upperCase(qomFactory.propertyValue("s", propertyName1)),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{false, false, false, false, true});
@@ -144,7 +142,7 @@
public void testLowerUpperCase() throws RepositoryException {
// first lower case, then upper case again
checkQueries(qomFactory.lowerCase(qomFactory.propertyValue("s", propertyName1)),
- true, Operator.EQ,
+ true, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{false, false, false, false, true});
@@ -153,7 +151,7 @@
public void testLowerCaseTwice() throws RepositoryException {
// lower case twice
checkQueries(qomFactory.lowerCase(qomFactory.propertyValue("s", propertyName1)),
- false, Operator.EQ,
+ false, JCR_OPERATOR_EQUAL_TO,
new String[]{"abc", "Abc", "aBc", "abC", "ABC"},
PropertyType.STRING,
new boolean[]{true, false, false, false, false});
@@ -163,7 +161,7 @@
private void checkQueries(DynamicOperand operand,
boolean toUpper,
- Operator operator,
+ String operator,
String[] literals,
int type,
boolean[] matches) throws RepositoryException {
@@ -175,7 +173,7 @@
private Query createQuery(DynamicOperand operand,
boolean toUpper,
- Operator operator,
+ String operator,
Value literal) throws RepositoryException {
if (toUpper) {
operand = qomFactory.upperCase(operand);
@@ -186,10 +184,11 @@
qomFactory.selector(testNodeType, "s"),
qomFactory.and(
qomFactory.childNode("s", testRoot),
- operator.comparison(
- qomFactory,
+ qomFactory.comparison(
operand,
- qomFactory.literal(literal))
+ operator,
+ qomFactory.literal(literal)
+ )
), null, null);
}
}