chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r903726 - in /incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main: java/org/apache/chemistry/abdera/ext/ java/org/apache/chemistry/tck/atompub/client/ java/org/apache/chemistry/tck/atompub/fixture/ java/org/apache/chemistry/t...
Date Wed, 27 Jan 2010 16:45:09 GMT
Author: dcaruana
Date: Wed Jan 27 16:45:08 2010
New Revision: 903726

URL: http://svn.apache.org/viewvc?rev=903726&view=rev
Log:
CMIS-105: Add rendition tests to TCK
- also add rendition support Abdera extension

Added:
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image1.jpg   (with props)
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image2.png   (with props)
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISCapabilities.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTestFixture.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTree.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/createdocumentBase64.cmisatomentry.xml
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/query.cmisquery.xml
    incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/queryallowableactions.cmisquery.xml

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISCapabilities.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISCapabilities.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISCapabilities.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISCapabilities.java Wed Jan 27 16:45:08 2010
@@ -78,4 +78,9 @@
         return child.getText();
     }
 
+    public String getRenditions() {
+        Element child = getFirstChild(CMISConstants.CAPABILITY_RENDITIONS);
+        return child.getText();
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java Wed Jan 27 16:45:08 2010
@@ -81,6 +81,7 @@
     public static final QName CAPABILITY_ALL_VERIONS_SEARCHABLE = new QName(CMIS_NS, "capabilityAllVersionsSearchable");
     public static final QName CAPABILITY_QUERY = new QName(CMIS_NS, "capabilityQuery");
     public static final QName CAPABILITY_JOIN = new QName(CMIS_NS, "capabilityJoin");
+    public static final QName CAPABILITY_RENDITIONS = new QName(CMIS_NS, "capabilityRenditions");
 
     // CMIS Object
     public static final QName OBJECT = new QName(CMISRA_NS, "object");
@@ -101,7 +102,13 @@
     public static final QName CONTENT = new QName(CMISRA_NS, "content");
     public static final QName CONTENT_MEDIATYPE = new QName(CMISRA_NS, "mediatype");
     public static final QName CONTENT_BASE64 = new QName(CMISRA_NS, "base64");
+
+    // CMIS Relative Path Segment
+    public static final QName RELATIVE_PATH_SEGMENT = new QName(CMISRA_NS, "relativePathSegment");
     
+    // CMIS Renditions
+    public static final QName RENDITION_KIND = new QName(CMISRA_NS, "renditionKind");
+
     // CMIS Type Definition
     public static final QName TYPE_DEFINITION = new QName(CMISRA_NS, "type");
     public static final QName TYPE_ID = new QName(CMIS_NS, "id");
@@ -165,6 +172,7 @@
     public static final String REL_VERSION_HISTORY = "version-history";
     public static final String REL_CURRENT_VERSION = "current-version";
     public static final String REL_WORKING_COPY = "working-copy";
+    public static final String REL_ALTERNATE = "alternate";
     public static final String REL_ROOT_DESCENDANTS = CMISLINK_NS + "rootdescendants";
     public static final String REL_TYPES_DESCENDANTS = CMISLINK_NS + "typedescendants";
     public static final String REL_FOLDER_TREE = CMISLINK_NS + "foldertree";

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java Wed Jan 27 16:45:08 2010
@@ -17,7 +17,9 @@
  */
 package org.apache.chemistry.tck.atompub.client;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.StringReader;
 import java.util.HashMap;
 import java.util.List;
@@ -263,6 +265,10 @@
     public Link getFolderParentLink(Entry entry) {
         return getLink(entry, CMISConstants.REL_UP, CMISConstants.MIMETYPE_ENTRY);
     }
+    
+    public List<Link> getRenditionLinks(Entry entry) {
+        return entry.getLinks(CMISConstants.REL_ALTERNATE);
+    }
 
     public Entry getEntry(IRI href) throws Exception {
         return getEntry(href, null);
@@ -326,16 +332,52 @@
         return createDocument(parent, name, atomEntryFile, false);
     }
 
-    public Entry createDocument(IRI parent, String name, String atomEntryFile,
-            boolean expectNoContent) throws Exception {
-        String createFile = templates.load(atomEntryFile == null ? "createdocument.atomentry.xml" : atomEntryFile);
+    public Entry createDocument(IRI parent, String name, String atomEntryFile, boolean expectNoContent)
+            throws Exception {
+        return createDocument(parent, name, atomEntryFile, expectNoContent, name, null, null);
+    }
+
+    public Entry createDocument(IRI parent, String name, String atomEntryFile, boolean expectNoContent, String content,
+            String cmisType, String cmisContentPath) throws Exception {
+
+        // If no preference is expressed, use the base64 template if binary
+        // content has been supplied or the basic atom entry template otherwise
+        String createFile = templates
+                .load(atomEntryFile == null ? (cmisContentPath == null ? "createdocument.atomentry.xml"
+                        : "createdocumentBase64.cmisatomentry.xml") : atomEntryFile);
         createFile = createFile.replace("${NAME}", name);
+
         // determine if creating content via mediatype
         Entry createEntry = appModel.parseEntry(new StringReader(createFile), null);
         MimeType mimeType = createEntry.getContentMimeType();
-        boolean mediaType = (mimeType != null);
-        createFile = createFile.replace("${CMISCONTENT}", new String(Base64.encodeBase64(name.getBytes())));
-        createFile = createFile.replace("${CONTENT}", mediaType ? new String(Base64.encodeBase64(name.getBytes())) : name);
+
+        if (content != null) {
+            createFile = createFile.replace("${CONTENT}", mimeType == null ? content : new String(Base64
+                    .encodeBase64(content.getBytes("UTF-8")), "8859_1"));
+        }
+
+        createFile = createFile.replace("${CMISTYPE}", cmisType == null ? "text/plain" : cmisType);
+
+        byte[] contentBytes = null;
+        if (cmisContentPath != null) {
+            InputStream in = getClass().getResourceAsStream('/' + cmisContentPath);
+            if (in != null) {
+                ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+                int bytesRead;
+                byte[] buffer = new byte[1024];
+                while ((bytesRead = in.read(buffer)) != -1) {
+                    out.write(buffer, 0, bytesRead);
+                }
+                in.close();
+                out.close();
+                contentBytes = out.toByteArray();
+            }
+        }
+        if (contentBytes == null) {
+            contentBytes = name.getBytes("UTF-8");
+        }
+        createFile = createFile.replace("${CMISCONTENT}", new String(Base64.encodeBase64(contentBytes), "8859_1"));
+
         Request req = new PostRequest(parent.toString(), createFile, CMISConstants.MIMETYPE_ENTRY);
         Response res = executeRequest(req, 201);
         Assert.assertNotNull(res);

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTestFixture.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTestFixture.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTestFixture.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTestFixture.java Wed Jan 27 16:45:08 2010
@@ -111,7 +111,30 @@
             EntryTree docEntry = new EntryTree();
             String docName = name + " doc " + docIdx;
             docEntry.parent = entry;
-            docEntry.entry = client.createDocument(childrenLink.getHref(), docName, docTemplate);
+            String cmisType = null;
+            String cmisContentPath = null;
+            String content = null;
+            // If no template is specified, use a selection of files of
+            // different types
+            if (docTemplate == null) {
+                switch (docIdx % 3) {
+                case 1:
+                    cmisType = "image/jpeg";
+                    cmisContentPath = "org/apache/chemistry/tck/atompub/images/image1.jpg";
+                    break;
+                case 2:
+                    cmisType = "image/png";
+                    cmisContentPath = "org/apache/chemistry/tck/atompub/images/image2.png";
+                    break;
+                default:
+                    content = name;
+                    break;
+                }
+                docEntry.entry = client.createDocument(childrenLink.getHref(), docName, null, false, content, cmisType,
+                        cmisContentPath);
+            } else {
+                docEntry.entry = client.createDocument(childrenLink.getHref(), docName, docTemplate);
+            }
             docEntry.type = CMISConstants.TYPE_DOCUMENT;
             folderEntry.children.add(docEntry);
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTree.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTree.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTree.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/CMISTree.java Wed Jan 27 16:45:08 2010
@@ -17,6 +17,7 @@
 package org.apache.chemistry.tck.atompub.fixture;
 
 import java.util.ArrayList;
+import java.util.Collections;
 
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
@@ -25,7 +26,6 @@
 import org.apache.chemistry.abdera.ext.CMISObject;
 import org.apache.chemistry.abdera.ext.CMISProperty;
 
-
 /**
  * CMIS Tree of Folders and Documents or Types
  */
@@ -43,6 +43,13 @@
         }
     }
 
+    public CMISTree(Entry parent, Entry entry, String type) {
+        this.parent = parent;
+        this.entry = entry;
+        this.type = type;
+        this.children = Collections.emptyList();
+    }
+
     private EntryTree createEntryTree(Entry parent, Entry entry) {
         EntryTree entryTree = new EntryTree();
         entryTree.parent = parent;

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java?rev=903726&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java Wed Jan 27 16:45:08 2010
@@ -0,0 +1,253 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     David Ward, Alfresco
+ */
+package org.apache.chemistry.tck.atompub.fixture;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Link;
+import org.apache.chemistry.abdera.ext.CMISCapabilities;
+import org.apache.chemistry.abdera.ext.CMISConstants;
+import org.apache.chemistry.abdera.ext.CMISObject;
+import org.apache.chemistry.abdera.ext.CMISUriTemplate;
+import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException;
+import org.apache.chemistry.tck.atompub.client.CMISClient;
+import org.apache.chemistry.tck.atompub.fixture.EntryTree.TreeVisitor;
+import org.apache.chemistry.tck.atompub.http.GetRequest;
+import org.junit.Assert;
+
+/**
+ * A visitor that fetches all renditions for an {@link EntryTree}. When called
+ * through the {@link #testRenditions(EntryTree, EntryGenerator)} method, will
+ * test a supplied {@link EntryGenerator} with a variety of rendition filters
+ * and ensure the renditions returned match those expected.
+ */
+public class GatherRenditionsVisitor implements TreeVisitor {
+
+    private CMISClient client;
+    private Set<MimeType> renditionMimeTypes = new HashSet<MimeType>(5);
+    private Set<String> renditionKinds = new HashSet<String>(5);
+    private Map<String, Map<String, Set<IRI>>> entryRenditionMap = new HashMap<String, Map<String, Set<IRI>>>(5);
+
+    public GatherRenditionsVisitor(CMISClient client) {
+        this.client = client;
+    }
+
+    private String getObjectId(Entry entry) {
+        Assert.assertNotNull(entry);
+        CMISObject object = entry.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(object);
+        String objectId = object.getObjectId().getStringValue();
+        Assert.assertNotNull(objectId);
+        return objectId;
+    }
+
+    public void visit(EntryTree entry) throws Exception {
+        // Get the object ID
+        String objectId = getObjectId(entry.entry);
+
+        // get the entry, this time with renditions (if any)
+        CMISUriTemplate objectByIdTemplate = client.getObjectByIdUriTemplate(client.getWorkspace());
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("id", objectId);
+        variables.put("renditionFilter", "*");
+        IRI objectByIdRequest = objectByIdTemplate.generateUri(variables);
+
+        Entry documentById = client.getEntry(objectByIdRequest);
+        Assert.assertNotNull(documentById);
+        String newObjectId = getObjectId(documentById);
+        Assert.assertEquals(objectId, newObjectId);
+
+        Map<String, Set<IRI>> entryRenditions = new HashMap<String, Set<IRI>>();
+        this.entryRenditionMap.put(objectId, entryRenditions);
+        
+        // Get each of the renditions
+        List<Link> renditions = this.client.getRenditionLinks(documentById);
+
+        for (Link rendition : renditions) {
+
+            // Check the rendition link is well formed
+            MimeType mimeType = rendition.getMimeType();
+            Assert.assertNotNull(mimeType);
+            String renditionKind = rendition.getAttributeValue(CMISConstants.RENDITION_KIND);
+            Assert.assertNotNull(renditionKind);
+            IRI renditionLink = rendition.getHref();
+            Assert.assertNotNull(renditionLink);
+
+            // Check the rendition can be fetched
+            this.client.executeRequest(new GetRequest(renditionLink.toString()), 200);
+
+            // Add the rendition link to our maps
+            this.renditionMimeTypes.add(mimeType);
+            this.renditionKinds.add(renditionKind);
+
+            Set<IRI> typeRenditions = entryRenditions.get(mimeType.getBaseType());
+            if (typeRenditions == null) {
+                typeRenditions = new HashSet<IRI>(5);
+                entryRenditions.put(mimeType.getBaseType(), typeRenditions);
+            }
+            typeRenditions.add(renditionLink);
+
+            typeRenditions = entryRenditions.get(renditionKind);
+            if (typeRenditions == null) {
+                typeRenditions = new HashSet<IRI>(5);
+                entryRenditions.put(renditionKind, typeRenditions);
+            }
+            typeRenditions.add(renditionLink);
+        }
+    }
+
+    public void testRenditions(EntryTree fixture, EntryGenerator entryGenerator) throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        if (capabilities.getRenditions().equals("none")) {
+            throw new TCKSkipCapabilityException("Renditions", "read", "none");
+        }
+
+        // Gather together all the renditions in the tree
+        fixture.walkTree(this);
+
+        // Choose a mime type and a kind for testing with
+        MimeType mimeType = null;
+        Iterator<MimeType> mimeTypes = this.renditionMimeTypes.iterator();
+        if (mimeTypes.hasNext()) {
+            mimeType = mimeTypes.next();
+        }
+        String kind = null;
+        Iterator<String> renditionKinds = this.renditionKinds.iterator();
+        if (renditionKinds.hasNext()) {
+            kind = renditionKinds.next();
+        }
+
+        // Test none
+        getEntriesWithRenditionFilter(entryGenerator, "cmis:none");
+
+        // Test all
+        getEntriesWithRenditionFilter(entryGenerator, "*");
+
+        // Test retrieval by specific mimetype and primary type
+        if (mimeType != null) {
+            getEntriesWithRenditionFilter(entryGenerator, mimeType.getBaseType());
+            getEntriesWithRenditionFilter(entryGenerator, mimeType.getPrimaryType() + "/*");
+        }
+        if (kind != null) {
+            // Test retrieval by kind
+            getEntriesWithRenditionFilter(entryGenerator, kind);
+            // Test retrieval by kind and mime type
+            if (mimeType != null) {
+                getEntriesWithRenditionFilter(entryGenerator, kind + ',' + mimeType.getBaseType());
+                getEntriesWithRenditionFilter(entryGenerator, kind + ',' + mimeType.getPrimaryType() + "/*");
+            }
+        }
+    }
+
+    private void getEntriesWithRenditionFilter(EntryGenerator entryGenerator, String renditionFilter) throws Exception {
+        EntryTree toValidate = entryGenerator.getEntries(renditionFilter);
+        toValidate.walkTree(getRenditionCheckingVisitor(renditionFilter));
+    }
+
+    private TreeVisitor getRenditionCheckingVisitor(final String renditionFilter) {
+        return new TreeVisitor() {
+
+            private Set<IRI> predictRenditionsForFilter(Entry entry) {
+                if (renditionFilter.equals("cmis:none")) {
+                    return Collections.emptySet();
+                } else if (renditionFilter.equals("*")) {
+                    Set<IRI> result = new HashSet<IRI>(5);
+                    Map<String, Set<IRI>> entryRenditions = GatherRenditionsVisitor.this.entryRenditionMap
+                            .get(getObjectId(entry));
+
+                    for (Set<IRI> renditions : entryRenditions.values()) {
+                        result.addAll(renditions);
+                    }
+                    return result;
+                }
+                Set<IRI> result = new HashSet<IRI>(5);
+                StringTokenizer tkn = new StringTokenizer(renditionFilter, ",");
+                Map<String, Set<IRI>> entryRenditions = GatherRenditionsVisitor.this.entryRenditionMap
+                        .get(getObjectId(entry));
+                while (tkn.hasMoreTokens()) {
+                    String token = tkn.nextToken();
+                    MimeType mimeType;
+                    try {
+                        mimeType = new MimeType(token);
+                        if (mimeType.getSubType().equals("*")) {
+                            String primaryType = mimeType.getPrimaryType();
+                            for (Map.Entry<String, Set<IRI>> typeEntry : entryRenditions.entrySet()) {
+                                try {
+                                    MimeType candidateType = new MimeType(typeEntry.getKey());
+                                    if (candidateType.getPrimaryType().equals(primaryType)) {
+                                        result.addAll(typeEntry.getValue());
+                                    }
+                                } catch (MimeTypeParseException e) {
+                                }
+                            }
+                            continue;
+                        }
+                    } catch (MimeTypeParseException e) {
+                    }
+                    Set<IRI> renditions = entryRenditions.get(token);
+                    if (renditions != null) {
+                        result.addAll(renditions);
+                    }
+                }
+                return result;
+            }
+
+            public void visit(EntryTree entry) throws Exception {
+                Set<IRI> predictedRenditions = predictRenditionsForFilter(entry.entry);
+                Set<IRI> actualRenditions = new HashSet<IRI>(predictedRenditions.size() * 2);
+
+                // Get each of the renditions
+                List<Link> renditions = GatherRenditionsVisitor.this.client.getRenditionLinks(entry.entry);
+
+                for (Link rendition : renditions) {
+                    // Check the rendition link is well formed
+                    MimeType mimeType = rendition.getMimeType();
+                    Assert.assertNotNull(mimeType);
+                    String renditionKind = rendition.getAttributeValue(CMISConstants.RENDITION_KIND);
+                    Assert.assertNotNull(renditionKind);
+                    IRI renditionLink = rendition.getHref();
+                    Assert.assertNotNull(renditionLink);
+
+                    // Check the rendition can be fetched
+                    GatherRenditionsVisitor.this.client.executeRequest(new GetRequest(renditionLink.toString()), 200);
+
+                    // Add to our rendition set
+                    actualRenditions.add(renditionLink);
+                }
+
+                Assert.assertEquals(predictedRenditions, actualRenditions);
+
+            }
+        };
+    }
+
+    public interface EntryGenerator {
+        public EntryTree getEntries(String renditionFilter) throws Exception;
+    }
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/fixture/GatherRenditionsVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/custom/CMISCustomTypeTest.java Wed Jan 27 16:45:08 2010
@@ -197,6 +197,7 @@
             String queryReq = queryDoc.replace("${STATEMENT}", query);
             queryReq = queryReq.replace("${SKIPCOUNT}", "0");
             queryReq = queryReq.replace("${PAGESIZE}", "5");
+            queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
             // issue structured query
             Response queryRes = client.executeRequest(new PostRequest(queryHREF.toString(), queryReq,

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderChildrenTest.java Wed Jan 27 16:45:08 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.chemistry.tck.atompub.test.spec;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -35,7 +36,9 @@
 import org.apache.chemistry.tck.atompub.TCKTest;
 import org.apache.chemistry.tck.atompub.fixture.AssertEntryInFeedVisitor;
 import org.apache.chemistry.tck.atompub.fixture.AssertValidFolderParentVisitor;
+import org.apache.chemistry.tck.atompub.fixture.CMISTree;
 import org.apache.chemistry.tck.atompub.fixture.EntryTree;
+import org.apache.chemistry.tck.atompub.fixture.GatherRenditionsVisitor;
 import org.junit.Assert;
 
 /**
@@ -156,5 +159,37 @@
 
         folder.walkTree(new AssertValidFolderParentVisitor(client));
     }
+    
+    public void testGetChildrenRenditions() throws Exception {
+        final EntryTree folder = fixture.createTestTree("children", 1, 3, null, null);
+        final Link childrenLink = client.getChildrenLink(folder.entry);
+
+        // Walk the tree with a visitor that gathers its renditions and then
+        // tries getChildren requests with various forms of renditionFilter
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(folder, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                // get children
+                return new CMISTree(folder, client.getFeed(childrenLink.getHref(), Collections.singletonMap(
+                        "renditionFilter", renditionFilter)));
+            }
+        });
+    }
 
+    public void testGetParentRenditions() throws Exception {
+        final EntryTree folder = fixture.createTestTree("children", 2, 0, null, null);
+        EntryTree child = folder.children.get(0);
+        final Link parentLink = client.getFolderParentLink(child.entry);
+        Assert.assertNotNull(parentLink);
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(folder, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                return new CMISTree(folder.entry, client.getEntry(parentLink.getHref(), Collections.singletonMap(
+                        "renditionFilter", renditionFilter)), CMISConstants.TYPE_FOLDER);
+            }
+        });
+    }
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/FolderHierarchyTest.java Wed Jan 27 16:45:08 2010
@@ -17,17 +17,20 @@
  */
 package org.apache.chemistry.tck.atompub.test.spec;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Link;
 import org.apache.chemistry.abdera.ext.CMISCapabilities;
+import org.apache.chemistry.abdera.ext.CMISConstants;
 import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException;
 import org.apache.chemistry.tck.atompub.TCKTest;
 import org.apache.chemistry.tck.atompub.fixture.AssertValidObjectParentsVisitor;
 import org.apache.chemistry.tck.atompub.fixture.CMISTree;
 import org.apache.chemistry.tck.atompub.fixture.EntryTree;
+import org.apache.chemistry.tck.atompub.fixture.GatherRenditionsVisitor;
 import org.junit.Assert;
 
 
@@ -69,6 +72,30 @@
     public void testGetFolderTreeOverDepth() throws Exception {
         getFolderTreeDepthN(3, 4);
     }
+    
+    public void testGetFolderTreeRenditions() throws Exception {
+        testLinkRenditions("foldertree", CMISConstants.REL_FOLDER_TREE, CMISConstants.MIMETYPE_FEED);
+    }
+
+    private void testLinkRenditions(String name, String linkRel, String linkMimeType) throws Exception {
+        // construct hierarchy of folders and docs
+        final EntryTree folderTree = fixture.createTestTree(name, 3, 2, null, null);
+
+        final Link treeLink = client.getLink(folderTree.entry, linkRel, linkMimeType);
+        Assert.assertNotNull(treeLink);
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(folderTree, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                // retrieve feed
+                Map<String, String> args = new HashMap<String, String>();
+                args.put("depth", "3");
+                args.put("renditionFilter", renditionFilter);
+                return new CMISTree(folderTree, client.getFeed(treeLink.getHref(), args));
+            }
+        });
+    }
 
     private void getDescendantsDepthN(int depth, int getDepth) throws Exception {
         // construct hierarchy of folders and docs
@@ -114,10 +141,30 @@
         getDescendantsDepthN(3, 4);
     }
 
+    public void testGetDescendantRenditions() throws Exception {
+        checkGetDescendantsCapability();
+        testLinkRenditions("descendants", CMISConstants.REL_DOWN, CMISConstants.MIMETYPE_CMISTREE);
+    }
+
     public void testGetObjectParents() throws Exception {
         EntryTree folder = fixture.createTestTree("children", 3, 2, null, null);
 
         folder.walkTree(new AssertValidObjectParentsVisitor(client));
     }
-
+    
+    public void testObjectParentRenditions() throws Exception {
+        final EntryTree folder = fixture.createTestTree("children", 1, 1, null, null);
+        EntryTree child = folder.children.get(0);
+        final Link parentLink = client.getObjectParentsLink(child.entry);
+        Assert.assertNotNull(parentLink);
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(folder, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                return new CMISTree(folder, client.getFeed(parentLink.getHref(), Collections.singletonMap(
+                        "renditionFilter", renditionFilter)));
+            }
+        });
+    }    
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/GetTest.java Wed Jan 27 16:45:08 2010
@@ -17,16 +17,23 @@
  */
 package org.apache.chemistry.tck.atompub.test.spec;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
 import org.apache.chemistry.abdera.ext.CMISConstants;
 import org.apache.chemistry.abdera.ext.CMISObject;
 import org.apache.chemistry.abdera.ext.CMISRepositoryInfo;
 import org.apache.chemistry.abdera.ext.CMISUriTemplate;
 import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.fixture.CMISTree;
+import org.apache.chemistry.tck.atompub.fixture.EntryTree;
+import org.apache.chemistry.tck.atompub.fixture.GatherRenditionsVisitor;
 import org.apache.chemistry.tck.atompub.http.GetRequest;
 import org.junit.Assert;
 
@@ -62,6 +69,21 @@
         client.executeRequest(new GetRequest(folder.getSelfLink().getHref().toString() + guid), 404);
     }
 
+    public void testGetDocumentRenditions() throws Exception {
+        final Entry document = fixture.createTestDocument("testGetDocumentRenditions");
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(new CMISTree(fixture.getTestCaseFolder(), document, CMISConstants.TYPE_DOCUMENT),
+                new GatherRenditionsVisitor.EntryGenerator() {
+
+                    public EntryTree getEntries(String renditionFilter) throws Exception {
+                        return new CMISTree(fixture.getTestCaseFolder(), client.getEntry(document.getSelfLink()
+                                .getHref(), Collections.singletonMap("renditionFilter", renditionFilter)),
+                                CMISConstants.TYPE_DOCUMENT);
+                    }
+                });
+    }
+    
     public void testObjectById() throws Exception
     {
         // construct document
@@ -133,4 +155,79 @@
         Assert.assertEquals(objectId, folderByPathObject.getObjectId().getStringValue());
     }
     
+    public void testObjectByIdRenditions() throws Exception {
+        // construct document
+        Entry document = fixture.createTestDocument("testObjectByIdRenditions");
+        Assert.assertNotNull(document);
+        CMISObject documentObject = document.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(documentObject);
+        final String objectId = documentObject.getObjectId().getStringValue();
+        Assert.assertNotNull(objectId);
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+
+        // Create simple entry tree and walk it with the renditions visitor
+        EntryTree entryTree = new CMISTree(fixture.getTestCaseFolder(), document, CMISConstants.TYPE_DOCUMENT);
+        visitor.testRenditions(entryTree, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                // formulate get request via id
+                CMISUriTemplate objectByIdTemplate = client.getObjectByIdUriTemplate(client.getWorkspace());
+                Map<String, Object> variables = new HashMap<String, Object>(5);
+                variables.put("id", objectId);
+                variables.put("renditionFilter", renditionFilter);
+                IRI objectByIdRequest = objectByIdTemplate.generateUri(variables);
+
+                return new CMISTree(fixture.getTestCaseFolder(), client.getEntry(objectByIdRequest),
+                        CMISConstants.TYPE_DOCUMENT);
+            }
+        });
+    }
+
+    public void testObjectByPathRenditions() throws Exception {
+        // construct document
+        Entry document = fixture.createTestDocument("testObjectByPath");
+        Assert.assertNotNull(document);
+        
+        // Get path of its folder
+        final Entry folder = fixture.getTestCaseFolder();
+        Assert.assertNotNull(folder);
+        CMISObject folderObject = folder.getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(folderObject);
+        String folderPath = folderObject.getPath().getStringValue();
+        Assert.assertNotNull(folderPath);
+        
+        // Get path of the document within its folder 
+        Link parentLink = client.getObjectParentsLink(document);
+        Assert.assertNotNull(parentLink);
+        Feed parents = client.getFeed(parentLink.getHref(), Collections.singletonMap("includeRelativePathSegment", "true"));        
+        Entry parent = parents.getEntry(folder.getId().toString());        
+        Assert.assertNotNull(parent);
+        Element pathEl = parent.getFirstChild(CMISConstants.RELATIVE_PATH_SEGMENT);
+        Assert.assertNotNull(pathEl);
+        String relPath = pathEl.getText();
+        Assert.assertNotNull(relPath);
+        
+        // Generate the full path of the document
+        final String path = folderPath + '/' + relPath;
+
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+
+        // Create simple entry tree and walk it with the renditions visitor
+        EntryTree entryTree = new CMISTree(fixture.getTestCaseFolder(), document, CMISConstants.TYPE_DOCUMENT);
+        visitor.testRenditions(entryTree, new GatherRenditionsVisitor.EntryGenerator() {
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                // formulate get request via path
+                CMISUriTemplate objectByPathTemplate = client.getObjectByPathUriTemplate(client.getWorkspace());
+                Map<String, Object> variables = new HashMap<String, Object>();
+                variables.put("path", path);
+                variables.put("renditionFilter", renditionFilter);
+                IRI objectByPathRequest = objectByPathTemplate.generateUri(variables);
+
+                return new CMISTree(folder, client.getEntry(objectByPathRequest),
+                        CMISConstants.TYPE_DOCUMENT);
+            }
+        });
+    }
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryPagingTest.java Wed Jan 27 16:45:08 2010
@@ -79,6 +79,7 @@
         String queryReq = queryDoc.replace("${STATEMENT}", query);
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "4");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
         Response queryRes = client.executeRequest(new PostRequest(queryHREF.toString(), queryReq,
                 CMISConstants.MIMETYPE_CMIS_QUERY), 201);
         Assert.assertNotNull(queryRes);

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/QueryTest.java Wed Jan 27 16:45:08 2010
@@ -19,6 +19,7 @@
 
 import java.io.StringReader;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.Map;
 
 import org.apache.abdera.i18n.iri.IRI;
@@ -30,6 +31,9 @@
 import org.apache.chemistry.abdera.ext.CMISObject;
 import org.apache.chemistry.tck.atompub.TCKSkipCapabilityException;
 import org.apache.chemistry.tck.atompub.TCKTest;
+import org.apache.chemistry.tck.atompub.fixture.CMISTree;
+import org.apache.chemistry.tck.atompub.fixture.EntryTree;
+import org.apache.chemistry.tck.atompub.fixture.GatherRenditionsVisitor;
 import org.apache.chemistry.tck.atompub.http.PostRequest;
 import org.apache.chemistry.tck.atompub.http.Request;
 import org.apache.chemistry.tck.atompub.http.Response;
@@ -41,13 +45,13 @@
  */
 public class QueryTest extends TCKTest {
     
-    private Entry folder;
+    private EntryTree folder;
     private CMISObject folderObject;
-    private Entry document1;
+    private EntryTree document1;
     private CMISObject document1Object;
-    private Entry document2;
+    private EntryTree document2;
     private CMISObject document2Object;
-    private Entry document3;
+    private EntryTree document3;
     private CMISObject document3Object;
 
     @Override
@@ -55,16 +59,31 @@
         super.setUp();
 
         try {
-            folder = fixture.getTestCaseFolder();
-            folderObject = folder.getExtension(CMISConstants.OBJECT);
+            folder = new EntryTree();
+            folder.entry = fixture.getTestCaseFolder();
+            folder.type = CMISConstants.TYPE_FOLDER;
+            folder.children = new LinkedList<EntryTree>();
+            folderObject = folder.entry.getExtension(CMISConstants.OBJECT);
             // create documents to query
-            document1 = fixture.createTestDocument("apple1");
-            document1Object = document1.getExtension(CMISConstants.OBJECT);
+            document1 = new EntryTree();
+            folder.children.add(document1);
+            document1.parent = folder.entry;
+            document1.entry = fixture.createTestDocument("apple1");
+            document1.type = CMISConstants.TYPE_DOCUMENT;
+            document1Object = document1.entry.getExtension(CMISConstants.OBJECT);
             String doc2name = "name" + System.currentTimeMillis();
-            document2 = fixture.createTestDocument(doc2name);
-            document2Object = document2.getExtension(CMISConstants.OBJECT);
-            document3 = fixture.createTestDocument("banana1");
-            document3Object = document3.getExtension(CMISConstants.OBJECT);
+            document2 = new EntryTree();
+            folder.children.add(document2);
+            document2.parent = folder.entry;
+            document2.entry = fixture.createTestDocument(doc2name);
+            document2.type = CMISConstants.TYPE_DOCUMENT;
+            document2Object = document2.entry.getExtension(CMISConstants.OBJECT);
+            document3 = new EntryTree();
+            folder.children.add(document3);
+            document3.parent = folder.entry;
+            document3.entry = fixture.createTestDocument("banana1");
+            document3.type = CMISConstants.TYPE_DOCUMENT;
+            document3Object = document3.entry.getExtension(CMISConstants.OBJECT);
         } catch (Exception e) {
             // TODO: appropriate exception handling
             throw new RuntimeException(e);
@@ -89,6 +108,7 @@
         String queryReq = queryDoc.replace("${STATEMENT}", query);
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "5");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
         Request postReq = new PostRequest(queryHREF.toString(), queryReq,  CMISConstants.MIMETYPE_CMIS_QUERY);
         Response queryRes = client.executeRequest(postReq, 201);
@@ -96,8 +116,8 @@
         Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
         Assert.assertNotNull(queryFeed);
         Assert.assertEquals(1, queryFeed.getEntries().size());
-        Assert.assertNotNull(queryFeed.getEntry(folder.getId().toString()));
-        CMISObject result1 = queryFeed.getEntry(folder.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(queryFeed.getEntry(folder.entry.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(folder.entry.getId().toString()).getExtension(CMISConstants.OBJECT);
         Assert.assertEquals(folderObject.getName().getStringValue(), result1.getName().getStringValue());
         Assert.assertEquals(folderObject.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
         Assert.assertEquals(folderObject.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
@@ -122,6 +142,7 @@
         String queryReq = queryDoc.replace("${STATEMENT}", query);
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "5");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
         Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
         Response queryRes = client.executeRequest(postReq, 201);
@@ -129,8 +150,8 @@
         Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
         Assert.assertNotNull(queryFeed);
         Assert.assertEquals(1, queryFeed.getEntries().size());
-        Assert.assertNotNull(queryFeed.getEntry(document1.getId().toString()));
-        CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(queryFeed.getEntry(document1.entry.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document1.entry.getId().toString()).getExtension(CMISConstants.OBJECT);
         Assert.assertEquals(document1Object.getName().getStringValue(), result1.getName().getStringValue());
         Assert.assertEquals(document1Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
         Assert.assertEquals(document1Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
@@ -155,6 +176,7 @@
         String queryReq = queryDoc.replace("${STATEMENT}", query);
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "5");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
         Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
         Response queryRes = client.executeRequest(postReq, 201);
@@ -162,8 +184,8 @@
         Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
         Assert.assertNotNull(queryFeed);
         Assert.assertEquals(1, queryFeed.getEntries().size());
-        Assert.assertNotNull(queryFeed.getEntry(document2.getId().toString()));
-        CMISObject result1 = queryFeed.getEntry(document2.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(queryFeed.getEntry(document2.entry.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document2.entry.getId().toString()).getExtension(CMISConstants.OBJECT);
         Assert.assertEquals(document2Object.getName().getStringValue(), result1.getName().getStringValue());
         Assert.assertEquals(document2Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
         Assert.assertEquals(document2Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
@@ -189,6 +211,7 @@
         String queryReq = queryDoc.replace("${STATEMENT}", query);
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "5");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
         Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
         Response queryRes = client.executeRequest(postReq, 201);
@@ -196,13 +219,55 @@
         Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
         Assert.assertNotNull(queryFeed);
         Assert.assertEquals(1, queryFeed.getEntries().size());
-        Assert.assertNotNull(queryFeed.getEntry(document1.getId().toString()));
-        CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+        Assert.assertNotNull(queryFeed.getEntry(document1.entry.getId().toString()));
+        CMISObject result1 = queryFeed.getEntry(document1.entry.getId().toString()).getExtension(CMISConstants.OBJECT);
         Assert.assertEquals(document1Object.getName().getStringValue(), result1.getName().getStringValue());
         Assert.assertEquals(document1Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
         Assert.assertEquals(document1Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
     }
 
+    public void testQueryDocumentRenditions() throws Exception {
+        CMISCapabilities capabilities = client.getCapabilities();
+        String capability = capabilities.getQuery();
+        if (!capability.equals("bothcombined")) {
+                throw new TCKSkipCapabilityException("query", "bothcombined", capability);
+        }
+
+        final IRI queryHREF = client.getQueryCollection(client.getWorkspace());
+        final String queryDoc = templates.load("query.cmisquery.xml");
+
+        // combined meta data and full text
+        // TODO: use property query name
+        final String query = 
+                "SELECT cmis:ObjectId, cmis:ObjectTypeId, cmis:Name FROM cmis:document " + 
+                "WHERE IN_FOLDER('" + folderObject.getObjectId().getStringValue() + "') " +
+                "AND cmis:Name = 'apple1' " +
+                "AND CONTAINS('apple1')";
+        
+        GatherRenditionsVisitor visitor = new GatherRenditionsVisitor(client);
+        visitor.testRenditions(folder, new GatherRenditionsVisitor.EntryGenerator(){
+
+            public EntryTree getEntries(String renditionFilter) throws Exception {
+                String queryReq = queryDoc.replace("${STATEMENT}", query);
+                queryReq = queryReq.replace("${SKIPCOUNT}", "0");
+                queryReq = queryReq.replace("${MAXITEMS}", "5");
+                queryReq = queryReq.replace("${RENDITIONFILTER}", renditionFilter);
+
+                Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);
+                Response queryRes = client.executeRequest(postReq, 201);
+                Assert.assertNotNull(queryRes);
+                Feed queryFeed = model.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+                Assert.assertNotNull(queryFeed);
+                Assert.assertEquals(1, queryFeed.getEntries().size());
+                Assert.assertNotNull(queryFeed.getEntry(document1.entry.getId().toString()));
+                CMISObject result1 = queryFeed.getEntry(document1.entry.getId().toString()).getExtension(CMISConstants.OBJECT);
+                Assert.assertEquals(document1Object.getName().getStringValue(), result1.getName().getStringValue());
+                Assert.assertEquals(document1Object.getObjectId().getStringValue(), result1.getObjectId().getStringValue());
+                Assert.assertEquals(document1Object.getObjectTypeId().getStringValue(), result1.getObjectTypeId().getStringValue());
+                return new CMISTree(folder, queryFeed);
+            }});
+    }
+
     public void testQueryAllowableActions() throws Exception {
         CMISCapabilities capabilities = client.getCapabilities();
         String capability = capabilities.getQuery();
@@ -222,6 +287,7 @@
         queryReq = queryReq.replace("${INCLUDEALLOWABLEACTIONS}", "true");
         queryReq = queryReq.replace("${SKIPCOUNT}", "0");
         queryReq = queryReq.replace("${MAXITEMS}", "5");
+        queryReq = queryReq.replace("${RENDITIONFILTER}", "cmis:none");
 
         // issue structured query
         Request postReq = new PostRequest(queryHREF.toString(), queryReq, CMISConstants.MIMETYPE_CMIS_QUERY);

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image1.jpg
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image1.jpg?rev=903726&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image1.jpg
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image1.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image2.png
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image2.png?rev=903726&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image2.png
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/images/image2.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/createdocumentBase64.cmisatomentry.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/createdocumentBase64.cmisatomentry.xml?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/createdocumentBase64.cmisatomentry.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/createdocumentBase64.cmisatomentry.xml Wed Jan 27 16:45:08 2010
@@ -7,7 +7,7 @@
   <summary>${NAME} (summary)</summary>
   <content type="text">Must be ignored - overridden by cmisra:content</content>
   <cmisra:content>
-    <cmisra:mediatype>text/plain</cmisra:mediatype>
+    <cmisra:mediatype>${CMISTYPE}</cmisra:mediatype>
     <cmisra:base64>${CMISCONTENT}</cmisra:base64>
   </cmisra:content>
   <cmisra:object>

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/query.cmisquery.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/query.cmisquery.xml?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/query.cmisquery.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/query.cmisquery.xml Wed Jan 27 16:45:08 2010
@@ -2,4 +2,5 @@
   <cmis:statement><![CDATA[${STATEMENT}]]></cmis:statement>
   <cmis:skipCount>${SKIPCOUNT}</cmis:skipCount>
   <cmis:maxItems>${MAXITEMS}</cmis:maxItems>
+  <cmis:renditionFilter>${RENDITIONFILTER}</cmis:renditionFilter>
 </cmis:query>

Modified: incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/queryallowableactions.cmisquery.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/queryallowableactions.cmisquery.xml?rev=903726&r1=903725&r2=903726&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/queryallowableactions.cmisquery.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/resources/org/apache/chemistry/tck/atompub/templates/queryallowableactions.cmisquery.xml Wed Jan 27 16:45:08 2010
@@ -3,4 +3,5 @@
   <cmis:includeAllowableActions>${INCLUDEALLOWABLEACTIONS}</cmis:includeAllowableActions>
   <cmis:skipCount>${SKIPCOUNT}</cmis:skipCount>
   <cmis:maxItems>${MAXITEMS}</cmis:maxItems>
+  <cmis:renditionFilter>${RENDITIONFILTER}</cmis:renditionFilter>
 </cmis:query>



Mime
View raw message