use of org.jboss.netty.channel.MessageEvent in project bagheera by mozilla-metrics.
the class AccessFilterTest method createMockEvent.
private MessageEvent createMockEvent(Channel channel, HttpVersion protocolVersion, HttpMethod method, String uri) {
MessageEvent event = createMock(UpstreamMessageEvent.class);
expect(event.getChannel()).andReturn(channel).anyTimes();
expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel, false)).anyTimes();
expect(event.getRemoteAddress()).andReturn(remoteAddr);
expect(event.getMessage()).andReturn(new BagheeraHttpRequest(protocolVersion, method, uri));
replay(channel, event);
return event;
}
use of org.jboss.netty.channel.MessageEvent in project bagheera by mozilla-metrics.
the class DummyProducer method testMessage.
// Ensure that one invocation of the message results in the specified number of deletes and creates
// and that two invocations results in double those numbers.
private void testMessage(String id, boolean doDelete, int expectedDeletes, int expectedCreates, String... deletes) throws Exception {
SubmissionHandler handler = new SubmissionHandler(validator, producer, channelGroup, manager);
ChannelHandlerContext context = Mockito.mock(ChannelHandlerContext.class);
MessageEvent messageEvent = Mockito.mock(MessageEvent.class);
Mockito.when(messageEvent.getChannel()).thenReturn(mockChannel);
BagheeraHttpRequest mockMessage = getMockMessage(HttpMethod.POST, id, doDelete, deletes);
Mockito.when(messageEvent.getMessage()).thenReturn(mockMessage);
testTwoInvocations(expectedDeletes, expectedCreates, handler, context, messageEvent);
producer.reset();
}
use of org.jboss.netty.channel.MessageEvent in project bagheera by mozilla-metrics.
the class DummyProducer method testDelete.
@Test
public void testDelete() throws Exception {
// Test an actual delete (as opposed to a POST message with an X-Obsolete-Doc header).
SubmissionHandler handler = new SubmissionHandler(validator, producer, channelGroup, manager);
ChannelHandlerContext context = Mockito.mock(ChannelHandlerContext.class);
MessageEvent messageEvent = Mockito.mock(MessageEvent.class);
Mockito.when(messageEvent.getChannel()).thenReturn(mockChannel);
BagheeraHttpRequest mockMessage = getMockMessage(HttpMethod.DELETE, "delete-id", false);
Mockito.when(messageEvent.getMessage()).thenReturn(mockMessage);
testTwoInvocations(1, 0, handler, context, messageEvent);
producer.reset();
}
use of org.jboss.netty.channel.MessageEvent in project bagheera by mozilla-metrics.
the class ContentLengthFilterTest method createMockEvent.
private MessageEvent createMockEvent(Channel channel, HttpVersion protocolVersion, HttpMethod method, String uri, byte[] contentBytes) {
MessageEvent event = createMock(UpstreamMessageEvent.class);
expect(event.getChannel()).andReturn(channel).anyTimes();
expect(event.getFuture()).andReturn(new DefaultChannelFuture(channel, false)).anyTimes();
expect(event.getRemoteAddress()).andReturn(remoteAddr);
HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
req.setChunked(false);
req.setContent(ChannelBuffers.copiedBuffer(contentBytes));
expect(event.getMessage()).andReturn(req);
replay(channel, event);
return event;
}
Aggregations