Search in sources :

Example 1 with Publish

use of com.rabbitmq.client.impl.AMQImpl.Basic.Publish in project rabbitmq-java-client by rabbitmq.

the class BrokenFramesTest method methodThenBody.

@Test
public void methodThenBody() throws Exception {
    List<Frame> frames = new ArrayList<Frame>();
    byte[] contentBody = new byte[10];
    int channelNumber = 0;
    Publish method = new Publish(1, "test", "test", false, false);
    frames.add(method.toFrame(0));
    frames.add(Frame.fromBodyFragment(channelNumber, contentBody, 0, contentBody.length));
    myFrameHandler.setFrames(frames.iterator());
    try {
        new AMQConnection(factory.params(Executors.newFixedThreadPool(1)), myFrameHandler).start();
    } catch (IOException e) {
        UnexpectedFrameError unexpectedFrameError = findUnexpectedFrameError(e);
        assertNotNull(unexpectedFrameError);
        assertEquals(AMQP.FRAME_BODY, unexpectedFrameError.getReceivedFrame().type);
        assertEquals(AMQP.FRAME_HEADER, unexpectedFrameError.getExpectedFrameType());
        return;
    }
    fail("No UnexpectedFrameError thrown");
}
Also used : Frame(com.rabbitmq.client.impl.Frame) AMQConnection(com.rabbitmq.client.impl.AMQConnection) ArrayList(java.util.ArrayList) UnexpectedFrameError(com.rabbitmq.client.UnexpectedFrameError) IOException(java.io.IOException) Publish(com.rabbitmq.client.impl.AMQImpl.Basic.Publish) Test(org.junit.Test)

Aggregations

UnexpectedFrameError (com.rabbitmq.client.UnexpectedFrameError)1 AMQConnection (com.rabbitmq.client.impl.AMQConnection)1 Publish (com.rabbitmq.client.impl.AMQImpl.Basic.Publish)1 Frame (com.rabbitmq.client.impl.Frame)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1