@Test public void testSwiftService() throws Exception { SwiftScribe scribeService = new SwiftScribe(); NiftyProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), scribeService); List<LogEntry> messages = testProcessor(processor); assertEquals(scribeService.getMessages(), newArrayList(concat(toSwiftLogEntry(messages), toSwiftLogEntry(messages)))); }
try (Scribe scribe = scribeClient.open(localFramedConnector(server.getPort())).get()) { assertEquals(scribe.log(MESSAGES), ResultCode.OK); assertEquals(injector.getInstance(SwiftScribe.class).getMessages(), newArrayList(MESSAGES)); assertEquals(eventHandlerContexts.size(), 1); assertEquals(injector.getInstance(TestThriftEventHandler.class).count, 1);
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Multiple @ThriftMethod-annotated methods named.*") public void testConflictingServices() throws Exception { new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), new SwiftScribe(), new ConflictingLogService()); }
try (Scribe scribe = scribeClient.open(localFramedConnector(server.getPort())).get()) { assertEquals(scribe.log(MESSAGES), ResultCode.OK); assertEquals(injector.getInstance(Key.get(SwiftScribe.class, TestAnnotation.class)).getMessages(), newArrayList(MESSAGES));
@Test public void testSwiftService() throws Exception { SwiftScribe scribeService = new SwiftScribe(); NiftyProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), scribeService); testProcessor(processor); }
@Test public void testSwiftServicePlaintext() throws Exception { SwiftScribe scribeService = new SwiftScribe(); NiftyProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), scribeService); List<LogEntry> messages = testProcessor(processor, true); assertEquals(scribeService.getMessages(), newArrayList(concat(toSwiftLogEntry(messages), toSwiftLogEntry(messages)))); }
try (Scribe scribe = scribeClient.open(localFramedConnector(server.getPort())).get()) { assertEquals(scribe.log(MESSAGES), ResultCode.OK); assertEquals(injector.getInstance(Key.get(SwiftScribe.class, TestAnnotation.class)).getMessages(), newArrayList(MESSAGES));
@Test public void testSwiftService() throws Exception { SwiftScribe scribeService = new SwiftScribe(); NiftyProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), scribeService); List<LogEntry> messages = testProcessor(processor, false); assertEquals(scribeService.getMessages(), newArrayList(concat(toSwiftLogEntry(messages), toSwiftLogEntry(messages)))); }
public void swiftEventHandlerTester(boolean niftyProcessor) throws Exception { SwiftScribe scribeService = new SwiftScribe(); EventHandler eventHandler = new EventHandler(niftyProcessor); EventHandler secondHandler = new EventHandler(niftyProcessor); List<EventHandler> handlers = ImmutableList.of(eventHandler, secondHandler); final ThriftServiceProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), handlers, scribeService); List<LogEntry> messages = niftyProcessor ? testProcessor(processor) : testProcessor(NiftyProcessorAdapters.processorToTProcessor(processor)); assertEquals(scribeService.getMessages(), newArrayList(concat(toSwiftLogEntry(messages), toSwiftLogEntry(messages)))); assertTrue(eventHandler.validate(2)); assertTrue(secondHandler.validate(2)); }