01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (license2)
04: * Initial Developer: H2 Group
05: */
06: package org.h2.test.unit;
07:
08: import java.io.ByteArrayInputStream;
09: import java.io.InputStream;
10: import java.io.Reader;
11: import java.io.StringReader;
12:
13: import org.h2.test.TestBase;
14: import org.h2.util.IOUtils;
15:
16: /**
17: * Tests the stream to UTF-8 reader conversion.
18: */
19: public class TestReader extends TestBase {
20:
21: public void test() throws Exception {
22: String s = "\u00ef\u00f6\u00fc";
23: StringReader r = new StringReader(s);
24: InputStream in = IOUtils.getInputStream(r);
25: byte[] buff = IOUtils.readBytesAndClose(in, 0);
26: InputStream in2 = new ByteArrayInputStream(buff);
27: Reader r2 = IOUtils.getReader(in2);
28: String s2 = IOUtils.readStringAndClose(r2, Integer.MAX_VALUE);
29: check(s2, "\u00ef\u00f6\u00fc");
30: }
31:
32: }
|