Java Code Examples for org.apache.flume.serialization.EventDeserializer#readEvents()
The following examples show how to use
org.apache.flume.serialization.EventDeserializer#readEvents() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlXpathDeserializerTest.java From ingestion with Apache License 2.0 | 6 votes |
private void validateReadAndMark(EventDeserializer des) throws IOException { Event evt; evt = des.readEvent(); assertTrue(new String(evt.getBody()).contains("Giada De Laurentiis")); des.mark(); evt = des.readEvent(); assertTrue(new String(evt.getBody()).contains("J K. Rowling")); des.mark(); // reset! List<Event> readEvents = des.readEvents(2); assertEquals(2, readEvents.size()); evt = des.readEvent(); assertNull("Event should be null because there are no more books " + "left to read", evt); des.mark(); des.mark(); des.close(); }
Example 2
Source File: XmlXpathDeserializerTest.java From ingestion with Apache License 2.0 | 6 votes |
private void validateReadAndMarkWithHeader(EventDeserializer des) throws IOException { Event evt; evt = des.readEvent(); System.out.println(evt.getHeaders().get("myHeader")); assertTrue(evt.getHeaders().get("myHeader").contains("Giada De Laurentiis")); des.mark(); evt = des.readEvent(); assertTrue(evt.getHeaders().get("myHeader").contains("J K. Rowling")); des.mark(); // reset! List<Event> readEvents = des.readEvents(2); assertEquals(2, readEvents.size()); evt = des.readEvent(); assertNull("Event should be null because there are no more books " + "left to read", evt); des.mark(); des.mark(); des.close(); }
Example 3
Source File: XmlXpathDeserializerTest.java From ingestion with Apache License 2.0 | 6 votes |
private void validateReset(EventDeserializer des) throws IOException { Event evt = des.readEvent(); assertEquals("Everyday Italian", new String(evt.getBody())); des.mark(); List<Event> events = des.readEvents(3); assertEquals(3, events.size()); assertEquals("Harry Potter", new String(events.get(0).getBody())); assertEquals("XQuery Kick Start", new String(events.get(1).getBody())); assertEquals("Learning XML", new String(events.get(2).getBody())); des.reset(); // reset! events = des.readEvents(3); assertEquals(3, events.size()); assertEquals("Harry Potter", new String(events.get(0).getBody())); assertEquals("XQuery Kick Start", new String(events.get(1).getBody())); assertEquals("Learning XML", new String(events.get(2).getBody())); evt = des.readEvent(); Assert.assertNull("Event should be null because there are no more books " + "left to read", evt); }
Example 4
Source File: TestBlobDeserializer.java From mt-flume with Apache License 2.0 | 5 votes |
@Test public void testBatch() throws IOException { ResettableInputStream in = new ResettableTestStringInputStream(mini); EventDeserializer des = new BlobDeserializer(new Context(), in); List<Event> events; events = des.readEvents(10); // try to read more than we should have assertEquals(1, events.size()); assertEventBodyEquals(mini, events.get(0)); des.mark(); des.close(); }
Example 5
Source File: XmlXpathDeserializerTest.java From ingestion with Apache License 2.0 | 5 votes |
@Test() public void testXPathWithNS() throws IOException { Context context = new Context(); context.put("expression", "/bookstore/book"); EventDeserializer des = new XmlXpathDeserializer.Builder().build(context, getTestInputStream("ns.xml")); List<Event> events = des.readEvents(4); assertEquals(4, events.size()); for (final Event event : events) { assertNotNull(event); } }
Example 6
Source File: XmlXpathDeserializerTest.java From ingestion with Apache License 2.0 | 5 votes |
private void validateHeaders(EventDeserializer des) throws IOException { List<Event> events = des.readEvents(4); Assert.assertTrue(events.size() == 4); for (Event evt : events) { Assert.assertEquals(evt.getHeaders().get("author"), "J K. Rowling"); } }