use of mockit.Expectations in project pulsar by yahoo.
the class AbstractStatefulHashTest method testUpdateByteBuffer.
@Test
public void testUpdateByteBuffer() {
final ByteBuffer input = ByteBuffer.allocate(20);
input.position(5);
input.limit(15);
new Expectations(hash) {
{
hash.updateUnchecked(input.array(), input.arrayOffset() + 5, 10);
}
};
hash.update(input);
assertEquals(input.limit(), input.position());
}
use of mockit.Expectations in project pulsar by yahoo.
the class AbstractStatefulHashTest method testUpdateReadOnlyByteBuffer.
@Test
public void testUpdateReadOnlyByteBuffer() {
final ByteBuffer input = ByteBuffer.allocate(20).asReadOnlyBuffer();
input.position(5);
input.limit(15);
new Expectations(hash) {
{
hash.updateUnchecked(withInstanceOf(byte[].class), 0, 10);
}
};
hash.update(input);
assertEquals(input.limit(), input.position());
}
use of mockit.Expectations in project pulsar by yahoo.
the class AbstractStatelessIntHashTest method testCalculateReadOnlyByteBuffer.
@Test
public void testCalculateReadOnlyByteBuffer() {
final ByteBuffer input = ByteBuffer.allocate(20).asReadOnlyBuffer();
input.position(5);
input.limit(15);
new Expectations(hash) {
{
hash.calculateUnchecked(withInstanceOf(byte[].class), 0, 10);
}
};
hash.calculate(input);
assertEquals(input.limit(), input.position());
}
use of mockit.Expectations in project pulsar by yahoo.
the class AbstractStatelessIntHashTest method testCalculateByteBuffer.
@Test
public void testCalculateByteBuffer() {
final ByteBuffer input = ByteBuffer.allocate(20);
input.position(5);
input.limit(15);
new Expectations(hash) {
{
hash.calculateUnchecked(input.array(), input.arrayOffset() + 5, 10);
}
};
hash.calculate(input);
assertEquals(input.limit(), input.position());
}
use of mockit.Expectations in project java-chassis by ServiceComb.
the class TestRestCodec method testRestToArgsInstanceExcetpion.
@Test
public void testRestToArgsInstanceExcetpion(@Mocked RestServerRequest request, @Mocked RestOperationMeta restOperation, @Mocked RestParam restParam, @Mocked ParamValueProcessor processer) throws Exception {
List<RestParam> params = new ArrayList<>();
params.add(restParam);
InvocationException exception = new InvocationException(Status.BAD_REQUEST, "Parameter is not valid.");
new Expectations() {
{
restOperation.getParamList();
result = params;
restParam.getParamProcessor();
result = processer;
processer.getValue(request);
result = exception;
}
};
boolean success = false;
try {
RestCodec.restToArgs(request, restOperation);
success = true;
} catch (InvocationException e) {
Assert.assertEquals(e.getStatusCode(), Status.BAD_REQUEST.getStatusCode());
}
Assert.assertEquals(success, false);
}
Aggregations