use of org.apache.hadoop.hive.ql.udf.xml.UDFXPathUtil.ReusableStringReader in project hive by apache.
the class TestReusableStringReader method testSkip.
@Test
public void testSkip() throws IOException {
Reader reader = new ReusableStringReader();
((ReusableStringReader) reader).set(fox);
// skip entire the data:
long skipped = reader.skip(fox.length() + 1);
assertEquals(fox.length(), skipped);
assertEquals(-1, reader.read());
// reset the data
((ReusableStringReader) reader).set(fox);
char[] cc = new char[6];
int read;
read = reader.read(cc);
assertEquals(6, read);
assertEquals("Quick ", new String(cc));
// skip some piece of data:
skipped = reader.skip(30);
assertEquals(30, skipped);
read = reader.read(cc);
assertEquals(4, read);
assertEquals("dog.", new String(cc, 0, read));
// skip when already at EOF:
skipped = reader.skip(300);
assertEquals(0, skipped);
assertEquals(-1, reader.read());
reader.close();
}
use of org.apache.hadoop.hive.ql.udf.xml.UDFXPathUtil.ReusableStringReader in project hive by apache.
the class TestReusableStringReader method testEmpty.
/**
* Test empty {@link ReusableStringReader}
*/
@Test
public void testEmpty() throws IOException {
Reader reader = new ReusableStringReader();
try {
int ch = reader.read();
fail("IOException expected.");
} catch (IOException ioe) {
// expected
}
try {
boolean ready = reader.ready();
fail("IOException expected.");
} catch (IOException ioe) {
// expected
}
reader.close();
}
use of org.apache.hadoop.hive.ql.udf.xml.UDFXPathUtil.ReusableStringReader in project hive by apache.
the class TestReusableStringReader method testMarkReset.
@Test
public void testMarkReset() throws IOException {
Reader reader = new ReusableStringReader();
if (reader.markSupported()) {
((ReusableStringReader) reader).set(fox);
assertTrue(reader.ready());
char[] cc = new char[6];
int read;
read = reader.read(cc);
assertEquals(6, read);
assertEquals("Quick ", new String(cc));
reader.mark(100);
read = reader.read(cc);
assertEquals(6, read);
assertEquals("brown ", new String(cc));
reader.reset();
read = reader.read(cc);
assertEquals(6, read);
assertEquals("brown ", new String(cc));
}
reader.close();
}
Aggregations