cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r727757 - in /cocoon/cocoon3/trunk/cocoon-stax: ./ src/test/java/org/apache/cocoon/stax/ src/test/java/org/apache/cocoon/stax/testImpls/ src/test/resources/org/ src/test/resources/org/apache/ src/test/resources/org/apache/cocoon/ src/test/r...
Date Thu, 18 Dec 2008 16:03:10 GMT
Author: reinhard
Date: Thu Dec 18 08:03:09 2008
New Revision: 727757

URL: http://svn.apache.org/viewvc?rev=727757&view=rev
Log:
. (hopefully) fix a bug with reading files that only occurs in some environments (failed with
Java 1.6, Ubuntu 64-bit)
. use commons-io and standard API to deal with streams and strings
. use same packages for test

Added:
    cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
  (contents, props changed)
      - copied, changed from r727687, cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/testImpls/simple/StAXPipelineTest.java
    cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/org/
    cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/org/apache/
    cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/org/apache/cocoon/
    cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/org/apache/cocoon/stax/   (props changed)
      - copied from r727687, cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/simple/
Removed:
    cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/testImpls/
    cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/simple/
Modified:
    cocoon/cocoon3/trunk/cocoon-stax/pom.xml

Modified: cocoon/cocoon3/trunk/cocoon-stax/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stax/pom.xml?rev=727757&r1=727756&r2=727757&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stax/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-stax/pom.xml Thu Dec 18 08:03:09 2008
@@ -53,6 +53,11 @@
     </dependency>
 
     <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Copied: cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
(from r727687, cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/testImpls/simple/StAXPipelineTest.java)
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java?p2=cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java&p1=cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/testImpls/simple/StAXPipelineTest.java&r1=727687&r2=727757&rev=727757&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/testImpls/simple/StAXPipelineTest.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
Thu Dec 18 08:03:09 2008
@@ -14,22 +14,18 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.cocoon.stax.testImpls.simple;
+package org.apache.cocoon.stax;
 
 import static org.junit.Assert.*;
 
-import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.cocoon.pipeline.NonCachingPipeline;
 import org.apache.cocoon.pipeline.Pipeline;
 import org.apache.cocoon.pipeline.SetupException;
 import org.apache.cocoon.pipeline.component.sax.StringGenerator;
-import org.apache.cocoon.stax.StAXGenerator;
-import org.apache.cocoon.stax.StAXSerializer;
+import org.apache.commons.io.IOUtils;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Test;
@@ -46,7 +42,7 @@
      */
     @Test
     public void testProducerConsumer() throws Exception {
-        InputStream input = StAXPipelineTest.class.getResource("/simple/simple.xml").openStream();
+        InputStream input = StAXPipelineTest.class.getResource("simple.xml").openStream();
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
@@ -56,8 +52,8 @@
         pipe.setup(out);
         pipe.execute();
 
-        String created = this.readByteArrayOutputStreamToString(out);
-        String correctOne = this.readTextFile("/simple/simple.xml");
+        String created = out.toString();
+        String correctOne = IOUtils.toString(StAXPipelineTest.class.getResource("simple.xml").openStream());
 
         XMLUnit.setIgnoreWhitespace(true);
         Diff myDiff = new Diff(correctOne, created);
@@ -79,29 +75,4 @@
             fail("Mixing wrong components which has to result in a SetupException");
         }
     }
-
-    private String readTextFile(String relativePath) throws IOException {
-        StringBuffer sb = new StringBuffer(1024);
-        BufferedReader reader = new BufferedReader(new FileReader(StAXPipelineTest.class.getResource(relativePath).getFile()));
-
-        char[] chars = new char[1];
-        while (reader.read(chars) > -1) {
-            sb.append(String.valueOf(chars));
-        }
-
-        reader.close();
-
-        return sb.toString();
-    }
-
-    private String readByteArrayOutputStreamToString(ByteArrayOutputStream out) {
-        byte[] output = out.toByteArray();
-        StringBuffer buffer = new StringBuffer();
-
-        for (byte b : output) {
-            buffer.append(String.valueOf((char) b));
-        }
-
-        return buffer.toString();
-    }
 }

Propchange: cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: cocoon/cocoon3/trunk/cocoon-stax/src/test/java/org/apache/cocoon/stax/StAXPipelineTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: cocoon/cocoon3/trunk/cocoon-stax/src/test/resources/org/apache/cocoon/stax/
------------------------------------------------------------------------------
    svn:mergeinfo = 



Mime
View raw message