use of io.vertx.proton.ProtonSession in project hono by eclipse.
the class ForwardingDownstreamAdapterTest method setup.
/**
* Initializes mocks etc.
*/
@Before
public void setup() {
attachments = mock(Record.class);
ProtonSession session = mock(ProtonSession.class);
con = mock(ProtonConnection.class);
when(con.getRemoteContainer()).thenReturn("downstream");
when(con.createSession()).thenReturn(session);
when(con.attachments()).thenReturn(attachments);
connectionFactory = newMockConnectionFactory(con, false);
}
use of io.vertx.proton.ProtonSession in project hono by eclipse.
the class AbstractRequestResponseEndpointTest method setUp.
/**
* Initializes common fixture.
*/
@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() {
connection = mock(ProtonConnection.class);
vertx = mock(Vertx.class);
eventBus = mock(EventBus.class);
receiver = mock(ProtonReceiver.class);
when(receiver.handler(any())).thenReturn(receiver);
when(receiver.closeHandler(any())).thenReturn(receiver);
when(receiver.setAutoAccept(any(Boolean.class))).thenReturn(receiver);
when(receiver.setPrefetch(any(Integer.class))).thenReturn(receiver);
when(receiver.setQoS(any(ProtonQoS.class))).thenReturn(receiver);
when(vertx.eventBus()).thenReturn(eventBus);
final ProtonSession session = mock(ProtonSession.class);
when(session.getConnection()).thenReturn(connection);
sender = mock(ProtonSender.class);
when(sender.getName()).thenReturn("mocked sender");
when(sender.isOpen()).thenReturn(Boolean.TRUE);
when(sender.getSession()).thenReturn(session);
authService = mock(AuthorizationService.class);
when(authService.isAuthorized(any(HonoUser.class), any(ResourceIdentifier.class), anyString())).thenReturn(Future.succeededFuture(Boolean.TRUE));
formalMessageVerification = mock(BiFunction.class);
when(formalMessageVerification.apply(any(ResourceIdentifier.class), any(Message.class))).thenReturn(Boolean.TRUE);
requestMessageHandler = mock(BiFunction.class);
endpoint = getEndpoint();
}
use of io.vertx.proton.ProtonSession in project hono by eclipse.
the class AbstractRequestResponseEndpointTest method testFreeSubscription.
/**
* Verify that a second response link to the same address is being accepted if the first is released before.
*/
@Test
public void testFreeSubscription() {
final ProtonConnection con1 = mock(ProtonConnection.class);
final ProtonSession session1 = mock(ProtonSession.class);
when(session1.getConnection()).thenReturn(con1);
final ProtonConnection con2 = mock(ProtonConnection.class);
final ProtonSender sender1 = mock(ProtonSender.class);
when(sender1.getSession()).thenReturn(session1);
final ProtonSender sender2 = mock(ProtonSender.class);
// WHEN a first sender attaches
endpoint.onLinkAttach(con1, sender1, REPLY_RESOURCE);
// THEN open has to be called
verify(sender1).open();
// WHEN the connection closed
endpoint.onConnectionClosed(con1);
// WHEN a new link is attached
endpoint.onLinkAttach(con2, sender2, REPLY_RESOURCE);
// THEN open has to be called
verify(sender2).open();
}
Aggregations