Search in sources :

Example 6 with AmqpFeedbackReceivedHandler

use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler in project azure-iot-sdk-java by Azure.

the class AmqpReceiveHandlerTest method onConnectionBound_call_flow_and_init_ok_amqp.

// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_009: [The event handler shall set the SASL PLAIN authentication on the Transport using the given user name and sas token]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_010: [The event handler shall set ANONYMUS_PEER authentication mode on the domain of the Transport]
// Tests_SRS_SERVICE_SDK_JAVA_AMQPFEEDBACKRECEIVEDHANDLER_12_017: [The event handler shall not initialize WebSocket if the protocol is AMQP]
@Test
public void onConnectionBound_call_flow_and_init_ok_amqp() {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    AmqpFeedbackReceivedHandler amqpReceiveHandler = new AmqpFeedbackReceivedHandler(hostName, userName, sasToken, iotHubServiceClientProtocol, null);
    // Assert
    new Expectations() {

        {
            connection = event.getConnection();
            transport = connection.getTransport();
            sasl.plain(anyString, anyString);
            sslDomain = Proton.sslDomain();
            sslDomain.init(SslDomain.Mode.CLIENT);
            sslDomain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
            transport.ssl(sslDomain);
        }
    };
    // Act
    amqpReceiveHandler.onConnectionBound(event);
}
Also used : Expectations(mockit.Expectations) AmqpFeedbackReceivedHandler(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Aggregations

IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)6 AmqpFeedbackReceivedHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedHandler)6 Expectations (mockit.Expectations)6 Test (org.junit.Test)6 WebSocketImpl (com.microsoft.azure.sdk.iot.deps.ws.impl.WebSocketImpl)1 AmqpFeedbackReceivedEvent (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFeedbackReceivedEvent)1 Symbol (org.apache.qpid.proton.amqp.Symbol)1 Source (org.apache.qpid.proton.amqp.messaging.Source)1 Target (org.apache.qpid.proton.amqp.messaging.Target)1