SGF-374 - Specifying a disk-store on a GatewayHub forces the GatewayHub to be persistent.
This commit is contained in:
@@ -120,10 +120,9 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.hasText(gatewayProxy.getOrderPolicy())) {
|
if (StringUtils.hasText(gatewayProxy.getOrderPolicy())) {
|
||||||
String orderPolicyValue = gatewayProxy.getOrderPolicy().trim().toUpperCase();
|
OrderPolicy orderPolicy = getOrderPolicyEnum(gatewayProxy.getOrderPolicy());
|
||||||
OrderPolicy orderPolicy = OrderPolicy.valueOf(orderPolicyValue);
|
|
||||||
Assert.notNull(orderPolicy, String.format("The specified order-policy '%1$s' is not valid!",
|
Assert.notNull(orderPolicy, String.format("The specified order-policy '%1$s' is not valid!",
|
||||||
orderPolicyValue));
|
gatewayProxy.getOrderPolicy()));
|
||||||
gateway.setOrderPolicy(orderPolicy);
|
gateway.setOrderPolicy(orderPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +140,21 @@ public class GatewayHubFactoryBean extends AbstractWANComponentFactoryBean<Gatew
|
|||||||
queueAttributes.setMaximumQueueMemory(queue.getMaximumQueueMemory());
|
queueAttributes.setMaximumQueueMemory(queue.getMaximumQueueMemory());
|
||||||
|
|
||||||
if (queue.getDiskStoreRef() != null) {
|
if (queue.getDiskStoreRef() != null) {
|
||||||
boolean persistent = (queue.getPersistent() == null) ? Boolean.TRUE : queue.getPersistent();
|
|
||||||
Assert.isTrue(persistent, "specifying a disk store requires persistent property to be true");
|
|
||||||
queueAttributes.setDiskStoreName(queue.getDiskStoreRef());
|
queueAttributes.setDiskStoreName(queue.getDiskStoreRef());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Gateway.OrderPolicy getOrderPolicyEnum(final String value) {
|
||||||
|
try {
|
||||||
|
return OrderPolicy.valueOf(value.trim().toUpperCase());
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ignore) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void autoStart() {
|
private void autoStart() {
|
||||||
if (!gatewayHub.getManualStart()) {
|
if (!gatewayHub.getManualStart()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Matchers.same;
|
import static org.mockito.Matchers.same;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -97,17 +98,6 @@ public class GatewayHubFactoryBeanTest {
|
|||||||
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
|
assertEquals(GatewayHub.DEFAULT_MANUAL_START, factoryBean.isManualStart(GatewayHub.DEFAULT_MANUAL_START));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void testSetAndGetMaxConnections() {
|
|
||||||
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
|
|
||||||
factoryBean.setMaxConnections(8192);
|
|
||||||
assertEquals(8192, factoryBean.getMaxConnections().intValue());
|
|
||||||
factoryBean.setMaxConnections(null);
|
|
||||||
assertEquals(GatewayHub.DEFAULT_MAX_CONNECTIONS, factoryBean.getMaxConnections().intValue());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetAndGetMaximumTimeBetweenPings() {
|
public void testSetAndGetMaximumTimeBetweenPings() {
|
||||||
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
|
assertEquals(GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS, factoryBean.getMaximumTimeBetweenPings().intValue());
|
||||||
@@ -259,6 +249,61 @@ public class GatewayHubFactoryBeanTest {
|
|||||||
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(eq(gatewayQueue.getPersistent()));
|
verify(mockGatewayQueueAttributes, times(1)).setEnablePersistence(eq(gatewayQueue.getPersistent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testGatewayHubWithInvalidStartupPolicy() throws Exception {
|
||||||
|
try {
|
||||||
|
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testGatewayHubWithInvalidStartupPolicy.MockGatewayHub");
|
||||||
|
|
||||||
|
when(mockCache.addGatewayHub(eq("testGatewayHubWithInvalidStartupPolicy"), eq(1234))).thenReturn(mockGatewayHub);
|
||||||
|
when(mockCache.getGatewayHub(eq("testGatewayHubWithInvalidStartupPolicy"))).thenReturn(mockGatewayHub);
|
||||||
|
|
||||||
|
factoryBean.setName("testGatewayHubWithInvalidStartupPolicy");
|
||||||
|
factoryBean.setPort(1234);
|
||||||
|
factoryBean.setStartupPolicy("invalid");
|
||||||
|
factoryBean.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException expected) {
|
||||||
|
assertEquals("The specified startup-policy 'invalid' is not valid!", expected.getMessage());
|
||||||
|
throw expected;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
verify(mockCache, times(1)).addGatewayHub(eq("testGatewayHubWithInvalidStartupPolicy"), eq(1234));
|
||||||
|
verify(mockCache, times(1)).getGatewayHub(eq("testGatewayHubWithInvalidStartupPolicy"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testGatewayQueueWithInvalidOrderPolicy() throws Exception {
|
||||||
|
GatewayHub mockGatewayHub = mock(GatewayHub.class, "testGatewayQueueWithInvalidOrderPolicy.MockGatewayHub");
|
||||||
|
Gateway mockGateway = mock(Gateway.class, "testGatewayQueueWithInvalidOrderPolicy.MockGateway");
|
||||||
|
|
||||||
|
try {
|
||||||
|
GatewayProxy gatewayProxy = new GatewayProxy();
|
||||||
|
|
||||||
|
gatewayProxy.setId("123");
|
||||||
|
gatewayProxy.setConcurrencyLevel(8);
|
||||||
|
gatewayProxy.setOrderPolicy("values");
|
||||||
|
|
||||||
|
when(mockCache.addGatewayHub(eq("testGatewayQueueWithInvalidOrderPolicy"), anyInt())).thenReturn(mockGatewayHub);
|
||||||
|
when(mockCache.getGatewayHub(eq("testGatewayQueueWithInvalidOrderPolicy"))).thenReturn(mockGatewayHub);
|
||||||
|
when(mockGatewayHub.addGateway(eq("123"), eq(8))).thenReturn(mockGateway);
|
||||||
|
|
||||||
|
factoryBean.setGateways(Arrays.asList(gatewayProxy));
|
||||||
|
factoryBean.setName("testGatewayQueueWithInvalidOrderPolicy");
|
||||||
|
factoryBean.setPort(1234);
|
||||||
|
factoryBean.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException expected) {
|
||||||
|
assertEquals("The specified order-policy 'values' is not valid!", expected.getMessage());
|
||||||
|
throw expected;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
verify(mockCache, times(1)).addGatewayHub(eq("testGatewayQueueWithInvalidOrderPolicy"), eq(1234));
|
||||||
|
verify(mockCache, times(1)).getGatewayHub(eq("testGatewayQueueWithInvalidOrderPolicy"));
|
||||||
|
verify(mockGatewayHub, times(1)).addGateway(eq("123"), eq(8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGatewayQueueWithOverflowNoPersistence() throws Exception {
|
public void testGatewayQueueWithOverflowNoPersistence() throws Exception {
|
||||||
String gatewayHubName = "testGatewayQueueWithOverflowNoPersistence";
|
String gatewayHubName = "testGatewayQueueWithOverflowNoPersistence";
|
||||||
|
|||||||
Reference in New Issue
Block a user