def test_compile_MQTTSource(self):
     print ('\n---------'+str(self))
     name = 'test_MQTTSource'
     topo = Topology(name)
     streamsx.spl.toolkit.add_toolkit(topo, self.mqtt_toolkit_home)
     src = MQTTSource(server_uri='tcp://server:1833', topics=['topic1', 'topic2'], schema=MqttDataTuple)
     # simply add all parameters; let' see if it compiles
     src.qos = [1, 2]
     src.message_queue_size = 122
     src.client_id = "client-IDsrc"
     src.reconnection_bound = 25
     src.trusted_certs = [TRUSTED_CERT_PEM, CLIENT_CA_CERT_PEM]
     src.client_cert = CLIENT_CERT_PEM
     src.client_private_key = PRIVATE_KEY_PEM
     src.ssl_protocol = 'TLSv1.1'
     src.vm_arg = ["-Xmx13G"]
     src.ssl_debug = True
     src.app_config_name = "abbconf2"
     src.command_timeout_millis=30000
     src.keep_alive_seconds = 65
     src.password = "******"
     src.username = "******"
     src.app_config_name = "mqtt_app_cfg"
     
     source_stream = topo.source(src, name='MqttStream')
     source_stream.print()
     # build only
     self._build_only(name, topo)
    def test_device_app(self):
        print ('\n---------'+str(self))
        name = 'test_device_app'
        topo = Topology(name)
        streamsx.spl.toolkit.add_toolkit(topo, self.mqtt_toolkit_home)

        # generate IOT specific Topic for Application
        device_type = "Test"
        event_id = "data"
        device_id = "+"
        message_format = "json"
        # app subscribe topic "iot-2/type/device_type/id/device_id/evt/event_id/fmt/format_string"
        app_subscribe_topic = "iot-2/type/"+device_type+"/id/"+device_id+"/evt/"+event_id+"/fmt/"+message_format
        #mqtt config is dict as read by from JSON, JSON uses already correct parameter values
        app_config = self._get_app_config()
        mqtt_source = MQTTSource(server_uri=app_config['serverURI'], topics=app_subscribe_topic, schema=[MqttDataTuple], topic_attribute_name='topic_name')
        mqtt_source.username = app_config['userID']
        mqtt_source.password = app_config['password']
        mqtt_source.client_id = app_config['clientID']
        mqtt_source.vm_arg = "-Dcom.ibm.jsse2.overrideDefaultTLS=true"
        source_stream = topo.source(mqtt_source, name='MqttSubscribe')
        source_stream.print()

        test_stream = self._create_stream(topo)
        test_stream.print()
        # generate IOT specific Topic for device
        # event_id has to be same as for application 
        # message_format has to be same as for application 
        # device event publish topic = "iot-2/evt/event_id/fmt/format_string"
        device_topic = "iot-2/evt/"+event_id+"/fmt/" + message_format
        # device config is dict as read by from JSON, JSON uses already correct parameter values
        device_config = self._get_device_config()
        mqtt_sink = MQTTSink(server_uri=device_config['serverURI'], topic=device_topic, data_attribute_name='data')
        mqtt_sink.client_id = device_config['clientID']
        mqtt_sink.username = device_config['userID']
        mqtt_sink.password = device_config['password']
        mqtt_sink.vm_arg = "-Dcom.ibm.jsse2.overrideDefaultTLS=true"

        test_stream.for_each(mqtt_sink, name='MqttPublish')

        if (("TestDistributed" in str(self)) or ("TestStreamingAnalytics" in str(self))):
            self._launch(topo)
        else:
            # build only
            self._build_only(name, topo)
src.trusted_certs = [
    '/tmp/secrets/cluster_ca_cert.pem', '/tmp/secrets/cluster-ca.crt'
]
#src.truststore = "/tmp/truststore-4657686007309004.jks"
src.truststore_password = '******'
src.client_cert = '/home/rolef/infosphereStreams/development/tk/ws_el7_43/kafkaTransactionSupport/etc/amqstreams/rolef.crt'
src.client_private_key = '/home/rolef/infosphereStreams/development/tk/ws_el7_43/kafkaTransactionSupport/etc/amqstreams/rolef.key'
#src.keystore = "/tmp/keystore-8728817490056367.jks"
src.keystore_password = '******'
src.ssl_protocol = 'TLSv1.1'
src.vm_arg = ["-Xmx13G"]
src.ssl_debug = True
src.app_config_name = "abbconf2"
src.command_timeout_millis = 247
src.keep_alive_seconds = 23
src.password = "******"
src.username = "******"

topo = Topology()
#data = topo.source(["A","B","C","D","E","F","G","H","I","J"]).as_string()

data = topo.source(src, "MQTTsubscribe")
data.for_each(sk, name="MQTTpublish")

#submission = context.submit(context.ContextTypes.TOOLKIT, topo)
submission = context.submit(context.ContextTypes.BUNDLE, topo)
#c._check_types()
#c._check_adjust()
#print(sk.__dict__)
#print(sk._config.__dict__)
print(submission)