Search in sources :

Example 96 with Expectations

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());
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) Expectations(mockit.Expectations) ByteBuffer(java.nio.ByteBuffer) Test(org.testng.annotations.Test)

Example 97 with Expectations

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());
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) Expectations(mockit.Expectations) ByteBuffer(java.nio.ByteBuffer) Test(org.testng.annotations.Test)

Example 98 with Expectations

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());
}
Also used : Expectations(mockit.Expectations) ByteBuffer(java.nio.ByteBuffer) Test(org.testng.annotations.Test)

Example 99 with Expectations

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());
}
Also used : Expectations(mockit.Expectations) ByteBuffer(java.nio.ByteBuffer) Test(org.testng.annotations.Test)

Example 100 with Expectations

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);
}
Also used : Expectations(mockit.Expectations) InvocationException(io.servicecomb.core.exception.InvocationException) ArrayList(java.util.ArrayList) RestParam(io.servicecomb.common.rest.definition.RestParam) Test(org.junit.Test)

Aggregations

Expectations (mockit.Expectations)113 Test (org.junit.Test)98 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)60 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)19 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)19 Test (org.testng.annotations.Test)14 AmqpSendHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler)12 ByteBuffer (java.nio.ByteBuffer)12 ServiceClient (com.microsoft.azure.sdk.iot.service.ServiceClient)10 AmqpFeedbackReceivedHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler)6 AmqpReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpReceive)5 URIEndpointObject (io.servicecomb.foundation.common.net.URIEndpointObject)5 FeedbackBatch (com.microsoft.azure.sdk.iot.service.FeedbackBatch)4 Message (com.microsoft.azure.sdk.iot.service.Message)4 AmqpSend (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSend)4 HeartbeatResponse (io.servicecomb.serviceregistry.api.response.HeartbeatResponse)4 WebSocketImpl (com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl)3 Tools (com.microsoft.azure.sdk.iot.service.Tools)3 AmqpFileUploadNotificationReceive (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive)3 Endpoint (io.servicecomb.core.Endpoint)3