use of org.eclipse.kapua.transport.TransportClientFactory in project kapua by eclipse.
the class MqttFacadeTest method testMqttClientSend.
/**
* Ignoring this test for a while. We should fix the build in the first place and then use embedded ActiveMQ
* broker for tests.
*/
@Ignore
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testMqttClientSend() throws Exception {
//
// Get facade
KapuaLocator locator = KapuaLocator.getInstance();
TransportClientFactory transportFacadeFactory = locator.getFactory(TransportClientFactory.class);
TransportFacade transportFacade = transportFacadeFactory.getFacade();
assertNotNull("client.clientId", transportFacade.getClientId());
//
// Send
String sendTopic = "$EDC/kapua-sys/" + transportFacade.getClientId() + "/" + MqttClientTest.class.getSimpleName() + "/testTransportFacadeSend";
MqttTopic mqttTopic = new MqttTopic(sendTopic);
MqttPayload mqttPayload = new MqttPayload("testTransportFacadeSendPayload".getBytes());
MqttMessage mqttMessage = new MqttMessage(mqttTopic, new Date(), mqttPayload);
TransportMessage responseMessage = null;
try {
responseMessage = transportFacade.sendSync(mqttMessage, null);
} catch (Exception e) {
fail(e.getMessage());
}
//
// Verify
assertNull("responseMessage", responseMessage);
// Clean
try {
transportFacade.clean();
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.eclipse.kapua.transport.TransportClientFactory in project kapua by eclipse.
the class KuraDeviceCallImpl method borrowClient.
//
// Private methods
//
private TransportFacade borrowClient() throws KuraMqttDeviceCallException {
TransportFacade transportFacade;
try {
KapuaLocator locator = KapuaLocator.getInstance();
TransportClientFactory transportClientFactory = locator.getFactory(TransportClientFactory.class);
transportFacade = transportClientFactory.getFacade();
} catch (Exception e) {
throw new KuraMqttDeviceCallException(KuraMqttDeviceCallErrorCodes.CALL_ERROR, e, (Object[]) null);
}
return transportFacade;
}
Aggregations