Search in sources :

Example 16 with Support_OutputStream

use of tests.support.Support_OutputStream in project j2objc by google.

the class OldOutputStreamWriterTest method test_ConstructorLjava_io_OutputStreamLjava_nio_charset_Charset.

public void test_ConstructorLjava_io_OutputStreamLjava_nio_charset_Charset() throws IOException {
    OutputStreamWriter writer;
    Support_OutputStream out = new Support_OutputStream();
    Charset cs = Charset.forName("ascii");
    try {
        writer = new OutputStreamWriter(null, cs);
        fail("Test 1: NullPointerException expected.");
    } catch (NullPointerException e) {
    // Expected
    }
    try {
        writer = new OutputStreamWriter(out, (Charset) null);
        fail("Test 2: NullPointerException expected.");
    } catch (NullPointerException e) {
    // Expected
    }
    writer = new OutputStreamWriter(out, cs);
    assertEquals("Test 3: Encoding not set correctly. ", cs, Charset.forName(writer.getEncoding()));
    writer.close();
}
Also used : Support_OutputStream(tests.support.Support_OutputStream) Charset(java.nio.charset.Charset) OutputStreamWriter(java.io.OutputStreamWriter)

Example 17 with Support_OutputStream

use of tests.support.Support_OutputStream in project j2objc by google.

the class OldOutputStreamWriterTest method test_ConstructorLjava_io_OutputStreamLjava_nio_charset_CharsetEncoder.

public void test_ConstructorLjava_io_OutputStreamLjava_nio_charset_CharsetEncoder() throws IOException {
    OutputStreamWriter writer;
    Support_OutputStream out = new Support_OutputStream();
    Charset cs = Charset.forName("ascii");
    CharsetEncoder enc = cs.newEncoder();
    try {
        writer = new OutputStreamWriter(null, enc);
        fail("Test 1: NullPointerException expected.");
    } catch (NullPointerException e) {
    // Expected
    }
    try {
        writer = new OutputStreamWriter(out, (CharsetEncoder) null);
        fail("Test 2: NullPointerException expected.");
    } catch (NullPointerException e) {
    // Expected
    }
    writer = new OutputStreamWriter(out, cs);
    assertEquals("Test 3: CharacterEncoder not set correctly. ", cs, Charset.forName(writer.getEncoding()));
    writer.close();
}
Also used : Support_OutputStream(tests.support.Support_OutputStream) Charset(java.nio.charset.Charset) OutputStreamWriter(java.io.OutputStreamWriter) CharsetEncoder(java.nio.charset.CharsetEncoder)

Example 18 with Support_OutputStream

use of tests.support.Support_OutputStream in project j2objc by google.

the class OldOutputStreamWriterTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    fos = new Support_OutputStream(500);
    osw = new OutputStreamWriter(fos, "UTF-8");
}
Also used : Support_OutputStream(tests.support.Support_OutputStream) OutputStreamWriter(java.io.OutputStreamWriter)

Example 19 with Support_OutputStream

use of tests.support.Support_OutputStream in project j2objc by google.

the class OldOutputStreamWriterTest method test_getEncoding.

public void test_getEncoding() throws IOException {
    OutputStreamWriter writer;
    writer = new OutputStreamWriter(new Support_OutputStream(), "utf-8");
    assertEquals("Test 1: Incorrect encoding returned.", Charset.forName("utf-8"), Charset.forName(writer.getEncoding()));
    writer.close();
    assertNull("Test 2: getEncoding() did not return null for a closed writer.", writer.getEncoding());
}
Also used : Support_OutputStream(tests.support.Support_OutputStream) OutputStreamWriter(java.io.OutputStreamWriter)

Example 20 with Support_OutputStream

use of tests.support.Support_OutputStream in project j2objc by google.

the class OldDataOutputStreamTest method setUp.

protected void setUp() {
    sos = new Support_OutputStream(true);
    bos = new ByteArrayOutputStream();
    os = new DataOutputStream(bos);
}
Also used : Support_OutputStream(tests.support.Support_OutputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

Support_OutputStream (tests.support.Support_OutputStream)48 IOException (java.io.IOException)30 ByteArrayOutputStream (java.io.ByteArrayOutputStream)16 OutputStreamWriter (java.io.OutputStreamWriter)16 FilterOutputStream (java.io.FilterOutputStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 BufferedOutputStream (java.io.BufferedOutputStream)6 ObjectOutputStream (java.io.ObjectOutputStream)6 DataOutputStream (java.io.DataOutputStream)4 Charset (java.nio.charset.Charset)4 ObjectInputStream (java.io.ObjectInputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 CharsetEncoder (java.nio.charset.CharsetEncoder)2 DigestOutputStream (java.security.DigestOutputStream)2 MessageDigest (java.security.MessageDigest)2