// Path: summer-mqtt-core/src/main/java/com/github/christophersmith/summer/mqtt/core/MqttClientConnectionType.java
// public enum MqttClientConnectionType
// {
//         /**
//          * Represents a connection type that can only publish messages.
//          */
//         PUBLISHER,
//         /**
//          * Represents a connection type that can both publish and receive messages.
//          */
//         PUBSUB,
//         /**
//          * Represents a connection type can only receive messages.
//          */
//         SUBSCRIBER;
// }
// 
// Path: summer-mqtt-core/src/main/java/com/github/christophersmith/summer/mqtt/core/MqttQualityOfService.java
// public enum MqttQualityOfService
// {
//         /**
//          * Represents a Quality of Service (Qos) of 0, for At Most Once.
//          */
//         QOS_0(0),
//         /**
//          * Represents a Quality of Service (Qos) of 1, for At Least Once.
//          */
//         QOS_1(1),
//         /**
//          * Represents a Quality of Service (Qos) of 2, for Exactly Once.
//          */
//         QOS_2(2);
// 
//     private transient final int levelIdentifier;
// 
//     MqttQualityOfService(final int levelIdentifier)
//     {
//         this.levelIdentifier = levelIdentifier;
//     }
// 
//     /**
//      * Returns an {@code int} value representation of the Quality of Service Level for this
//      * instance.
//      * 
//      * @return the Level Identifier
//      */
//     public int getLevelIdentifier()
//     {
//         return levelIdentifier;
//     }
// 
//     /**
//      * Finds the {@link MqttQualityOfService} instance that matches the {@code levelIdentifier}
//      * value.
//      * <p>
//      * If the {@code levelIdentifier} does not match a {@code MqttQualityOfService} instance, a
//      * default value of {@link MqttQualityOfService#QOS_0} will be returned.
//      * 
//      * @param levelIdentifier the Level Identifier to search by
//      * @return a {@code MqttQualityOfService} value
//      */
//     public static final MqttQualityOfService findByLevelIdentifier(final int levelIdentifier)
//     {
//         MqttQualityOfService record = QOS_0;
//         for (MqttQualityOfService value : values())
//         {
//             if (value.getLevelIdentifier() == levelIdentifier)
//             {
//                 record = value;
//                 break;
//             }
//         }
//         return record;
//     }
// }
// 
// Path: summer-mqtt-paho/src/test/java/com/github/christophersmith/summer/mqtt/paho/service/util/BrokerHelper.java
// public class BrokerHelper
// {
//     private static final String CLIENT_ID         = MqttAsyncClient.generateClientId();
//     private static final String BROKER_URI_FORMAT = "tcp://%s:%s";
//     private static final String BROKER_HOST_NAME = "mqtt.eclipse.org";
//     private static final int    BROKER_PORT       = 1883;
//     private static final String PROXY_HOST_NAME   = "localhost";
//     private static final int    PROXY_PORT        = 10080;
// 
//     public static String getClientId()
//     {
//         return CLIENT_ID;
//     }
// 
//     public static String getBrokerHostName()
//     {
//         return BROKER_HOST_NAME;
//     }
// 
//     public static int getBrokerPort()
//     {
//         return BROKER_PORT;
//     }
// 
//     public static String getBrokerUri()
//     {
//         return String.format(BROKER_URI_FORMAT, BROKER_HOST_NAME, String.valueOf(BROKER_PORT));
//     }
// 
//     public static String getProxyHostName()
//     {
//         return PROXY_HOST_NAME;
//     }
// 
//     public static int getProxyPort()
//     {
//         return PROXY_PORT;
//     }
// 
//     public static String getProxyUri()
//     {
//         return String.format(BROKER_URI_FORMAT, PROXY_HOST_NAME, String.valueOf(PROXY_PORT));
//     }
// }


import java.io.IOException;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.netcrusher.core.reactor.NioReactor;
import org.netcrusher.tcp.TcpCrusher;
import org.netcrusher.tcp.TcpCrusherBuilder;
import com.github.christophersmith.summer.mqtt.core.MqttClientConnectionType;
import com.github.christophersmith.summer.mqtt.core.MqttQualityOfService;
import com.github.christophersmith.summer.mqtt.paho.service.util.BrokerHelper;
/*******************************************************************************
 * Copyright (c) 2019 Christopher Smith - https://github.com/christophersmith
 * 
 * Licensed 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
 * 
 * http://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 com.github.christophersmith.summer.mqtt.paho.service;




public class SubscribeUnsubscribeTest
{
    private static final String EXCEPTION_MESSAGE_CANNOT_SUBSCRIBE_FORMAT = "Client ID %s is a %s and cannot subscribe or unsubscribe from Topic Filters.";
    @Rule
    public ExpectedException    thrown                                    = ExpectedException
        .none();

    @Test
    public void testSubscribeBeforeStartClientSubscriber() throws MqttException
    {
        PahoAsyncMqttClientService service = new PahoAsyncMqttClientService(
// Path: summer-mqtt-core/src/main/java/com/github/christophersmith/summer/mqtt/core/MqttClientConnectionType.java
// public enum MqttClientConnectionType
// {
//         /**
//          * Represents a connection type that can only publish messages.
//          */
//         PUBLISHER,
//         /**
//          * Represents a connection type that can both publish and receive messages.
//          */
//         PUBSUB,
//         /**
//          * Represents a connection type can only receive messages.
//          */
//         SUBSCRIBER;
// }
// 
// Path: summer-mqtt-core/src/main/java/com/github/christophersmith/summer/mqtt/core/MqttQualityOfService.java
// public enum MqttQualityOfService
// {
//         /**
//          * Represents a Quality of Service (Qos) of 0, for At Most Once.
//          */
//         QOS_0(0),
//         /**
//          * Represents a Quality of Service (Qos) of 1, for At Least Once.
//          */
//         QOS_1(1),
//         /**
//          * Represents a Quality of Service (Qos) of 2, for Exactly Once.
//          */
//         QOS_2(2);
// 
//     private transient final int levelIdentifier;
// 
//     MqttQualityOfService(final int levelIdentifier)
//     {
//         this.levelIdentifier = levelIdentifier;
//     }
// 
//     /**
//      * Returns an {@code int} value representation of the Quality of Service Level for this
//      * instance.
//      * 
//      * @return the Level Identifier
//      */
//     public int getLevelIdentifier()
//     {
//         return levelIdentifier;
//     }
// 
//     /**
//      * Finds the {@link MqttQualityOfService} instance that matches the {@code levelIdentifier}
//      * value.
//      * <p>
//      * If the {@code levelIdentifier} does not match a {@code MqttQualityOfService} instance, a
//      * default value of {@link MqttQualityOfService#QOS_0} will be returned.
//      * 
//      * @param levelIdentifier the Level Identifier to search by
//      * @return a {@code MqttQualityOfService} value
//      */
//     public static final MqttQualityOfService findByLevelIdentifier(final int levelIdentifier)
//     {
//         MqttQualityOfService record = QOS_0;
//         for (MqttQualityOfService value : values())
//         {
//             if (value.getLevelIdentifier() == levelIdentifier)
//             {
//                 record = value;
//                 break;
//             }
//         }
//         return record;
//     }
// }
// 
// Path: summer-mqtt-paho/src/test/java/com/github/christophersmith/summer/mqtt/paho/service/util/BrokerHelper.java
// public class BrokerHelper
// {
//     private static final String CLIENT_ID         = MqttAsyncClient.generateClientId();
//     private static final String BROKER_URI_FORMAT = "tcp://%s:%s";
//     private static final String BROKER_HOST_NAME = "mqtt.eclipse.org";
//     private static final int    BROKER_PORT       = 1883;
//     private static final String PROXY_HOST_NAME   = "localhost";
//     private static final int    PROXY_PORT        = 10080;
// 
//     public static String getClientId()
//     {
//         return CLIENT_ID;
//     }
// 
//     public static String getBrokerHostName()
//     {
//         return BROKER_HOST_NAME;
//     }
// 
//     public static int getBrokerPort()
//     {
//         return BROKER_PORT;
//     }
// 
//     public static String getBrokerUri()
//     {
//         return String.format(BROKER_URI_FORMAT, BROKER_HOST_NAME, String.valueOf(BROKER_PORT));
//     }
// 
//     public static String getProxyHostName()
//     {
//         return PROXY_HOST_NAME;
//     }
// 
//     public static int getProxyPort()
//     {
//         return PROXY_PORT;
//     }
// 
//     public static String getProxyUri()
//     {
//         return String.format(BROKER_URI_FORMAT, PROXY_HOST_NAME, String.valueOf(PROXY_PORT));
//     }
// }


// Path: summer-mqtt-paho/src/test/java/com/github/christophersmith/summer/mqtt/paho/service/SubscribeUnsubscribeTest.java
import java.io.IOException;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.netcrusher.core.reactor.NioReactor;
import org.netcrusher.tcp.TcpCrusher;
import org.netcrusher.tcp.TcpCrusherBuilder;
import com.github.christophersmith.summer.mqtt.core.MqttClientConnectionType;
import com.github.christophersmith.summer.mqtt.core.MqttQualityOfService;
import com.github.christophersmith.summer.mqtt.paho.service.util.BrokerHelper;

/*******************************************************************************
 * Copyright (c) 2019 Christopher Smith - https://github.com/christophersmith
 * 
 * Licensed 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
 * 
 * http://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 com.github.christophersmith.summer.mqtt.paho.service;




public class SubscribeUnsubscribeTest
{
    private static final String EXCEPTION_MESSAGE_CANNOT_SUBSCRIBE_FORMAT = "Client ID %s is a %s and cannot subscribe or unsubscribe from Topic Filters.";
    @Rule
    public ExpectedException    thrown                                    = ExpectedException
        .none();

    @Test
    public void testSubscribeBeforeStartClientSubscriber() throws MqttException
    {
        PahoAsyncMqttClientService service = new PahoAsyncMqttClientService(
            BrokerHelper.getBrokerUri(), BrokerHelper.getClientId(),