Search in sources :

Example 1 with ServerTestDriver

use of com.yahoo.messagebus.jdisc.test.ServerTestDriver in project vespa by vespa-engine.

the class MbusServerTestCase method requireThatNonMbusResponseCausesEmptyReply.

@Test
public void requireThatNonMbusResponseCausesEmptyReply() {
    MyRequestHandler requestHandler = MyRequestHandler.newInstance();
    ServerTestDriver driver = ServerTestDriver.newInstance(requestHandler);
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(requestHandler.awaitRequest());
    assertTrue(requestHandler.sendResponse(new Response(Response.Status.OK)));
    assertNotNull(driver.awaitSuccess());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 2 with ServerTestDriver

use of com.yahoo.messagebus.jdisc.test.ServerTestDriver in project vespa by vespa-engine.

the class MbusServerTestCase method requireThatRequestDeniedExceptionIsCaught.

@Test
public void requireThatRequestDeniedExceptionIsCaught() {
    ServerTestDriver driver = ServerTestDriver.newInstance(MyRequestHandler.newRequestDenied());
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(driver.awaitErrors(ErrorCode.APP_FATAL_ERROR));
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 3 with ServerTestDriver

use of com.yahoo.messagebus.jdisc.test.ServerTestDriver in project vespa by vespa-engine.

the class MbusServerTestCase method requireThatBindingNotFoundExceptionIsCaught.

@Test
public void requireThatBindingNotFoundExceptionIsCaught() {
    ServerTestDriver driver = ServerTestDriver.newUnboundInstance();
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(driver.awaitErrors(ErrorCode.APP_FATAL_ERROR));
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 4 with ServerTestDriver

use of com.yahoo.messagebus.jdisc.test.ServerTestDriver in project vespa by vespa-engine.

the class MbusServerTestCase method requireThatMbusRequestContentCallsCompletion.

@Test
public void requireThatMbusRequestContentCallsCompletion() throws InterruptedException {
    MyRequestHandler requestHandler = MyRequestHandler.newInstance();
    ServerTestDriver driver = ServerTestDriver.newInstance(requestHandler);
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(requestHandler.awaitRequest());
    ContentChannel content = requestHandler.responseHandler.handleResponse(new Response(Response.Status.OK));
    assertNotNull(content);
    MyCompletion completion = new MyCompletion();
    content.close(completion);
    assertTrue(completion.completedLatch.await(60, TimeUnit.SECONDS));
    assertNotNull(driver.awaitSuccess());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 5 with ServerTestDriver

use of com.yahoo.messagebus.jdisc.test.ServerTestDriver in project vespa by vespa-engine.

the class MbusServerTestCase method requireThatRequestIsMbus.

@Test
public void requireThatRequestIsMbus() {
    MyRequestHandler requestHandler = MyRequestHandler.newInstance();
    ServerTestDriver driver = ServerTestDriver.newInstance(requestHandler);
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    Request request = requestHandler.awaitRequest();
    assertTrue(request instanceof MbusRequest);
    Message msg = ((MbusRequest) request).getMessage();
    assertTrue(msg instanceof SimpleMessage);
    assertEquals("foo", ((SimpleMessage) msg).getValue());
    assertTrue(requestHandler.sendResponse(new Response(Response.Status.OK)));
    assertNotNull(driver.awaitSuccess());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Request(com.yahoo.jdisc.Request) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Aggregations

ServerTestDriver (com.yahoo.messagebus.jdisc.test.ServerTestDriver)12 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)12 Test (org.junit.Test)11 Response (com.yahoo.jdisc.Response)5 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 Request (com.yahoo.jdisc.Request)1 Error (com.yahoo.messagebus.Error)1 LinkedList (java.util.LinkedList)1