You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/10/06 18:20:14 UTC

svn commit: r1005105 - in /incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub: client/CMISClient.java test/spec/CreateTest.java

Author: dcaruana
Date: Wed Oct  6 16:20:14 2010
New Revision: 1005105

URL: http://svn.apache.org/viewvc?rev=1005105&view=rev
Log:
AtomPub TCK: Modify create tests to use appropriate base64 encoding for text/* mime types

Modified:
    incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
    incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java

Modified: incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java?rev=1005105&r1=1005104&r2=1005105&view=diff
==============================================================================
--- incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java (original)
+++ incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/client/CMISClient.java Wed Oct  6 16:20:14 2010
@@ -410,14 +410,14 @@ public class CMISClient {
                         : "createdocumentBase64.cmisatomentry.xml") : atomEntryFile);
         createFile = createFile.replace("${NAME}", name);
         createFile = createFile.replace("${TYPE}", type);
-        createFile = createFile.replace("${CONTENTTYPE}", contentType == null ? "text/plain" : contentType);
+        createFile = createFile.replace("${CONTENTTYPE}", contentType == null ? "text" : contentType);
 
         // determine if creating content via mediatype
         Entry createEntry = appModel.parseEntry(new StringReader(createFile), null);
         MimeType mimeType = createEntry.getContentMimeType();
 
         if (content != null) {
-            createFile = createFile.replace("${CONTENT}", mimeType == null ? content : new String(Base64
+            createFile = createFile.replace("${CONTENT}", mimeType == null || mimeType.getPrimaryType().equals("text") ? content : new String(Base64
                     .encodeBase64(content.getBytes("UTF-8")), "8859_1"));
         }
 

Modified: incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java?rev=1005105&r1=1005104&r2=1005105&view=diff
==============================================================================
--- incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java (original)
+++ incubator/chemistry/tck/trunk/chemistry-tck-atompub/src/main/java/org/apache/chemistry/tck/atompub/test/spec/CreateTest.java Wed Oct  6 16:20:14 2010
@@ -57,7 +57,7 @@ public class CreateTest extends TCKTest
         Feed children = client.getFeed(childrenLink.getHref());
         Assert.assertNotNull(children);
         int entriesBefore = children.getEntries().size();
-        Entry document = client.createDocument(children.getSelfLink().getHref(), null, "testCreateDocumentCMISContent", "createdocumentBase64.cmisatomentry.xml");
+        Entry document = client.createDocument(children.getSelfLink().getHref(), null, "testCreateDocumentCMISContent", "createdocumentBase64.cmisatomentry.xml", false, null, "text/plain", null);
         Response documentContentRes = client.executeRequest(new GetRequest(document.getContentSrc().toString()), 200);
         String resContent = documentContentRes.getContentAsString();
         Assert.assertEquals(document.getTitle(), resContent);
@@ -88,6 +88,27 @@ public class CreateTest extends TCKTest
         Assert.assertNotNull(entry);
     }
 
+    public void testCreateDocumentAtomContentWithMimeType()
+        throws Exception
+    {
+        Entry testFolder = fixture.getTestCaseFolder();
+        Link childrenLink = client.getChildrenLink(testFolder);
+        Assert.assertNotNull(childrenLink);
+        Feed children = client.getFeed(childrenLink.getHref());
+        Assert.assertNotNull(children);
+        int entriesBefore = children.getEntries().size();
+        Entry document = client.createDocument(children.getSelfLink().getHref(), null, "testCreateDocumentAtomContentWithMimeType", 
+                "createdocument.atomentry.xml", false, "testCreateDocumentAtomContentWithMimeType", "text/plain", null);
+        Response documentContentRes = client.executeRequest(new GetRequest(document.getContentSrc().toString()), 200);
+        String resContent = documentContentRes.getContentAsString();
+        Assert.assertEquals(document.getTitle(), resContent);
+        Feed feedFolderAfter = client.getFeed(childrenLink.getHref());
+        int entriesAfter = feedFolderAfter.getEntries().size();
+        Assert.assertEquals(entriesBefore +1, entriesAfter);
+        Entry entry = feedFolderAfter.getEntry(document.getId().toString());
+        Assert.assertNotNull(entry);
+    }
+
     public void testCreateAtomEntry()
         throws Exception
     {