use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class HonoClientImplTest method setUp.
/**
* Sets up fixture.
*/
@Before
public void setUp() {
con = mock(ProtonConnection.class);
when(con.getRemoteContainer()).thenReturn("server");
connectionFactory = new DisconnectHandlerProvidingConnectionFactory(con);
props = new ClientConfigProperties();
client = new HonoClientImpl(vertx, connectionFactory, props);
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class TelemetrySenderImplTest method setUp.
/**
* Sets up the fixture.
*/
@Before
public void setUp() {
vertx = mock(Vertx.class);
context = HonoClientUnitTestHelper.mockContext(vertx);
sender = HonoClientUnitTestHelper.mockProtonSender();
config = new ClientConfigProperties();
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class ConnectionFactoryImplTest method testConnectEnablesSslIfExplicitlyConfigured.
/**
* Verifies that the factory uses TLS when connecting to the peer if no trust store
* is configured but TLS has been enabled explicitly.
*/
@SuppressWarnings("unchecked")
@Test
public void testConnectEnablesSslIfExplicitlyConfigured() {
// GIVEN a factory configured to connect to a server using TLS
final ClientConfigProperties config = new ClientConfigProperties();
config.setHost("remote.host");
config.setTlsEnabled(true);
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 ConnectionFactoryImplTest method setup.
/**
* Sets up fixture.
*/
@Before
public void setup() {
props = new ClientConfigProperties();
props.setHost("127.0.0.1");
// no server running on port
props.setPort(25673);
props.setAmqpHostname("hono");
props.setName("client");
}
use of org.eclipse.hono.config.ClientConfigProperties in project hono by eclipse.
the class EventConsumerImplTest method testHandlerCallsCloseHook.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void testHandlerCallsCloseHook(final TestContext ctx, final BiConsumer<ProtonReceiver, ArgumentCaptor<Handler>> handlerCaptor) {
// GIVEN an open event consumer
final Async consumerCreation = ctx.async();
final BiConsumer<ProtonDelivery, Message> eventConsumer = mock(BiConsumer.class);
final RecordImpl attachments = new RecordImpl();
final Source source = mock(Source.class);
when(source.getAddress()).thenReturn("source/address");
final ProtonReceiver receiver = mock(ProtonReceiver.class);
when(receiver.isOpen()).thenReturn(Boolean.TRUE);
when(receiver.getSource()).thenReturn(source);
when(receiver.attachments()).thenReturn(attachments);
when(receiver.open()).then(answer -> {
attachments.set(EventConsumerImpl.KEY_LINK_ESTABLISHED, Boolean.class, Boolean.TRUE);
consumerCreation.complete();
return receiver;
});
final ProtonConnection con = mock(ProtonConnection.class);
when(con.createReceiver(anyString())).thenReturn(receiver);
final Handler<String> closeHook = mock(Handler.class);
final ArgumentCaptor<Handler> captor = ArgumentCaptor.forClass(Handler.class);
EventConsumerImpl.create(vertx.getOrCreateContext(), new ClientConfigProperties(), con, "source/address", eventConsumer, ok -> {
}, closeHook);
consumerCreation.await();
handlerCaptor.accept(receiver, captor);
// WHEN the receiver link is closed
captor.getValue().handle(Future.succeededFuture(receiver));
// THEN the close hook is called
verify(closeHook).handle(any());
// and the receiver link is closed
verify(receiver).close();
}
Aggregations