use of org.eclipse.hono.client.RegistrationClient in project hono by eclipse.
the class ClientTestBase method connect.
/**
* Sets up the environment:
* <ol>
* <li>connect to the AMQP messaging network</li>
* <li>connects to the Hono Server</li>
* <li>connects to the Hono Device Registry</li>
* <li>creates a RegistrationClient for TEST_TENANT_ID</li>
* <li>creates a MessageSender for TEST_TENANT_ID</li>
* </ul>
*
* @param ctx The test context
*/
@Before
public void connect(final TestContext ctx) {
final ClientConfigProperties downstreamProps = new ClientConfigProperties();
downstreamProps.setHost(IntegrationTestSupport.DOWNSTREAM_HOST);
downstreamProps.setPort(IntegrationTestSupport.DOWNSTREAM_PORT);
downstreamProps.setPathSeparator(IntegrationTestSupport.PATH_SEPARATOR);
downstreamProps.setUsername(IntegrationTestSupport.RESTRICTED_CONSUMER_NAME);
downstreamProps.setPassword(IntegrationTestSupport.RESTRICTED_CONSUMER_PWD);
downstreamClient = new HonoClientImpl(vertx, ConnectionFactoryBuilder.newBuilder(downstreamProps).vertx(vertx).build(), downstreamProps);
final ClientConfigProperties honoProps = new ClientConfigProperties();
honoProps.setHost(IntegrationTestSupport.HONO_HOST);
honoProps.setPort(IntegrationTestSupport.HONO_PORT);
honoProps.setUsername(IntegrationTestSupport.HONO_USER);
honoProps.setPassword(IntegrationTestSupport.HONO_PWD);
honoClient = new HonoClientImpl(vertx, ConnectionFactoryBuilder.newBuilder(honoProps).vertx(vertx).build(), honoProps);
final ClientConfigProperties registryProps = new ClientConfigProperties();
registryProps.setHost(IntegrationTestSupport.HONO_DEVICEREGISTRY_HOST);
registryProps.setPort(IntegrationTestSupport.HONO_DEVICEREGISTRY_AMQP_PORT);
registryProps.setUsername(IntegrationTestSupport.HONO_USER);
registryProps.setPassword(IntegrationTestSupport.HONO_PWD);
honoDeviceRegistryClient = new HonoClientImpl(vertx, ConnectionFactoryBuilder.newBuilder(registryProps).vertx(vertx).build(), registryProps);
final ProtonClientOptions options = new ProtonClientOptions();
// connect to AMQP messaging network
final Future<HonoClient> downstreamTracker = downstreamClient.connect(options);
// create sender
final Future<MessageSender> senderTracker = honoClient.connect(options).compose(connectedClient -> createProducer(TEST_TENANT_ID)).map(s -> {
sender = s;
return s;
});
// create registration client
final Future<RegistrationClient> registrationClientTracker = honoDeviceRegistryClient.connect(options).compose(connectedClient -> connectedClient.getOrCreateRegistrationClient(TEST_TENANT_ID)).map(c -> {
registrationClient = c;
return c;
});
CompositeFuture.all(downstreamTracker, senderTracker, registrationClientTracker).setHandler(ctx.asyncAssertSuccess(s -> {
LOGGER.info("connections to Hono server, Hono device registry and AMQP messaging network established");
}));
}
use of org.eclipse.hono.client.RegistrationClient in project hono by eclipse.
the class AbstractProtocolAdapterBaseTest method setup.
/**
* Sets up the fixture.
*/
@Before
public void setup() {
registrationClient = mock(RegistrationClient.class);
HonoClient honoClient = mock(HonoClient.class);
when(honoClient.getOrCreateRegistrationClient(anyString())).thenReturn(Future.succeededFuture(registrationClient));
properties = new ProtocolAdapterProperties();
adapter = newProtocolAdapter(properties);
adapter.setRegistrationServiceClient(honoClient);
}
Aggregations