use of org.eclipse.hono.config.ClientConfigProperties 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());
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class IntegrationTestSupport method init.
/**
* Connects to the AMQP 1.0 Messaging Network.
*
* @param ctx The vert.x test context.
*/
public void init(final TestContext ctx) {
registry = new DeviceRegistryHttpClient(vertx, IntegrationTestSupport.HONO_DEVICEREGISTRY_HOST, IntegrationTestSupport.HONO_DEVICEREGISTRY_HTTP_PORT);
final ClientConfigProperties downstreamProps = new ClientConfigProperties();
downstreamProps.setHost(IntegrationTestSupport.DOWNSTREAM_HOST);
downstreamProps.setPort(IntegrationTestSupport.DOWNSTREAM_PORT);
downstreamProps.setUsername(IntegrationTestSupport.DOWNSTREAM_USER);
downstreamProps.setPassword(IntegrationTestSupport.DOWNSTREAM_PWD);
downstreamClient = new HonoClientImpl(vertx, downstreamProps);
downstreamClient.connect().setHandler(ctx.asyncAssertSuccess());
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class DeviceRegistryAmqpTestSupport method prepareDeviceRegistryClient.
/**
* Build a HonoClient to access the device registry service.
*
* @param vertx The Vert.x instance to execute the client on, if {@code null} a new Vert.x instance is used.
* @return The client that is configured for accessing the device registry.
*/
protected static HonoClient prepareDeviceRegistryClient(final Vertx vertx) {
final ClientConfigProperties clientProps = new ClientConfigProperties();
clientProps.setName("test");
clientProps.setHost(IntegrationTestSupport.HONO_DEVICEREGISTRY_HOST);
clientProps.setPort(IntegrationTestSupport.HONO_DEVICEREGISTRY_AMQP_PORT);
clientProps.setUsername(IntegrationTestSupport.HONO_USER);
clientProps.setPassword(IntegrationTestSupport.HONO_PWD);
return new HonoClientImpl(vertx, clientProps);
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class ConnectionFactoryImplTest method testConnectEnablesSslIfTrustStoreIsConfigured.
/**
* Verifies that the factory uses TLS when connecting to the peer if a trust store
* is configured but TLS has not been enabled explicitly.
*/
@SuppressWarnings("unchecked")
@Test
public void testConnectEnablesSslIfTrustStoreIsConfigured() {
// GIVEN a factory configured to use a specific trust store
final ClientConfigProperties config = new ClientConfigProperties();
config.setHost("remote.host");
config.setTrustStorePath("/tmp/trusted-ca.p12");
final ProtonClient client = mock(ProtonClient.class);
final ConnectionFactoryImpl factory = new ConnectionFactoryImpl(vertx, config);
factory.setProtonClient(client);
// WHEN connecting to the server
factory.connect(null, null, null, c -> {
});
// THEN the factory uses TLS when establishing the connection
final ArgumentCaptor<ProtonClientOptions> optionsCaptor = ArgumentCaptor.forClass(ProtonClientOptions.class);
verify(client).connect(optionsCaptor.capture(), eq("remote.host"), anyInt(), any(), any(), any(Handler.class));
assertTrue(optionsCaptor.getValue().isSsl());
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class AbstractAdapterConfig method messagingClientConfig.
/**
* Exposes configuration properties for accessing a Hono Messaging service as a Spring bean.
* <p>
* The properties can be customized in subclasses by means of overriding the
* {@link #customizeMessagingClientConfig(ClientConfigProperties)} method.
*
* @return The properties.
*/
@Qualifier(Constants.QUALIFIER_MESSAGING)
@ConfigurationProperties(prefix = "hono.messaging")
@Bean
public ClientConfigProperties messagingClientConfig() {
final ClientConfigProperties config = new ClientConfigProperties();
customizeMessagingClientConfig(config);
return config;
}
Aggregations