Search in sources :

Example 1 with MessageHandler

use of com.yahoo.messagebus.MessageHandler in project vespa by vespa-engine.

the class SimpleFeederTest method requireThatAsyncFailuresThrowInMainThread.

@Test
public void requireThatAsyncFailuresThrowInMainThread() throws Throwable {
    TestDriver driver = new TestDriver(new FeederParams(), "<vespafeed><document documenttype='simple' documentid='doc:scheme:0'/></vespafeed>", new MessageHandler() {

        @Override
        public void handleMessage(Message msg) {
            Reply reply = new EmptyReply();
            reply.swapState(msg);
            reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 6, "foo"));
            reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 9, "bar"));
            reply.popHandler().handleReply(reply);
        }
    });
    try {
        driver.run();
        fail();
    } catch (IOException e) {
        assertMatches("com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage@.+\n" + "\\[UNKNOWN\\(250006\\) @ .+\\]: foo\n" + "\\[UNKNOWN\\(250009\\) @ .+\\]: bar\n", e.getMessage());
    }
    assertTrue(driver.close());
}
Also used : MessageHandler(com.yahoo.messagebus.MessageHandler) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) Error(com.yahoo.messagebus.Error) IOException(java.io.IOException) EmptyReply(com.yahoo.messagebus.EmptyReply) Test(org.junit.Test)

Aggregations

DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 EmptyReply (com.yahoo.messagebus.EmptyReply)1 Error (com.yahoo.messagebus.Error)1 Message (com.yahoo.messagebus.Message)1 MessageHandler (com.yahoo.messagebus.MessageHandler)1 Reply (com.yahoo.messagebus.Reply)1 IOException (java.io.IOException)1 Test (org.junit.Test)1