Search in sources :

Example 6 with Channel

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;
}
Also used : Channel(io.joynr.messaging.info.Channel) BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation)

Example 7 with 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);
}
Also used : Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 8 with Channel

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();
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Channel

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());
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) Channel(io.joynr.messaging.info.Channel) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 10 with Channel

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());
}
Also used : Channel(io.joynr.messaging.info.Channel) Test(org.junit.Test)

Aggregations

Channel (io.joynr.messaging.info.Channel)11 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)5 Test (org.junit.Test)5 URI (java.net.URI)2 LinkedList (java.util.LinkedList)2 EntityManager (javax.persistence.EntityManager)2 Query (javax.persistence.Query)2 JoynrHttpException (io.joynr.communications.exceptions.JoynrHttpException)1 JoynrCommunicationException (io.joynr.exceptions.JoynrCommunicationException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)1 ChannelEntity (io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.ChannelEntity)1 BounceProxyInformation (io.joynr.messaging.info.BounceProxyInformation)1 ChannelInformation (io.joynr.messaging.info.ChannelInformation)1 EntityTransaction (javax.persistence.EntityTransaction)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Ignore (org.junit.Ignore)1