Search in sources :

Example 71 with StringReader

use of java.io.StringReader in project j2objc by google.

the class OldBufferedReaderTest method test_readLine_interaction_with_read.

public void test_readLine_interaction_with_read() throws Exception {
    BufferedReader r = new BufferedReader(new StringReader("1\r\n2"));
    assertEquals('1', r.read());
    assertEquals('\r', r.read());
    // The '\r' we read() didn't count.
    assertEquals("", r.readLine());
    assertEquals("2", r.readLine());
    assertNull(r.readLine());
}
Also used : BufferedReader(java.io.BufferedReader) Support_StringReader(tests.support.Support_StringReader) StringReader(java.io.StringReader)

Example 72 with StringReader

use of java.io.StringReader in project j2objc by google.

the class OldLineNumberReaderTest method test_reset.

public void test_reset() throws IOException {
    lnr = new LineNumberReader(new StringReader(text));
    assertEquals("Test 1: Returned incorrect line number;", 0, lnr.getLineNumber());
    String line = null;
    lnr.mark(100);
    lnr.readLine();
    lnr.reset();
    line = lnr.readLine();
    assertEquals("Test 2: Failed to reset reader", "0", line);
    lnr.mark(100);
    lnr.close();
    try {
        lnr.reset();
        fail("Test 3: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
}
Also used : StringReader(java.io.StringReader) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Example 73 with StringReader

use of java.io.StringReader in project j2objc by google.

the class OldLineNumberReaderTest method test_markI.

public void test_markI() throws IOException {
    lnr = new LineNumberReader(new StringReader(text));
    String line;
    lnr.skip(80);
    lnr.mark(100);
    line = lnr.readLine();
    lnr.reset();
    assertTrue("Test 1: Failed to return to marked position.", line.equals(lnr.readLine()));
    lnr.close();
    try {
        lnr.mark(42);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
// The spec does not say the mark has to be invalidated
}
Also used : StringReader(java.io.StringReader) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Example 74 with StringReader

use of java.io.StringReader in project j2objc by google.

the class OldBufferedReaderTest method testSourceThrowsWithMark.

public void testSourceThrowsWithMark() throws IOException {
    br = new BufferedReader(new ThrowingReader(new StringReader("ABCDEFGHI"), 4));
    br.read();
    br.read();
    br.mark(10);
    br.read();
    br.read();
    try {
        br.read();
        fail();
    } catch (IOException fromThrowingReader) {
    }
    assertEquals('E', br.read());
    assertEquals('F', br.read());
}
Also used : ThrowingReader(tests.support.ThrowingReader) BufferedReader(java.io.BufferedReader) Support_StringReader(tests.support.Support_StringReader) StringReader(java.io.StringReader) IOException(java.io.IOException)

Example 75 with StringReader

use of java.io.StringReader in project j2objc by google.

the class OldBufferedReaderTest method test_readLine_interaction_with_array_read_1.

public void test_readLine_interaction_with_array_read_1() throws Exception {
    BufferedReader r = new BufferedReader(new StringReader("1\r\n2"));
    assertEquals(2, r.read(new char[2], 0, 2));
    // The '\r' we read() didn't count.
    assertEquals("", r.readLine());
    assertEquals("2", r.readLine());
    assertNull(r.readLine());
}
Also used : BufferedReader(java.io.BufferedReader) Support_StringReader(tests.support.Support_StringReader) StringReader(java.io.StringReader)

Aggregations

StringReader (java.io.StringReader)4150 Test (org.junit.Test)1003 IOException (java.io.IOException)589 Reader (java.io.Reader)445 InputSource (org.xml.sax.InputSource)408 BufferedReader (java.io.BufferedReader)342 TokenStream (org.apache.lucene.analysis.TokenStream)302 ArrayList (java.util.ArrayList)273 StringWriter (java.io.StringWriter)251 Tokenizer (org.apache.lucene.analysis.Tokenizer)241 Document (org.w3c.dom.Document)232 JSONReader (com.alibaba.fastjson.JSONReader)195 DocumentBuilder (javax.xml.parsers.DocumentBuilder)180 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)157 Map (java.util.Map)144 HashMap (java.util.HashMap)136 Element (org.w3c.dom.Element)134 StreamSource (javax.xml.transform.stream.StreamSource)132 ParserResult (org.jabref.logic.importer.ParserResult)130 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)120