This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question about getEncoding method on different platforms


I have testcases that are failing across several platforms because the encoding value that is returned from the different platforms does not match the
8859_1 value that is being expected by the testcase. Example the value of ASCII is returned for Sun and Linux. 

Question: Should the mauve code be changed to reflect the correct values expected for each platform ?

Code:
gnu/testlet/java/io/InputStreamReader/jdk11.java

// Tags: JDK1.1

package gnu.testlet.java.io.InputStreamReader;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;

import java.io.*;

public class jdk11 implements Testlet
{
  public void test (TestHarness harness)
  {
    try
      {
                InputStreamReader isr = new InputStreamReader (new StringBufferInputStream ("zardoz has spoken"));
                harness.check(!isr.ready(), "ready()");   // deprecated post-1.1
                harness.check(isr.getEncoding(), "8859_1", "getEncoding");
                char[] cbuf = new char[10];
                isr.read (cbuf, 0, cbuf.length);
                String tst = new String(cbuf);
                harness.check(tst, "zardoz has", "read(buf[], off, len)");
                harness.check(isr.read(), ' ', "read()");
                isr.close ();
                harness.check(true, "close()");
      }
    catch (IOException e)
      {
                harness.check(false, "IOException unexpected");
      }
  }
}

gnu/testlet/java/io/OutputStreamWriter/jdk11.java

// Tags: JDK1.1

package gnu.testlet.java.io.OutputStreamWriter;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.io.OutputStreamWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class jdk11 implements Testlet
{
  public void test (TestHarness harness)
  {
    try
      {
                String tstr = "ABCDEFGH";
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                OutputStreamWriter osw = new OutputStreamWriter (baos);  //Default encoding
                harness.check(true, "OutputStreamWriter(writer)");
                harness.check(osw.getEncoding(), "8859_1", "getEncoding");
                osw.write(tstr.charAt(0));                                      // 'A'
                harness.check(true,"write(int)");
                osw.write("ABCDE", 1, 3);                                       // 'ABCD'
                harness.check(true,"write(string, off, len)");
                char[] cbuf = new char[8];
                tstr.getChars(4, 8, cbuf, 0);
                osw.write(cbuf, 0, 4);                                          // 'ABCDEFGH'
                harness.check(true,"write(char[], off, len)");
                osw.flush();
                harness.check(true, "flush()");
                harness.check(baos.toString(), tstr, "Wrote all characters okay");
                osw.close ();
                harness.check(true, "close()");
                ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
                OutputStreamWriter osw2 = new OutputStreamWriter(baos2, "8859_3");
                harness.check(osw2.getEncoding(), "8859_3", "OutputStreamWriter(writer, encoding)");

      }
    catch (IOException e)
      {
                harness.check(false, "IOException unexpected");
      }
  }
}



>From JavaTM 2 Platform
Std. Ed. v1.4.1
getEncoding
public String <../../java/lang/String.html>  getEncoding()
	Return the name of the character encoding being used by this stream. 
	If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned. 
	If this instance was created with the OutputStreamWriter(OutputStream, String) <../../java/io/OutputStreamWriter.html>  constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method may return null if the stream has been closed. 
Returns: 
	The historical name of this encoding, or possibly null if the stream has been closed 
See Also: 
	Charset <../../java/nio/charset/Charset.html> 



Pat Ellis
SDE Build and Test Team
Phone:      (919) 531-0355   
R2263     Patrick dot Ellis at sas dot com
SAS...  The Power to Know


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]