MqttPropertiesTest.java — netty Source File
Architecture documentation for MqttPropertiesTest.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2020 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 org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static io.netty.handler.codec.mqtt.MqttProperties.CONTENT_TYPE;
import static io.netty.handler.codec.mqtt.MqttProperties.PAYLOAD_FORMAT_INDICATOR;
import static io.netty.handler.codec.mqtt.MqttProperties.SUBSCRIPTION_IDENTIFIER;
import static io.netty.handler.codec.mqtt.MqttProperties.USER_PROPERTY;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MqttPropertiesTest {
private MqttProperties createSampleProperties() {
MqttProperties props = new MqttProperties();
props.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 10));
props.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 20));
props.add(new MqttProperties.IntegerProperty(PAYLOAD_FORMAT_INDICATOR, 6));
props.add(new MqttProperties.StringProperty(CONTENT_TYPE, "text/plain"));
props.add(new MqttProperties.UserProperty("isSecret", "true"));
props.add(new MqttProperties.UserProperty("tag", "firstTag"));
props.add(new MqttProperties.UserProperty("tag", "secondTag"));
return props;
}
@Test
public void testGetProperty() {
MqttProperties props = createSampleProperties();
assertEquals(
"text/plain",
((MqttProperties.StringProperty) props.getProperty(CONTENT_TYPE)).value);
assertEquals(
10,
((MqttProperties.IntegerProperty) props.getProperty(SUBSCRIPTION_IDENTIFIER)).value.intValue());
List<MqttProperties.StringPair> expectedUserProps = new ArrayList<MqttProperties.StringPair>();
expectedUserProps.add(new MqttProperties.StringPair("isSecret", "true"));
expectedUserProps.add(new MqttProperties.StringPair("tag", "firstTag"));
expectedUserProps.add(new MqttProperties.StringPair("tag", "secondTag"));
List<MqttProperties.StringPair> actualUserProps =
((MqttProperties.UserProperties) props.getProperty(USER_PROPERTY)).value;
assertEquals(expectedUserProps, actualUserProps);
}
@Test
public void testGetProperties() {
MqttProperties props = createSampleProperties();
assertEquals(
Collections.singletonList(new MqttProperties.StringProperty(CONTENT_TYPE, "text/plain")),
props.getProperties(CONTENT_TYPE));
List<MqttProperties.IntegerProperty> expectedSubscriptionIds = new ArrayList<>();
expectedSubscriptionIds.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 10));
expectedSubscriptionIds.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 20));
assertEquals(
expectedSubscriptionIds,
props.getProperties(SUBSCRIPTION_IDENTIFIER));
List<MqttProperties.UserProperty> expectedUserProps = new ArrayList<>();
expectedUserProps.add(new MqttProperties.UserProperty("isSecret", "true"));
expectedUserProps.add(new MqttProperties.UserProperty("tag", "firstTag"));
expectedUserProps.add(new MqttProperties.UserProperty("tag", "secondTag"));
List<MqttProperties.UserProperty> actualUserProps =
(List<MqttProperties.UserProperty>) props.getProperties(USER_PROPERTY);
assertEquals(expectedUserProps, actualUserProps);
}
@Test
public void testListAll() {
MqttProperties props = createSampleProperties();
List<MqttProperties.MqttProperty> expectedProperties = new ArrayList<>();
expectedProperties.add(new MqttProperties.IntegerProperty(PAYLOAD_FORMAT_INDICATOR, 6));
expectedProperties.add(new MqttProperties.StringProperty(CONTENT_TYPE, "text/plain"));
expectedProperties.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 10));
expectedProperties.add(new MqttProperties.IntegerProperty(SUBSCRIPTION_IDENTIFIER, 20));
MqttProperties.UserProperties expectedUserProperties = new MqttProperties.UserProperties();
expectedUserProperties.add(new MqttProperties.StringPair("isSecret", "true"));
expectedUserProperties.add(new MqttProperties.StringPair("tag", "firstTag"));
expectedUserProperties.add(new MqttProperties.StringPair("tag", "secondTag"));
expectedProperties.add(expectedUserProperties);
assertEquals(expectedProperties, props.listAll());
}
}
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does MqttPropertiesTest.java do?
MqttPropertiesTest.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is MqttPropertiesTest.java in the architecture?
MqttPropertiesTest.java is located at codec-mqtt/src/test/java/io/netty/handler/codec/mqtt/MqttPropertiesTest.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