+
+ in.close();
+ }
+ });
+
+ addTest(new TestCase("Starts With strings + steps") {
+ @Override
+ public void test() throws Exception {
+ String data = "{\nREF: fanfan\n}";
+ NextableInputStream in = new NextableInputStream(
+ data.getBytes("UTF-8"), new NextableInputStreamStep(
+ '\n'));
+ in.next();
+
+ assertEquals("STARTS_WITH OK", true, in.startsWith("{"));
+ in.skip(1);
+ assertEquals("STARTS_WITH WHEN SPENT", false,
+ in.startsWith("{"));
+
+ checkNext(this, "PARTIAL CONTENT", in,
+ "REF: fanfan".getBytes("UTF-8"));
+ }
+ });
+
+ addTest(new TestCase("InputStream is(String)") {
+ @Override
+ public void test() throws Exception {
+ String data = "{\nREF: fanfan\n}";
+ NextableInputStream in = new NextableInputStream(
+ new ByteArrayInputStream(data.getBytes("UTF-8")),
+ new NextableInputStreamStep('\n'));
+
+ in.next();
+ assertEquals("Item 1 OK", true, in.is("{"));
+ assertEquals("Item 1 KO_1", false, in.is("|"));
+ assertEquals("Item 1 KO_2", false, in.is("{}"));
+ in.skip(1);
+ in.next();
+ assertEquals("Item 2 OK", true, in.is("REF: fanfan"));
+ assertEquals("Item 2 KO", false, in.is("REF: fanfan."));
+ IOUtils.readSmallStream(in);
+ in.next();
+ assertEquals("Item 3 OK", true, in.is("}"));
+
+ in.close();