From 00b3528aed74693df2b6745fe4d18dc1e74eb37d Mon Sep 17 00:00:00 2001 From: Randall Hauch Date: Thu, 24 May 2012 16:14:12 -0500 Subject: [PATCH] JCR-3313 Changed a ColumnTest test to only check for required columns Section 6.7.1 of JSR-283 requires that "If no columns are specified, the columns available in the tabular view are implementation determined, but minimally include, for each selector, a column for each single-valued non-residual property of the selector's node type." The ColumnTest.testExpandColumnsForNodeType() method was placing additional requirements: namely that the tabular view contains **only** a column for each single-valued non-residual property of the selector's node type. This test was changed to more correctly enforce the specification's requirements by ensuring only that there is a column for each single-valued non-residual property of the selector's node type, while allowing other columns to exist. Note that this test is slightly less strict than before, so Jackrabbit Core passes this test without any changes. Additionally, a full build with these changes succeeds as expected. --- .../jackrabbit/test/api/query/qom/ColumnTest.java | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java index c02a5a8..6ef0c19 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ColumnTest.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; +import java.util.HashSet; +import java.util.Set; import javax.jcr.RepositoryException; import javax.jcr.Node; @@ -65,21 +67,22 @@ public class ColumnTest extends AbstractQOMTest { forQOMandSQL2(qom, new Callable() { public Object call(Query query) throws RepositoryException { QueryResult result = query.execute(); - List names = new ArrayList(Arrays.asList(result.getColumnNames())); NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager(); NodeType nt = ntMgr.getNodeType(testNodeType); PropertyDefinition[] propDefs = nt.getPropertyDefinitions(); + Set names = new HashSet(); for (int i = 0; i < propDefs.length; i++) { PropertyDefinition propDef = propDefs[i]; if (!propDef.isMultiple() && !propDef.getName().equals("*")) { String columnName = SELECTOR_1 + "." + propDef.getName(); - assertTrue("Missing column: " + columnName, - names.remove(columnName)); + names.add(columnName); + assertTrue("Missing column: " + columnName, names.remove(columnName)); } } - for (Iterator it = names.iterator(); it.hasNext(); ) { - fail(it.next() + " is not a property on node type " + testNodeType); + for (String columnName : result.getColumnNames()) { + names.remove(columnName); } + assertTrue("Missing required column(s): " + names, names.isEmpty()); return null; } }); -- 1.7.6