### Question:
MorphlineInterceptor implements Interceptor { @Override public List<Event> intercept(List<Event> events) { LocalMorphlineInterceptor interceptor = borrowFromPool(); List<Event> results = interceptor.intercept(events); returnToPool(interceptor); return results; } protected  MorphlineInterceptor(Context context); @Override void initialize(); @Override void close(); @Override List<Event> intercept(List<Event> events); @Override Event intercept(Event event);  }### Answer:
@Test public void testGrokIfNotMatchDropEventDrop() throws Exception { Context context = new Context(); context.put(MorphlineHandlerImpl.MORPHLINE_FILE_PARAM, RESOURCES_DIR + "/test-morphlines/grokIfNotMatchDropRecord.conf"); String msg = "<XXXXXXXXXXXXX164>Feb 4 10:46:14 syslog sshd[607]: Server listening on 0.0.0.0 port 22."; Event input = EventBuilder.withBody(null, ImmutableMap.of(Fields.MESSAGE, msg)); Event actual = build(context).intercept(input); assertNull(actual); }
@Test public void testIfDetectMimeTypeRouteToSouthPole() throws Exception { Context context = new Context(); context.put(MorphlineHandlerImpl.MORPHLINE_FILE_PARAM, RESOURCES_DIR + "/test-morphlines/ifDetectMimeType.conf"); context.put(MorphlineHandlerImpl.MORPHLINE_VARIABLE_PARAM + ".MY.MIME_TYPE", "avro/binary"); Event input = EventBuilder.withBody(Files.toByteArray(new File(RESOURCES_DIR + "/test-documents/sample-statuses-20120906-141433.avro"))); Event actual = build(context).intercept(input); Map<String, String> expected = new HashMap(); expected.put(Fields.ATTACHMENT_MIME_TYPE, "avro/binary"); expected.put("flume.selector.header", "goToSouthPole"); Event expectedEvent = EventBuilder.withBody(input.getBody(), expected); assertEqualsEvent(expectedEvent, actual); }
@Test public void testIfDetectMimeTypeRouteToNorthPole() throws Exception { Context context = new Context(); context.put(MorphlineHandlerImpl.MORPHLINE_FILE_PARAM, RESOURCES_DIR + "/test-morphlines/ifDetectMimeType.conf"); context.put(MorphlineHandlerImpl.MORPHLINE_VARIABLE_PARAM + ".MY.MIME_TYPE", "avro/binary"); Event input = EventBuilder.withBody(Files.toByteArray(new File(RESOURCES_DIR + "/test-documents/testPDF.pdf"))); Event actual = build(context).intercept(input); Map<String, String> expected = new HashMap(); expected.put(Fields.ATTACHMENT_MIME_TYPE, "application/pdf"); expected.put("flume.selector.header", "goToNorthPole"); Event expectedEvent = EventBuilder.withBody(input.getBody(), expected); assertEqualsEvent(expectedEvent, actual); }