Search in sources :

Example 1 with EventEndpoint

use of org.eclipse.hono.event.impl.EventEndpoint in project hono by eclipse.

the class StandaloneEventApiTest method prepareHonoServer.

/**
 * Sets up Hono Messaging service.
 *
 * @param ctx The 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 EventEndpoint eventEndpoint = new EventEndpoint(vertx);
    eventEndpoint.setMetrics(mock(MessagingMetrics.class));
    eventEndpoint.setEventAdapter(downstreamAdapter);
    eventEndpoint.setRegistrationAssertionValidator(assertionHelper);
    eventEndpoint.setConfiguration(configProperties);
    server = new HonoMessaging();
    server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(TestSupport.createAuthenticationService(createUser())));
    server.setConfig(configProperties);
    server.addEndpoint(eventEndpoint);
    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 : EventEndpoint(org.eclipse.hono.event.impl.EventEndpoint) 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) ClientErrorException(org.eclipse.hono.client.ClientErrorException) HonoUser(org.eclipse.hono.auth.HonoUser) Constants(org.eclipse.hono.util.Constants) ProtonClientOptions(io.vertx.proton.ProtonClientOptions) MessageSender(org.eclipse.hono.client.MessageSender) Message(org.apache.qpid.proton.message.Message) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) ProtonHelper(io.vertx.proton.ProtonHelper) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Activity(org.eclipse.hono.auth.Activity) HonoClientImpl(org.eclipse.hono.client.impl.HonoClientImpl) EventConstants(org.eclipse.hono.util.EventConstants) Future(io.vertx.core.Future) TestSupport(org.eclipse.hono.TestSupport) Authorities(org.eclipse.hono.auth.Authorities) HonoSaslAuthenticatorFactory(org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory) Mockito.mock(org.mockito.Mockito.mock) EventEndpoint(org.eclipse.hono.event.impl.EventEndpoint) HonoClientImpl(org.eclipse.hono.client.impl.HonoClientImpl) 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 ProtonHelper (io.vertx.proton.ProtonHelper)1 Message (org.apache.qpid.proton.message.Message)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 ClientErrorException (org.eclipse.hono.client.ClientErrorException)1 MessageSender (org.eclipse.hono.client.MessageSender)1 HonoClientImpl (org.eclipse.hono.client.impl.HonoClientImpl)1 ClientConfigProperties (org.eclipse.hono.config.ClientConfigProperties)1 EventEndpoint (org.eclipse.hono.event.impl.EventEndpoint)1 HonoSaslAuthenticatorFactory (org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory)1 Constants (org.eclipse.hono.util.Constants)1