chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject 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
Date Wed, 06 Oct 2010 16:20:14 GMT
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
     {



Mime
View raw message