You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2014/03/03 12:56:34 UTC
svn commit: r1573531 -
/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
Author: fmui
Date: Mon Mar 3 11:56:34 2014
New Revision: 1573531
URL: http://svn.apache.org/r1573531
Log:
CMIS-766: TCK: create test documents and folders before running query LIKE test
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java?rev=1573531&r1=1573530&r2=1573531&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/query/QueryLikeTest.java Mon Mar 3 11:56:34 2014
@@ -24,6 +24,7 @@ import static org.apache.chemistry.openc
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
@@ -34,6 +35,9 @@ import org.apache.chemistry.opencmis.tck
*/
public class QueryLikeTest extends AbstractQueryTest {
+ private static final String CONTENT = "TCK test content.";
+ private static final int PAGE_SIZE = 10;
+
@Override
public void init(Map<String, String> parameters) {
super.init(parameters);
@@ -44,50 +48,111 @@ public class QueryLikeTest extends Abstr
@Override
public void run(Session session) {
if (supportsQuery(session) && !isFulltextOnly(session)) {
+ // create a test folder
+ Folder testFolder = createTestFolder(session);
+
+ try {
+ for (char c = 'a'; c <= 'z'; c++) {
+ createDocument(session, testFolder, c + "Document", CONTENT);
+ createFolder(session, testFolder, c + "Folder");
+ }
+
+ OperationContext context = session.createOperationContext();
+ context.setFilterString("cmis:name,cmis:creationDate");
+ context.setCacheEnabled(false);
+ context.setIncludeAcls(false);
+ context.setIncludeAllowableActions(false);
+ context.setIncludePathSegments(false);
+ context.setIncludePolicies(false);
+ context.setIncludeRelationships(IncludeRelationships.NONE);
+ context.setRenditionFilterString("cmis:none");
+ context.setOrderBy("cmis:creationDate");
+
+ CmisTestResult f;
+
+ for (char c = 'a'; c <= 'z'; c++) {
+ // query documents
+ long timestamp = Long.MIN_VALUE;
+ long count = 0;
+
+ for (CmisObject o : session.queryObjects("cmis:document", "cmis:name LIKE '" + c + "%'", false,
+ context).getPage(PAGE_SIZE)) {
+
+ if (o.getName() == null || o.getName().length() == 0) {
+ addResult(createResult(
+ FAILURE,
+ "Documents without name should not be returned by this query! Document ID: "
+ + o.getId()));
+ } else {
+ f = createResult(FAILURE, "Document name should start with '" + c + "' but the name is '"
+ + o.getName() + "'.");
+ addResult(assertEquals(c, Character.toLowerCase(o.getName().charAt(0)), null, f));
+ }
+
+ if (o.getCreationDate() == null) {
+ addResult(createResult(FAILURE,
+ "Found document without creation date! Document ID: " + o.getId()));
+ } else {
+ f = createResult(FAILURE,
+ "Query results should be ordered by cmis:creationDate but they are not!");
+ addResult(assertIsTrue(timestamp <= o.getCreationDate().getTimeInMillis(), null, f));
- OperationContext context = session.createOperationContext();
- context.setFilterString("cmis:name,cmis:creationDate");
- context.setCacheEnabled(false);
- context.setIncludeAcls(false);
- context.setIncludeAllowableActions(false);
- context.setIncludePathSegments(false);
- context.setIncludePolicies(false);
- context.setIncludeRelationships(IncludeRelationships.NONE);
- context.setRenditionFilterString("cmis:none");
- context.setOrderBy("cmis:creationDate");
-
- CmisTestResult f;
-
- for (char c = 'a'; c <= 'z'; c++) {
- long timestamp = Long.MIN_VALUE;
-
- for (CmisObject o : session
- .queryObjects("cmis:document", "cmis:name LIKE '" + c + "%'", false, context).getPage(10)) {
-
- if (o.getName() == null || o.getName().length() == 0) {
- addResult(createResult(
- FAILURE,
- "Documents without name should not be returned by this query! Document id: "
- + o.getId()));
- } else {
- f = createResult(FAILURE,
- "Document name should start with '" + c + "' but the name is '" + o.getName() + "'");
- addResult(assertEquals(c, Character.toLowerCase(o.getName().charAt(0)), null, f));
+ timestamp = o.getCreationDate().getTimeInMillis();
+ }
+
+ count++;
}
- if (o.getCreationDate() == null) {
- addResult(createResult(FAILURE,
- "Found document without creation date! Document id: " + o.getId()));
- } else {
- f = createResult(FAILURE,
- "Query results should be ordered by cmis:creationDate but they are not!");
- addResult(assertIsTrue(timestamp <= o.getCreationDate().getTimeInMillis(), null, f));
+ f = createResult(FAILURE, "No documents starting with '" + c
+ + "' have been found, but there must be at least one!");
+ addResult(assertIsTrue(count > 0, null, f));
+
+ f = createResult(FAILURE, "A page of " + PAGE_SIZE
+ + " query hits has been requested, but the repository returned " + count + ".");
+ addResult(assertIsTrue(count <= PAGE_SIZE, null, f));
+
+ // query folders
+ timestamp = Long.MIN_VALUE;
+ count = 0;
+
+ for (CmisObject o : session.queryObjects("cmis:folder", "cmis:name LIKE '" + c + "%'", false,
+ context).getPage(PAGE_SIZE)) {
+
+ if (o.getName() == null || o.getName().length() == 0) {
+ addResult(createResult(FAILURE,
+ "Folder without name should not be returned by this query! Folder ID: " + o.getId()));
+ } else {
+ f = createResult(FAILURE,
+ "Folder name should start with '" + c + "' but the name is '" + o.getName() + "'.");
+ addResult(assertEquals(c, Character.toLowerCase(o.getName().charAt(0)), null, f));
+ }
+
+ if (o.getCreationDate() == null) {
+ addResult(createResult(FAILURE,
+ "Found folder without creation date! Folder ID: " + o.getId()));
+ } else {
+ f = createResult(FAILURE,
+ "Query results should be ordered by cmis:creationDate but they are not!");
+ addResult(assertIsTrue(timestamp <= o.getCreationDate().getTimeInMillis(), null, f));
+
+ timestamp = o.getCreationDate().getTimeInMillis();
+ }
- timestamp = o.getCreationDate().getTimeInMillis();
+ count++;
}
+
+ f = createResult(FAILURE, "No folders starting with '" + c
+ + "' have been found, but there must be at least one!");
+ addResult(assertIsTrue(count > 0, null, f));
+
+ f = createResult(FAILURE, "A page of " + PAGE_SIZE
+ + " query hits has been requested, but the repository returned " + count + ".");
+ addResult(assertIsTrue(count <= PAGE_SIZE, null, f));
}
+ } finally {
+ // delete the test folder
+ deleteTestFolder();
}
-
} else {
addResult(createResult(SKIPPED, "Metadata query not supported. Test Skipped!"));
}