Request requestMock = EasyMock.createNiceMock(Request.class);
ResponseImpl responseImpl = new ResponseImpl();
String stringMessage = "Hello";
expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
expect(requestURI.getPath()).andReturn("/").anyTimes();
expect(requestURI.getQuery()).andReturn("value=" + stringMessage)
.anyTimes();
expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
replay(requestMock);
replay(requestURI);
handler.handle(requestMock, responseImpl);
responseImpl.consumeBody();
Assert.assertArrayEquals(stringMessage.getBytes(), responseImpl.getBodyBytes());
reset(requestURI);
responseImpl = new ResponseImpl();
// now do the same with a decimal value
String decimalString = "446544";
expect(requestURI.getPath()).andReturn("/").anyTimes();
expect(requestURI.getQuery()).andReturn("value=" + decimalString)
.anyTimes();
replay(requestURI);
handler.handle(requestMock, responseImpl);
responseImpl.consumeBody();
Assert.assertArrayEquals(("int:" + decimalString).getBytes(), responseImpl.getBodyBytes());