Search in sources :

Example 1 with BounceProxyInformation

use of io.joynr.messaging.info.BounceProxyInformation in project joynr by bmwcarit.

the class RoundRobinAssignmentTest method testAssignmentToUnassignedBounceProxySmallTimestamps.

@Test
public void testAssignmentToUnassignedBounceProxySmallTimestamps() {
    LinkedList<BounceProxyRecord> bpList = new LinkedList<BounceProxyRecord>();
    bpList.add(createBounceProxyRecordWithChannels("X1.Y1", 2, 2l));
    bpList.add(createBounceProxyRecordWithChannels("X2.Y2", 3, 3l));
    bpList.add(createBounceProxyRecord("X3.Y3"));
    Mockito.when(directoryMock.getAssignableBounceProxies()).thenReturn(bpList);
    BounceProxyInformation bounceProxy = assignmentStrategy.calculateBounceProxy("channel-123");
    Assert.assertEquals("X3.Y3", bounceProxy.getId());
    Mockito.verify(directoryMock, Mockito.never()).updateChannelAssignment("channel-123", bounceProxy);
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with BounceProxyInformation

use of io.joynr.messaging.info.BounceProxyInformation in project joynr by bmwcarit.

the class RoundRobinAssignmentTest method testAssignmentToUnassignedBounceProxy.

@Test
public void testAssignmentToUnassignedBounceProxy() {
    LinkedList<BounceProxyRecord> bpList = new LinkedList<BounceProxyRecord>();
    bpList.add(createBounceProxyRecordWithChannels("X1.Y1", 2, 23456456456l));
    bpList.add(createBounceProxyRecordWithChannels("X2.Y2", 3, 19837453453l));
    bpList.add(createBounceProxyRecord("X3.Y3"));
    Mockito.when(directoryMock.getAssignableBounceProxies()).thenReturn(bpList);
    BounceProxyInformation bounceProxy = assignmentStrategy.calculateBounceProxy("channel-123");
    Assert.assertEquals("X3.Y3", bounceProxy.getId());
    Mockito.verify(directoryMock, Mockito.never()).updateChannelAssignment("channel-123", bounceProxy);
}
Also used : BounceProxyRecord(io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord) BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with BounceProxyInformation

use of io.joynr.messaging.info.BounceProxyInformation in project joynr by bmwcarit.

the class InMemoryBounceProxyDirectoryTest method testUpdateChannelAssignmentOnNonExistingBounceProxy.

@Test
public void testUpdateChannelAssignmentOnNonExistingBounceProxy() {
    directory.addBounceProxy(new ControlledBounceProxyInformation("A.B", null));
    try {
        directory.updateChannelAssignment("channel-123", new BounceProxyInformation("X.Y", null));
        Assert.fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation) ControlledBounceProxyInformation(io.joynr.messaging.info.ControlledBounceProxyInformation) Test(org.junit.Test)

Example 4 with BounceProxyInformation

use of io.joynr.messaging.info.BounceProxyInformation in project joynr by bmwcarit.

the class SingleBounceProxyInformationProvider method setHostPath.

@Inject(optional = true)
public void setHostPath(@Named(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH) String hostPath, HttpServletRequest request) {
    if (hostPath.endsWith("/")) {
        hostPath = hostPath.substring(0, hostPath.length() - 1);
    }
    this.hostPath = hostPath;
    String servletContext = request.getServletContext().getContextPath();
    if (this.hostPath != null) {
        log.info("Using bounceproxy URL {} from property {}", hostPath, MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH);
        bpInfo = new BounceProxyInformation(hostPath, URI.create(hostPath + servletContext));
    }
}
Also used : BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation) Inject(com.google.inject.Inject)

Example 5 with BounceProxyInformation

use of io.joynr.messaging.info.BounceProxyInformation in project joynr by bmwcarit.

the class SingleBounceProxyInformationProvider method get.

@Override
public BounceProxyInformation get() {
    if (bpInfo == null) {
        log.info("No bounceproxy URL set from properties. Using bounceproxy URL {} created from request", hostPathFromRequest);
        bpInfo = new BounceProxyInformation(hostPathFromRequest.getHost(), hostPathFromRequest);
    }
    return bpInfo;
}
Also used : BounceProxyInformation(io.joynr.messaging.info.BounceProxyInformation)

Aggregations

BounceProxyInformation (io.joynr.messaging.info.BounceProxyInformation)10 ControlledBounceProxyInformation (io.joynr.messaging.info.ControlledBounceProxyInformation)7 Test (org.junit.Test)7 BounceProxyRecord (io.joynr.messaging.bounceproxy.controller.directory.BounceProxyRecord)4 LinkedList (java.util.LinkedList)4 Inject (com.google.inject.Inject)1 Channel (io.joynr.messaging.info.Channel)1