use of io.joynr.messaging.info.Channel in project joynr by bmwcarit.
the class AbstractChannelSetUpTest method createChannel.
protected Channel createChannel(String bpId, String baseUrl, String ccid) {
BounceProxyInformation bounceProxy = new BounceProxyInformation(bpId, URI.create(baseUrl));
Channel channel = new Channel(bounceProxy, ccid, URI.create(baseUrl + "/channels/" + ccid));
return channel;
}
use of io.joynr.messaging.info.Channel in project joynr by bmwcarit.
the class ChannelServiceImplTest method testCreateChannel.
@Test
public void testCreateChannel() throws JoynrProtocolException {
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("X.Y", URI.create("http://bpX.de"));
Mockito.when(channelAssignmentStrategyMock.calculateBounceProxy("channel-123")).thenReturn(bpInfo);
Mockito.when(bpMock.createChannel(bpInfo, "channel-123", "trackingId-xyz")).thenReturn(URI.create("http://bpX.de/channels/channel-123"));
Channel channel = channelService.createChannel("channel-123", "trackingId-xyz");
assertEquals("channel-123", channel.getChannelId());
assertEquals("X.Y", channel.getBounceProxy().getId());
assertEquals("http://bpX.de", channel.getBounceProxy().getLocation().toString());
assertEquals("http://bpX.de/channels/channel-123", channel.getLocation().toString());
Mockito.verify(channelDirectoryMock, Mockito.times(1)).addChannel(channel);
Mockito.verify(bpDirectoryMock).updateChannelAssignment("channel-123", bpInfo);
}
use of io.joynr.messaging.info.Channel in project joynr by bmwcarit.
the class DatabasesTest method testCascadingDelete.
@Test
@Ignore
public void testCascadingDelete() {
Assert.assertEquals(0, channelDb.getChannels().size());
ControlledBounceProxyInformation bpInfo = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo);
channelDb.addChannel(new Channel(bpInfo, "channel1", URI.create("http://www.joyn1.de/bp1/channels/channel1")));
Assert.assertEquals(1, bounceProxyDb.getAssignableBounceProxies().size());
Assert.assertEquals(1, channelDb.getChannels().size());
// delete bounce proxy
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
Query deleteBounceProxiesQuery = em.createQuery("DELETE FROM BounceProxyEntity");
Assert.assertEquals(3, deleteBounceProxiesQuery.executeUpdate());
tx.commit();
Assert.assertEquals(0, bounceProxyDb.getAssignableBounceProxies().size());
Assert.assertEquals(0, channelDb.getChannels().size());
tx.begin();
Query deleteBounceProxyInformationQuery = em.createQuery("DELETE FROM BounceProxyInformationEntity");
Assert.assertEquals(0, deleteBounceProxyInformationQuery.executeUpdate());
Query deleteChannelsQuery = em.createQuery("DELETE FROM ChannelEntity");
Assert.assertEquals(0, deleteChannelsQuery.executeUpdate());
tx.commit();
}
use of io.joynr.messaging.info.Channel in project joynr by bmwcarit.
the class DatabasesTest method testUpdateChannelAssignment.
@Test
public void testUpdateChannelAssignment() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
channelDb.addChannel(new Channel(bpInfo1, "channel-123", URI.create("http://www.joyn1.de/bp1/channels/channel-123")));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
bounceProxyDb.updateChannelAssignment("channel-123", bpInfo1);
List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(1, assignableBounceProxies.size());
BounceProxyRecord bpRecord1 = assignableBounceProxies.get(0);
Assert.assertEquals("bp1.0", bpRecord1.getBounceProxyId());
Assert.assertEquals(1, bpRecord1.getNumberOfAssignedChannels());
}
use of io.joynr.messaging.info.Channel in project joynr by bmwcarit.
the class DefaultBounceProxyChannelServiceImplTest method testCreateChannel.
@Test
public void testCreateChannel() {
Mockito.when(bpInfoMock.getId()).thenReturn("X.Y");
Mockito.when(bpInfoMock.getLocation()).thenReturn(URI.create("http://www.joynr.io"));
Mockito.when(longPollingDelegateMock.createChannel("channel-123", "trackingId-123")).thenReturn("channels/channel-123/");
Channel channel = channelService.createChannel("channel-123", "trackingId-123");
Assert.assertEquals("channel-123", channel.getChannelId());
Assert.assertEquals("http://www.joynr.io/channels/channel-123/", channel.getLocation().toString());
Assert.assertEquals(bpInfoMock, channel.getBounceProxy());
}
Aggregations