Author: johnh
Date: Fri Apr 30 22:06:20 2010
New Revision: 939842

URL: http://svn.apache.org/viewvc?rev=939842&view=rev
Log:
Updates and fixes, per Jacobo Tarrio's review comments.


Modified:
    
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
    
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/MutableContentTest.java

Modified: 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java?rev=939842&r1=939841&r2=939842&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
 Fri Apr 30 22:06:20 2010
@@ -123,10 +123,8 @@ public class MutableContent {
   }
 
   /**
-   * Retrieves the current content for this object as bytes.
-   * The returned byte array should be treated as immutable. If it
-   * is modified, resultant behavior is
-   * @return Active content as bytes.
+   * Retrieves the current content for this object as an InputStream.
+   * @return Active content as InputStream.
    */
   public InputStream getContentBytes() {
     if (contentBytes == null) {
@@ -160,7 +158,7 @@ public class MutableContent {
    * @param newBytes New content.
    */
   public void setContentBytes(byte[] newBytes) {
-    if (contentBytes == null || Arrays.equals(contentBytes, newBytes)) {
+    if (contentBytes == null || !Arrays.equals(contentBytes, newBytes)) {
       contentBytes = newBytes;
       document = null;
       contentSource = null;

Modified: 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/MutableContentTest.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/MutableContentTest.java?rev=939842&r1=939841&r2=939842&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/MutableContentTest.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/MutableContentTest.java
 Fri Apr 30 22:06:20 2010
@@ -64,7 +64,7 @@ public class MutableContentTest {
   }
 
   @Test
-  public void modifyContentReflectedInTree() throws Exception {
+  public void modifyContentReflectedInTreeAndBytes() throws Exception {
     assertEquals(0, mhc.getNumChanges());
     mhc.setContent("NEW CONTENT");
     assertEquals(1, mhc.getNumChanges());
@@ -77,6 +77,20 @@ public class MutableContentTest {
   }
   
   @Test
+  public void modifyContentReflectedInTreeUtf8() throws Exception {
+    String theContent = "NèW C¯NTéNT";
+    assertEquals(0, mhc.getNumChanges());
+    mhc.setContent(theContent);
+    assertEquals(1, mhc.getNumChanges());
+    assertEquals(theContent, new 
String(IOUtils.toByteArray(mhc.getContentBytes()), "UTF8"));
+    Document document = mhc.getDocument();
+    assertEquals(1, document.getChildNodes().getLength());
+    assertEquals(theContent, 
document.getChildNodes().item(0).getTextContent());
+    mhc.documentChanged();
+    assertEquals(2, mhc.getNumChanges());
+  }
+  
+  @Test
   public void modifyBytesReflectedInContentAndTree() throws Exception {
     assertEquals(0, mhc.getNumChanges());
     mhc.setContentBytes("NEW CONTENT".getBytes("UTF8"));
@@ -90,7 +104,7 @@ public class MutableContentTest {
     assertEquals("NEW CONTENT", new String(IOUtils.toByteArray(is), "UTF8"));
     assertEquals(1, mhc.getNumChanges());
   }
-
+  
   @Test
   public void modifyTreeReflectedInContent() throws Exception {
     Document document = mhc.getDocument();


Reply via email to