use of io.vertx.ext.unit.TestContext in project hono by eclipse.
the class VertxBasedMqttProtocolAdapterTest method testMapTopicFailsForQoS2EventMessage.
/**
* Verifies that the adapter rejects QoS 2 messages published to the <em>event</em> endpoint.
*
* @param ctx The helper to use for running tests on vert.x.
*/
@Test
public void testMapTopicFailsForQoS2EventMessage(final TestContext ctx) {
givenAnAdapter();
// WHEN a device publishes a message with QoS 2 to an "event" topic
final MqttPublishMessage message = newMessage(MqttQoS.EXACTLY_ONCE, EventConstants.EVENT_ENDPOINT);
adapter.mapTopic(message).setHandler(ctx.asyncAssertFailure(t -> {
// THEN no downstream sender can be created for the message
}));
}
use of io.vertx.ext.unit.TestContext in project hono by eclipse.
the class VertxBasedMqttProtocolAdapterTest method testMapTopicFailsForQoS2TelemetryMessage.
/**
* Verifies that the adapter rejects QoS 2 messages published to the <em>telemetry</em> endpoint.
*
* @param ctx The helper to use for running tests on vert.x.
*/
@Test
public void testMapTopicFailsForQoS2TelemetryMessage(final TestContext ctx) {
givenAnAdapter();
// WHEN a device publishes a message with QoS 2 to a "telemetry" topic
final MqttPublishMessage message = newMessage(MqttQoS.EXACTLY_ONCE, TelemetryConstants.TELEMETRY_ENDPOINT);
adapter.mapTopic(message).setHandler(ctx.asyncAssertFailure(t -> {
// THEN no downstream sender can be created for the message
}));
}
use of io.vertx.ext.unit.TestContext in project hono by eclipse.
the class VertxBasedMqttProtocolAdapterTest method testMapTopicFailsForUnknownEndpoint.
/**
* Verifies that the adapter rejects messages published to topics containing an endpoint
* other than <em>telemetry</em> or <em>event</em>.
*
* @param ctx The helper to use for running tests on vert.x.
*/
@Test
public void testMapTopicFailsForUnknownEndpoint(final TestContext ctx) {
givenAnAdapter();
// WHEN a device publishes a message to a topic with an unknown endpoint
final MqttPublishMessage message = newMessage(MqttQoS.AT_MOST_ONCE, "unknown");
adapter.mapTopic(message).setHandler(ctx.asyncAssertFailure(t -> {
// THEN no downstream sender can be created for the message
}));
}
use of io.vertx.ext.unit.TestContext in project hono by eclipse.
the class VertxBasedMqttProtocolAdapterTest method testMapTopicFailsForQoS0EventMessage.
/**
* Verifies that the adapter rejects QoS 0 messages published to the <em>event</em> endpoint.
*
* @param ctx The helper to use for running tests on vert.x.
*/
@Test
public void testMapTopicFailsForQoS0EventMessage(final TestContext ctx) {
givenAnAdapter();
// WHEN a device publishes a message with QoS 0 to an "event" topic
final MqttPublishMessage message = newMessage(MqttQoS.AT_MOST_ONCE, EventConstants.EVENT_ENDPOINT);
adapter.mapTopic(message).setHandler(ctx.asyncAssertFailure(t -> {
// THEN no downstream sender can be created for the message
}));
}
use of io.vertx.ext.unit.TestContext in project hono by eclipse.
the class VertxBasedMqttProtocolAdapterTest method testOnPublishedAuthenticatedMessageFailsForMissingDeviceId.
/**
* Verifies that the adapter fails to map a topic without a device ID received from an authenticated device.
*
* @param ctx The helper to use for running tests on vert.x.
*/
@Test
public void testOnPublishedAuthenticatedMessageFailsForMissingDeviceId(final TestContext ctx) {
givenAnAdapter();
// WHEN an authenticated device publishes a message to a topic that does not contain a device ID
final MqttContext context = newContext(MqttQoS.AT_MOST_ONCE, TelemetryConstants.TELEMETRY_ENDPOINT + "/my-tenant", new Device("my-tenant", "device"));
adapter.onPublishedMessage(context).setHandler(ctx.asyncAssertFailure(t -> {
// THEN the message cannot be mapped to an address
}));
}
Aggregations