use of io.joynr.messaging.info.ControlledBounceProxyInformation 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.ControlledBounceProxyInformation 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.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class DatabasesTest method testUpdateBounceProxy.
@Test
public void testUpdateBounceProxy() {
ControlledBounceProxyInformation bpInfo1 = new ControlledBounceProxyInformation("bp1.0", URI.create("http://www.joynr1.de/bp1/"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(1000l);
bounceProxyDb.addBounceProxy(bpInfo1);
BounceProxyRecord bpRecord = new BounceProxyRecord(bpInfo1);
bpRecord.setFreshness(6000l);
bpRecord.setLastAssignedTimestamp(4000l);
bpRecord.setStatus(BounceProxyStatus.ACTIVE);
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(2000l);
bounceProxyDb.updateBounceProxy(bpRecord);
List<BounceProxyRecord> assignableBounceProxies = bounceProxyDb.getAssignableBounceProxies();
Assert.assertEquals(1, assignableBounceProxies.size());
BounceProxyRecord resultRecord = bounceProxyDb.getBounceProxy("bp1.0");
Assert.assertEquals("bp1.0", resultRecord.getBounceProxyId());
Assert.assertEquals(2000l, resultRecord.getFreshness().getTime());
Assert.assertEquals(4000l, resultRecord.getLastAssignedTimestamp());
Assert.assertEquals(BounceProxyStatus.ACTIVE, resultRecord.getStatus());
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class InMemoryBounceProxyDirectoryTest method testUpdateBounceProxy.
@Test
public void testUpdateBounceProxy() {
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(100l);
directory.addBounceProxy(new ControlledBounceProxyInformation("X.Y", URI.create("http://www.location.de")));
BounceProxyRecord bounceProxyRecord = directory.getBounceProxy("X.Y");
bounceProxyRecord.getInfo().setLocation(URI.create("http://www.location-updated.de"));
bounceProxyRecord.getInfo().setLocationForBpc(URI.create("http://www.location-for-bpc-updated.de"));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(200l);
directory.updateBounceProxy(bounceProxyRecord);
BounceProxyRecord result = directory.getBounceProxy("X.Y");
assertEquals("http://www.location-updated.de", result.getInfo().getLocation().toString());
assertEquals("http://www.location-for-bpc-updated.de", result.getInfo().getLocationForBpc().toString());
assertEquals(200, result.getFreshness().getTime());
}
use of io.joynr.messaging.info.ControlledBounceProxyInformation in project joynr by bmwcarit.
the class InMemoryBounceProxyDirectoryTest method testUpdateChannelAssignment.
@Test
public void testUpdateChannelAssignment() {
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(100l);
directory.addBounceProxy(new ControlledBounceProxyInformation("X.Y", null));
Mockito.when(mockTimestampProvider.getCurrentTime()).thenReturn(200l);
directory.updateChannelAssignment("channel-123", new BounceProxyInformation("X.Y", null));
BounceProxyRecord bounceProxy = directory.getBounceProxy("X.Y");
assertNotNull(bounceProxy);
assertEquals(1, bounceProxy.getNumberOfAssignedChannels());
assertEquals(200, bounceProxy.getLastAssignedTimestamp());
}
Aggregations