uima-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twgo...@apache.org
Subject svn commit: r704118 - in /incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima: analysis_engine/impl/ analysis_engine/impl/metadata/ cas/test/ collection/impl/ resource/impl/ resource/metadata/impl/
Date Mon, 13 Oct 2008 13:35:15 GMT
Author: twgoetz
Date: Mon Oct 13 06:35:14 2008
New Revision: 704118

URL: http://svn.apache.org/viewvc?rev=704118&view=rev
Log:
Jira UIMA-1202: add proper encoding handling to various test cases.

https://issues.apache.org/jira/browse/UIMA-1202

Modified:
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngineDescription_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/PearSpecifier_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/TestResourceInterface_impl.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/URISpecifier_implTest.java
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/Import_implTest.java

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngineDescription_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngineDescription_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngineDescription_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/AnalysisEngineDescription_implTest.java
Mon Oct 13 06:35:14 2008
@@ -84,6 +84,11 @@
  * 
  */
 public class AnalysisEngineDescription_implTest extends TestCase {
+
+  // Text encoding to use for the various byte/character conversions happening in this test
case.
+  // Public because also used by other test cases.
+  public static final String encoding = "utf-8";
+  
   /**
    * Constructor for AnalysisEngineDescription_implTest.
    * 
@@ -275,10 +280,10 @@
       // System.out.println(aggregateDescXml);
 
       // parse objects from XML
-      InputStream is = new ByteArrayInputStream(primitiveDescXml.getBytes());
+      InputStream is = new ByteArrayInputStream(primitiveDescXml.getBytes(encoding));
       AnalysisEngineDescription newPrimitiveDesc = (AnalysisEngineDescription) UIMAFramework
               .getXMLParser().parse(new XMLInputSource(is, null));
-      is = new ByteArrayInputStream(aggregateDescXml.getBytes());
+      is = new ByteArrayInputStream(aggregateDescXml.getBytes(encoding));
       AnalysisEngineDescription newAggregateDesc = (AnalysisEngineDescription) UIMAFramework
               .getXMLParser().parse(new XMLInputSource(is, null));
 
@@ -296,7 +301,7 @@
       writer = new StringWriter();
       desc.toXML(writer);
       String descXml = writer.getBuffer().toString();
-      is = new ByteArrayInputStream(descXml.getBytes());
+      is = new ByteArrayInputStream(descXml.getBytes(encoding));
       AnalysisEngineDescription newDesc = (AnalysisEngineDescription) UIMAFramework.getXMLParser()
               .parse(new XMLInputSource(is, null));
       Assert.assertEquals(desc, newDesc);
@@ -308,7 +313,7 @@
       writer = new StringWriter();
       desc.toXML(writer);
       descXml = writer.getBuffer().toString();
-      is = new ByteArrayInputStream(descXml.getBytes());
+      is = new ByteArrayInputStream(descXml.getBytes(encoding));
       newDesc = (AnalysisEngineDescription) UIMAFramework.getXMLParser().parse(
               new XMLInputSource(is, null));
       Assert.assertEquals(desc, newDesc);

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ResultSpecification_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.analysis_engine.impl;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -528,7 +530,7 @@
       // System.out.println(rsXml);
 
       // parse object back from XML
-      InputStream is = new ByteArrayInputStream(rsXml.getBytes());
+      InputStream is = new ByteArrayInputStream(rsXml.getBytes(encoding));
       ResultSpecification newRS = UIMAFramework.getXMLParser().parseResultSpecification(
               new XMLInputSource(is, null));
       TypeOrFeature[] tofs = newRS.getResultTypesAndFeatures();

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TaeDescription_implTest.java
Mon Oct 13 06:35:14 2008
@@ -66,6 +66,8 @@
 import org.apache.uima.test.junit_extension.JUnitExtension;
 import org.apache.uima.util.XMLInputSource;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 /**
  * Test the TaeDescription_impl class.
  * 
@@ -251,10 +253,10 @@
       // System.out.println(aggregateDescXml);
 
       // parse objects back from XML
-      InputStream is = new ByteArrayInputStream(primitiveDescXml.getBytes());
+      InputStream is = new ByteArrayInputStream(primitiveDescXml.getBytes(encoding));
       AnalysisEngineDescription newPrimitiveDesc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
               new XMLInputSource(is, null));
-      is = new ByteArrayInputStream(aggregateDescXml.getBytes());
+      is = new ByteArrayInputStream(aggregateDescXml.getBytes(encoding));
       AnalysisEngineDescription newAggregateDesc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
               new XMLInputSource(is, null));
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/metadata/SofaMapping_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.analysis_engine.impl.metadata;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -63,10 +65,10 @@
       sm2.toXML(writer);
       String sm2Xml = writer.getBuffer().toString();
       // parse from XML
-      InputStream is = new ByteArrayInputStream(sm1Xml.getBytes());
+      InputStream is = new ByteArrayInputStream(sm1Xml.getBytes(encoding));
       SofaMapping_impl newSm1 = (SofaMapping_impl) UIMAFramework.getXMLParser().parse(
               new XMLInputSource(is, null));
-      is = new ByteArrayInputStream(sm2Xml.getBytes());
+      is = new ByteArrayInputStream(sm2Xml.getBytes(encoding));
       SofaMapping_impl newSm2 = (SofaMapping_impl) UIMAFramework.getXMLParser().parse(
               new XMLInputSource(is, null));
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,7 @@
 
 package org.apache.uima.cas.test;
 
+import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -27,7 +28,9 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.Reader;
 import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -552,6 +555,7 @@
   }
   
   public void testSetSofaDataURIonInitialView() throws Exception {
+    // This test uses platform encoding both for reading and writing.  
     String someText="remote text.";
     String someTextFile="./someUriText.txt";
     FileWriter output = new FileWriter(someTextFile);
@@ -566,13 +570,20 @@
     
     InputStream is = this.cas.getSofaDataStream();
     assertTrue(is != null);
-    byte[] dest = new byte[1];
-    StringBuffer buf = new StringBuffer();
-    while (is.read(dest) != -1) {
-      buf.append((char) dest[0]);
-    }
+
+    // This obviously can't work on all platforms
+//    byte[] dest = new byte[1];
+//    StringBuffer buf = new StringBuffer();
+//    while (is.read(dest) != -1) {
+//      buf.append((char) dest[0]);
+//    }
+//    is.close();
+//    assertTrue(buf.toString().equals(someText));
+    
+    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+    String textFromFile = reader.readLine();
     is.close();
-    assertTrue(buf.toString().equals(someText));
+    assertTrue(textFromFile.equals(someText));
     File testFile = new File(someTextFile);
     assertTrue(testFile.delete());
   }

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasConsumerDescription_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.collection.impl;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -189,7 +191,7 @@
       // System.out.println(testDescXml);
 
       // parse objects from XML (no schema validation)
-      InputStream is = new ByteArrayInputStream(testDescXml.getBytes());
+      InputStream is = new ByteArrayInputStream(testDescXml.getBytes(encoding));
       CasConsumerDescription newDesc = (CasConsumerDescription) UIMAFramework.getXMLParser().parse(
               new XMLInputSource(is, null));
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CasInitializerDescription_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.collection.impl;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -189,7 +191,7 @@
       // System.out.println(testDescXml);
 
       // parse objects from XML (no schema validation)
-      InputStream is = new ByteArrayInputStream(testDescXml.getBytes());
+      InputStream is = new ByteArrayInputStream(testDescXml.getBytes(encoding));
       CasInitializerDescription newDesc = (CasInitializerDescription) UIMAFramework.getXMLParser()
               .parse(new XMLInputSource(is, null));
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/collection/impl/CollectionReaderDescription_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.collection.impl;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -189,7 +191,7 @@
       // System.out.println(testDescXml);
 
       // parse objects from XML (no schema validation)
-      InputStream is = new ByteArrayInputStream(testDescXml.getBytes());
+      InputStream is = new ByteArrayInputStream(testDescXml.getBytes(encoding));
       CollectionReaderDescription newDesc = (CollectionReaderDescription) UIMAFramework
               .getXMLParser().parse(new XMLInputSource(is, null));
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/DataResource_implTest.java
Mon Oct 13 06:35:14 2008
@@ -107,7 +107,7 @@
 
       // try to get an input stream and read from the file
       InputStream inStr = dr.getInputStream();
-      BufferedReader bufRdr = new BufferedReader(new InputStreamReader(inStr));
+      BufferedReader bufRdr = new BufferedReader(new InputStreamReader(inStr, "utf-8"));
       String result = bufRdr.readLine();
       inStr.close();
 

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/PearSpecifier_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/PearSpecifier_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/PearSpecifier_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/PearSpecifier_implTest.java
Mon Oct 13 06:35:14 2008
@@ -30,6 +30,8 @@
 import org.apache.uima.test.junit_extension.JUnitExtension;
 import org.apache.uima.util.XMLInputSource;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 /**
  * PearSpecifier creation and Xmlization test
  */
@@ -88,7 +90,7 @@
       StringWriter sw = new StringWriter();
       pearSpec.toXML(sw);
       PearSpecifier pearSpec2 = (PearSpecifier) UIMAFramework.getXMLParser().parse(
-              new XMLInputSource(new ByteArrayInputStream(sw.getBuffer().toString().getBytes()),
+              new XMLInputSource(new ByteArrayInputStream(sw.getBuffer().toString().getBytes(encoding)),
                       null));
       assertEquals(pearSpec, pearSpec2);
     } catch (Exception e) {

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/TestResourceInterface_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/TestResourceInterface_impl.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/TestResourceInterface_impl.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/TestResourceInterface_impl.java
Mon Oct 13 06:35:14 2008
@@ -46,7 +46,7 @@
     try {
       // try to get an input stream and read from the file
       InputStream inStr = aData.getInputStream();
-      BufferedReader bufRdr = new BufferedReader(new InputStreamReader(inStr));
+      BufferedReader bufRdr = new BufferedReader(new InputStreamReader(inStr, "utf-8"));
       mString = bufRdr.readLine();
       inStr.close();
     } catch (IOException e) {

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/URISpecifier_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/URISpecifier_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/URISpecifier_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/impl/URISpecifier_implTest.java
Mon Oct 13 06:35:14 2008
@@ -19,6 +19,8 @@
 
 package org.apache.uima.resource.impl;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
+
 import java.io.ByteArrayInputStream;
 import java.io.StringWriter;
 
@@ -46,7 +48,7 @@
       StringWriter sw = new StringWriter();
       uriSpec.toXML(sw);
       URISpecifier uriSpec2 = (URISpecifier) UIMAFramework.getXMLParser().parse(
-              new XMLInputSource(new ByteArrayInputStream(sw.getBuffer().toString().getBytes()),
+              new XMLInputSource(new ByteArrayInputStream(sw.getBuffer().toString().getBytes(encoding)),
                       null));
       assertEquals(uriSpec, uriSpec2);
     } catch (Exception e) {

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/Import_implTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/Import_implTest.java?rev=704118&r1=704117&r2=704118&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/Import_implTest.java
(original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/resource/metadata/impl/Import_implTest.java
Mon Oct 13 06:35:14 2008
@@ -36,6 +36,7 @@
 import org.apache.uima.util.XMLInputSource;
 import org.w3c.dom.Document;
 
+import static org.apache.uima.analysis_engine.impl.AnalysisEngineDescription_implTest.encoding;
 
 public class Import_implTest extends TestCase {
 
@@ -69,7 +70,7 @@
 
       // name import
       String importXml = "<import name=\"this.is.a.test\"/>";
-      Document importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes()));
+      Document importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
       Import_impl importObj = new Import_impl();
       importObj.buildFromXMLElement(importDoc.getDocumentElement(), null);
       assertEquals("this.is.a.test", importObj.getName());
@@ -77,7 +78,7 @@
 
       // location import
       importXml = "<import location=\"foo/bar/MyFile.xml\"/>";
-      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes()));
+      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
       importObj = new Import_impl();
       importObj.buildFromXMLElement(importDoc.getDocumentElement(), null);
       assertEquals("foo/bar/MyFile.xml", importObj.getLocation());
@@ -85,7 +86,7 @@
 
       // invalid - both location and name
       importXml = "<import name=\"this.is.a.test\" location=\"foo/bar/MyFile.xml\"/>";
-      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes()));
+      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
       importObj = new Import_impl();
       InvalidXMLException ex = null;
       try {
@@ -97,7 +98,7 @@
 
       // invalid - empty import
       importXml = "<import/>";
-      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes()));
+      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
       importObj = new Import_impl();
       ex = null;
       try {



Mime
View raw message