Search in sources :

Example 1 with TelemetryEndpoint

use of org.eclipse.hono.telemetry.impl.TelemetryEndpoint in project hono by eclipse.

the class StandaloneTelemetryApiTest method prepareHonoServer.

/**
 * Sets up the fixture common to all test cases.
 *
 * @param ctx The vert.x test context.
 */
@BeforeClass
public static void prepareHonoServer(final TestContext ctx) {
    vertx = Vertx.vertx();
    downstreamAdapter = new MessageDiscardingDownstreamAdapter(vertx);
    final HonoMessagingConfigProperties configProperties = new HonoMessagingConfigProperties();
    configProperties.setInsecurePort(0);
    final TelemetryEndpoint telemetryEndpoint = new TelemetryEndpoint(vertx);
    telemetryEndpoint.setMetrics(mock(MessagingMetrics.class));
    telemetryEndpoint.setTelemetryAdapter(downstreamAdapter);
    telemetryEndpoint.setRegistrationAssertionValidator(assertionHelper);
    telemetryEndpoint.setConfiguration(configProperties);
    server = new HonoMessaging();
    server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(TestSupport.createAuthenticationService(createUser())));
    server.setConfig(configProperties);
    server.addEndpoint(telemetryEndpoint);
    final Future<String> serverTracker = Future.future();
    vertx.deployVerticle(server, serverTracker.completer());
    serverTracker.compose(s -> {
        final ClientConfigProperties clientProps = new ClientConfigProperties();
        clientProps.setName("test");
        clientProps.setHost(server.getInsecurePortBindAddress());
        clientProps.setPort(server.getInsecurePort());
        clientProps.setUsername(USER);
        clientProps.setPassword(PWD);
        client = new HonoClientImpl(vertx, clientProps);
        return client.connect(new ProtonClientOptions());
    }).setHandler(ctx.asyncAssertSuccess());
}
Also used : HonoSaslAuthenticatorFactory(org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory) TestContext(io.vertx.ext.unit.TestContext) AuthoritiesImpl(org.eclipse.hono.auth.AuthoritiesImpl) HonoUserAdapter(org.eclipse.hono.auth.HonoUserAdapter) BeforeClass(org.junit.BeforeClass) RunWith(org.junit.runner.RunWith) Vertx(io.vertx.core.Vertx) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Activity(org.eclipse.hono.auth.Activity) HonoUser(org.eclipse.hono.auth.HonoUser) HonoClientImpl(org.eclipse.hono.client.impl.HonoClientImpl) Future(io.vertx.core.Future) TelemetryEndpoint(org.eclipse.hono.telemetry.impl.TelemetryEndpoint) TelemetryConstants(org.eclipse.hono.util.TelemetryConstants) TestSupport(org.eclipse.hono.TestSupport) ProtonClientOptions(io.vertx.proton.ProtonClientOptions) MessageSender(org.eclipse.hono.client.MessageSender) Authorities(org.eclipse.hono.auth.Authorities) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) HonoSaslAuthenticatorFactory(org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory) Mockito.mock(org.mockito.Mockito.mock) HonoClientImpl(org.eclipse.hono.client.impl.HonoClientImpl) TelemetryEndpoint(org.eclipse.hono.telemetry.impl.TelemetryEndpoint) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) ProtonClientOptions(io.vertx.proton.ProtonClientOptions) BeforeClass(org.junit.BeforeClass)

Aggregations

Future (io.vertx.core.Future)1 Vertx (io.vertx.core.Vertx)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 ProtonClientOptions (io.vertx.proton.ProtonClientOptions)1 TestSupport (org.eclipse.hono.TestSupport)1 Activity (org.eclipse.hono.auth.Activity)1 Authorities (org.eclipse.hono.auth.Authorities)1 AuthoritiesImpl (org.eclipse.hono.auth.AuthoritiesImpl)1 HonoUser (org.eclipse.hono.auth.HonoUser)1 HonoUserAdapter (org.eclipse.hono.auth.HonoUserAdapter)1 MessageSender (org.eclipse.hono.client.MessageSender)1 HonoClientImpl (org.eclipse.hono.client.impl.HonoClientImpl)1 ClientConfigProperties (org.eclipse.hono.config.ClientConfigProperties)1 HonoSaslAuthenticatorFactory (org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory)1 TelemetryEndpoint (org.eclipse.hono.telemetry.impl.TelemetryEndpoint)1 TelemetryConstants (org.eclipse.hono.util.TelemetryConstants)1 BeforeClass (org.junit.BeforeClass)1 RunWith (org.junit.runner.RunWith)1 Mockito.mock (org.mockito.Mockito.mock)1