Home / File/ MqttConnectPayloadTest.java — netty Source File

MqttConnectPayloadTest.java — netty Source File

Architecture documentation for MqttConnectPayloadTest.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2017 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.netty.handler.codec.mqtt;

import static org.junit.jupiter.api.Assertions.assertNull;

import io.netty.util.CharsetUtil;
import org.junit.jupiter.api.Test;

import java.util.Collections;

public class MqttConnectPayloadTest {

    @Test
    public void testNullWillMessage() throws Exception {
        String clientIdentifier = "clientIdentifier";
        String willTopic = "willTopic";
        byte[] willMessage = null;
        String userName = "userName";
        byte[] password = "password".getBytes(CharsetUtil.UTF_8);
        MqttConnectPayload mqttConnectPayload = new MqttConnectPayload(clientIdentifier,
                MqttProperties.NO_PROPERTIES,
                willTopic,
                willMessage,
                userName,
                password);

        assertNull(mqttConnectPayload.willMessageInBytes());
        assertNull(mqttConnectPayload.willMessage());
    }

    @Test
    public void testNullPassword() throws Exception {
        String clientIdentifier = "clientIdentifier";
        String willTopic = "willTopic";
        byte[] willMessage = "willMessage".getBytes(CharsetUtil.UTF_8);
        String userName = "userName";
        byte[] password = null;
        MqttConnectPayload mqttConnectPayload = new MqttConnectPayload(clientIdentifier,
                MqttProperties.NO_PROPERTIES,
                willTopic,
                willMessage,
                userName,
                password);

        assertNull(mqttConnectPayload.passwordInBytes());
        assertNull(mqttConnectPayload.password());
    }

    @Test
    public void testBuilderNullPassword() throws Exception {
        MqttMessageBuilders.ConnectBuilder builder = new MqttMessageBuilders.ConnectBuilder();
        builder.password((String) null);

        MqttConnectPayload mqttConnectPayload = builder.build().payload();

        assertNull(mqttConnectPayload.passwordInBytes());
        assertNull(mqttConnectPayload.password());

        builder = new MqttMessageBuilders.ConnectBuilder();
        builder.password((byte[]) null);

        mqttConnectPayload = builder.build().payload();

        assertNull(mqttConnectPayload.passwordInBytes());
        assertNull(mqttConnectPayload.password());
    }

    @Test
    public void testBuilderNullWillMessage() throws Exception {
        MqttMessageBuilders.ConnectBuilder builder = new MqttMessageBuilders.ConnectBuilder();
        builder.willMessage((String) null);

        MqttConnectPayload mqttConnectPayload = builder.build().payload();

        assertNull(mqttConnectPayload.willMessageInBytes());
        assertNull(mqttConnectPayload.willMessage());

        builder = new MqttMessageBuilders.ConnectBuilder();
        builder.willMessage((byte[]) null);

        mqttConnectPayload = builder.build().payload();

        assertNull(mqttConnectPayload.willMessageInBytes());
        assertNull(mqttConnectPayload.willMessage());
    }

    /* See https://github.com/netty/netty/pull/9202 */
    @Test
    public void testEmptyTopicsToString() {
        new MqttSubscribePayload(Collections.<MqttTopicSubscription>emptyList()).toString();
        new MqttUnsubscribePayload(Collections.<String>emptyList()).toString();
    }
}

Domain

Subdomains

Frequently Asked Questions

What does MqttConnectPayloadTest.java do?
MqttConnectPayloadTest.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is MqttConnectPayloadTest.java in the architecture?
MqttConnectPayloadTest.java is located at codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttConnectPayloadTest.java (domain: Buffer, subdomain: Allocators, directory: codec-mqtt/src/test/java/io/netty/handler/codec/mqtt).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free