SGF-398 - Provide early support of Apache Geode (Pivotal GemFire OSS).
Test source compilation and test resource processing build step complete.
This commit is contained in:
@@ -41,11 +41,11 @@ import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayQueueEvent;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
/**
|
||||
|
||||
@@ -137,8 +137,6 @@ public class TemplateClientRegionNamespaceTest {
|
||||
assertNull(region.getAttributes().getCustomEntryIdleTimeout());
|
||||
assertNull(region.getAttributes().getCustomEntryTimeToLive());
|
||||
assertNull(region.getAttributes().getDiskStoreName());
|
||||
assertFalse(region.getAttributes().getEnableGateway());
|
||||
assertNullEmpty(region.getAttributes().getGatewayHubId());
|
||||
assertFalse(region.getAttributes().getMulticastEnabled());
|
||||
assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive());
|
||||
assertDefaultExpirationAttributes(region.getAttributes().getRegionIdleTimeout());
|
||||
|
||||
@@ -243,8 +243,6 @@ public class TemplateRegionsNamespaceTests {
|
||||
assertNull(region.getAttributes().getCustomEntryIdleTimeout());
|
||||
assertNull(region.getAttributes().getCustomEntryTimeToLive());
|
||||
assertNull(region.getAttributes().getDiskStoreName());
|
||||
assertFalse(region.getAttributes().getEnableGateway());
|
||||
assertNullEmpty(region.getAttributes().getGatewayHubId());
|
||||
assertFalse(region.getAttributes().getMulticastEnabled());
|
||||
assertNullEmpty(region.getAttributes().getPoolName());
|
||||
assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive());
|
||||
|
||||
@@ -16,9 +16,15 @@
|
||||
|
||||
package org.springframework.data.gemfire.listener.adapter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -27,7 +33,6 @@ import org.springframework.data.gemfire.listener.ContinuousQueryListener;
|
||||
import com.gemstone.gemfire.cache.Operation;
|
||||
import com.gemstone.gemfire.cache.query.CqEvent;
|
||||
import com.gemstone.gemfire.cache.query.CqQuery;
|
||||
import com.gemstone.gemfire.cache.query.internal.CqQueryImpl;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
@@ -43,12 +48,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
CqEvent event() {
|
||||
CqEvent event = new CqEvent() {
|
||||
final CqQuery cq = new CqQueryImpl();
|
||||
final byte[] ba = new byte[0];
|
||||
return new CqEvent() {
|
||||
final CqQuery cq = mock(CqQuery.class);
|
||||
final byte[] deltaValue = new byte[0];
|
||||
final Object key = new Object();
|
||||
final Object value = new Object();
|
||||
final Exception ex = new Exception();
|
||||
final Exception exception = new Exception();
|
||||
|
||||
public Operation getBaseOperation() {
|
||||
return Operation.CACHE_CLOSE;
|
||||
@@ -59,7 +64,7 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
public byte[] getDeltaValue() {
|
||||
return ba;
|
||||
return deltaValue;
|
||||
}
|
||||
|
||||
public Object getKey() {
|
||||
@@ -75,14 +80,14 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
public Throwable getThrowable() {
|
||||
return ex;
|
||||
return exception;
|
||||
}
|
||||
};
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static interface Delegate {
|
||||
|
||||
void handleEvent(CqEvent event);
|
||||
|
||||
void handleQuery(CqQuery query);
|
||||
@@ -99,8 +104,7 @@ public class QueryListenerAdapterTest {
|
||||
|
||||
void handleOps(Operation base, Operation query);
|
||||
|
||||
void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp,
|
||||
Object v);
|
||||
void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, Object v);
|
||||
|
||||
void handleInvalid(Object o1, Object o2, Object o3);
|
||||
}
|
||||
@@ -112,111 +116,122 @@ public class QueryListenerAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testThatTheDefaultHandlingMethodNameIsTheConstantDefault() throws Exception {
|
||||
assertEquals(ContinuousQueryListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD, adapter.getDefaultListenerMethod());
|
||||
assertEquals(ContinuousQueryListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD,
|
||||
adapter.getDefaultListenerMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdapterWithListenerAndDefaultMessage() throws Exception {
|
||||
ContinuousQueryListener mock = mock(ContinuousQueryListener.class);
|
||||
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
ContinuousQueryListener mockCqListener = mock(ContinuousQueryListener.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockCqListener);
|
||||
CqEvent event = event();
|
||||
adapter.onEvent(event);
|
||||
verify(mock).onEvent(event);
|
||||
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockCqListener).onEvent(same(event));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEvent() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleEvent(event);
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleEvent(same(event));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleArray() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleArray");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleArray(event.getDeltaValue());
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleArray");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleArray(eq(event.getDeltaValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleKey() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleKey");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleKey(event.getKey());
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleKey");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleKey(eq(event.getKey()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleKV() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleKV");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleKV(event.getKey(), event.getNewValue());
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleKV");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleKV(eq(event.getKey()), eq(event.getNewValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEx() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleEx");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleEx(event.getThrowable());
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleEx");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleEx(eq(event.getThrowable()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleOps() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleOps");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleOps(event.getBaseOperation(), event.getQueryOperation());
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleOps");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleOps(eq(event.getBaseOperation()), eq(event.getQueryOperation()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleAll() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleAll");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
CqEvent event = event();
|
||||
|
||||
adapter.onEvent(event);
|
||||
verify(mock).handleAll(event, event.getCq(), event.getDeltaValue(), event.getKey(), event.getBaseOperation(),
|
||||
event.getThrowable(), event.getQueryOperation(), event.getNewValue());
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleAll");
|
||||
cqListenerAdapter.onEvent(event);
|
||||
|
||||
verify(mockDelegate).handleAll(eq(event), eq(event.getCq()), eq(event.getDeltaValue()), eq(event.getKey()),
|
||||
eq(event.getBaseOperation()), eq(event.getThrowable()), eq(event.getQueryOperation()),
|
||||
eq(event.getNewValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalid() throws Exception {
|
||||
Delegate mock = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter adapter = new ContinuousQueryListenerAdapter(mock);
|
||||
adapter.setDefaultListenerMethod("handleInvalid");
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
adapter.onEvent(event());
|
||||
doThrow(new IllegalArgumentException()).when(mock);
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleInvalid");
|
||||
cqListenerAdapter.onEvent(event());
|
||||
|
||||
doThrow(new IllegalArgumentException()).when(mockDelegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SGF-89
|
||||
* @link https://jira.spring.io/browse/SGF-89
|
||||
*/
|
||||
@Test
|
||||
public void triggersListenerImplementingInterfaceCorrectly() {
|
||||
|
||||
SampleListener listener = new SampleListener();
|
||||
|
||||
ContinuousQueryListener listenerAdapter = new ContinuousQueryListenerAdapter(listener) {
|
||||
@@ -238,4 +253,5 @@ public class QueryListenerAdapterTest {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.test;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.GatewayEventListener;
|
||||
import com.gemstone.gemfire.cache.util.GatewayQueueAttributes;
|
||||
|
||||
/**
|
||||
* The MockGatewayFactory class is a factory for creating mock GemFire Gateways, GatewayQueueAttributes
|
||||
* and Gateway.Endpoints.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.util.Gateway
|
||||
* @see com.gemstone.gemfire.cache.util.GatewayHub
|
||||
* @since 1.5.3
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
public class MockGatewayFactory extends AbstractMockerySupport {
|
||||
|
||||
private Boolean batchConflation = GatewayQueueAttributes.DEFAULT_BATCH_CONFLATION;
|
||||
private Boolean persistence = GatewayQueueAttributes.DEFAULT_ENABLE_PERSISTENCE;
|
||||
|
||||
private Gateway.OrderPolicy orderPolicy;
|
||||
|
||||
private GatewayQueueAttributes queueAttributes;
|
||||
|
||||
private Integer alertThreshold = GatewayQueueAttributes.DEFAULT_ALERT_THRESHOLD;
|
||||
private Integer batchSize = GatewayQueueAttributes.DEFAULT_BATCH_SIZE;
|
||||
private Integer batchTimeInterval = GatewayQueueAttributes.DEFAULT_BATCH_TIME_INTERVAL;
|
||||
private Integer maxQueueMemory = GatewayQueueAttributes.DEFAULT_MAXIMUM_QUEUE_MEMORY;
|
||||
private Integer socketBufferSize = Gateway.DEFAULT_SOCKET_BUFFER_SIZE;
|
||||
private Integer socketReadTimeout = Gateway.DEFAULT_SOCKET_READ_TIMEOUT;
|
||||
|
||||
private List<Gateway.Endpoint> endpoints;
|
||||
private List<GatewayEventListener> listeners;
|
||||
|
||||
private String diskStoreName;
|
||||
|
||||
public MockGatewayFactory() {
|
||||
endpoints = new ArrayList<Gateway.Endpoint>();
|
||||
listeners = new ArrayList<GatewayEventListener>();
|
||||
queueAttributes = mockGatewayQueueAttributes();
|
||||
}
|
||||
|
||||
public Gateway mockGateway(final String id, final int concurrencyLevel) {
|
||||
Gateway mockGateway = mock(Gateway.class, String.format("%1$s.MockGateway", getMockId()));
|
||||
|
||||
when(mockGateway.getConcurrencyLevel()).thenReturn(concurrencyLevel);
|
||||
when(mockGateway.getEndpoints()).thenReturn(endpoints);
|
||||
when(mockGateway.getId()).thenReturn(id);
|
||||
when(mockGateway.getListeners()).thenReturn(listeners);
|
||||
when(mockGateway.getQueueSize()).thenThrow(new UnsupportedOperationException(NOT_IMPLEMENTED));
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
orderPolicy = invocation.getArgumentAt(0, Gateway.OrderPolicy.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).setOrderPolicy(any(Gateway.OrderPolicy.class));
|
||||
|
||||
when(mockGateway.getOrderPolicy()).thenAnswer(new Answer<Gateway.OrderPolicy>() {
|
||||
@Override public Gateway.OrderPolicy answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return orderPolicy;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
queueAttributes = invocation.getArgumentAt(0, GatewayQueueAttributes.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).setQueueAttributes(any(GatewayQueueAttributes.class));
|
||||
|
||||
when(mockGateway.getQueueAttributes()).thenAnswer(new Answer<GatewayQueueAttributes>() {
|
||||
@Override public GatewayQueueAttributes answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return queueAttributes;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
socketBufferSize = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).setSocketBufferSize(anyInt());
|
||||
|
||||
when(mockGateway.getSocketBufferSize()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return socketBufferSize;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
socketReadTimeout = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).setSocketReadTimeout(anyInt());
|
||||
|
||||
when(mockGateway.getSocketReadTimeout()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return socketReadTimeout;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
String id = invocation.getArgumentAt(0, String.class);
|
||||
String host = invocation.getArgumentAt(1, String.class);
|
||||
int port = invocation.getArgumentAt(2, Integer.class);
|
||||
endpoints.add(mockGatewayEndpoint(id, host, port));
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).addEndpoint(anyString(), anyString(), anyInt());
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
listeners.add(invocation.getArgumentAt(0, GatewayEventListener.class));
|
||||
return null;
|
||||
}
|
||||
}).when(mockGateway).addListener(any(GatewayEventListener.class));
|
||||
|
||||
return mockGateway;
|
||||
}
|
||||
|
||||
public Gateway.Endpoint mockGatewayEndpoint(final String id, final String host, final int port) {
|
||||
Gateway.Endpoint mockEndpoint = mock(Gateway.Endpoint.class,
|
||||
String.format("%1$s.MockGatewayEndpoint", getMockId()));
|
||||
|
||||
when(mockEndpoint.getId()).thenReturn(id);
|
||||
when(mockEndpoint.getHost()).thenReturn(host);
|
||||
when(mockEndpoint.getPort()).thenReturn(port);
|
||||
|
||||
return mockEndpoint;
|
||||
}
|
||||
|
||||
public GatewayQueueAttributes mockGatewayQueueAttributes() {
|
||||
GatewayQueueAttributes mockQueueAttributes = mock(GatewayQueueAttributes.class,
|
||||
String.format("%1$s.MockGatewayQueueAttributes", getMockId()));
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
alertThreshold = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setAlertThreshold(anyInt());
|
||||
|
||||
when(mockQueueAttributes.getAlertThreshold()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return alertThreshold;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
batchConflation = invocation.getArgumentAt(0, Boolean.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setBatchConflation(anyBoolean());
|
||||
|
||||
when(mockQueueAttributes.getBatchConflation()).thenAnswer(new Answer<Boolean>() {
|
||||
@Override public Boolean answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return batchConflation;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
batchSize = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setBatchSize(anyInt());
|
||||
|
||||
when(mockQueueAttributes.getBatchSize()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return batchSize;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
batchTimeInterval = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setBatchTimeInterval(anyInt());
|
||||
|
||||
when(mockQueueAttributes.getBatchTimeInterval()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return batchTimeInterval;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
diskStoreName = invocation.getArgumentAt(0, String.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setDiskStoreName(anyString());
|
||||
|
||||
when(mockQueueAttributes.getDiskStoreName()).thenAnswer(new Answer<String>() {
|
||||
@Override public String answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return diskStoreName;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
persistence = invocation.getArgumentAt(0, Boolean.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setEnablePersistence(anyBoolean());
|
||||
|
||||
when(mockQueueAttributes.getEnablePersistence()).thenAnswer(new Answer<Boolean>() {
|
||||
@Override public Boolean answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return persistence;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
maxQueueMemory = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockQueueAttributes).setMaximumQueueMemory(anyInt());
|
||||
|
||||
when(mockQueueAttributes.getMaximumQueueMemory()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return maxQueueMemory;
|
||||
}
|
||||
});
|
||||
|
||||
return mockQueueAttributes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.test;
|
||||
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
|
||||
/**
|
||||
* The MockGatewayHubFactory class is a factory for creating mock GemFire GatewayHubs.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.test.AbstractMockerySupport
|
||||
* @see org.springframework.data.gemfire.wan.GatewayHubFactoryBean
|
||||
* @see com.gemstone.gemfire.cache.util.Gateway
|
||||
* @see com.gemstone.gemfire.cache.util.GatewayHub
|
||||
* @since 1.5.3
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
public class MockGatewayHubFactory extends AbstractMockerySupport {
|
||||
|
||||
private static final AtomicLong ID_SEQUENCE = new AtomicLong(System.currentTimeMillis());
|
||||
|
||||
private Boolean manualStart = GatewayHub.DEFAULT_MANUAL_START;
|
||||
|
||||
private Integer maximumConnections = GatewayHub.DEFAULT_MAX_CONNECTIONS;
|
||||
private Integer maximumTimeBetweenPings = GatewayHub.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS;
|
||||
private Integer socketBufferSize = GatewayHub.DEFAULT_SOCKET_BUFFER_SIZE;
|
||||
|
||||
private List<Gateway> gateways = new ArrayList<Gateway>();
|
||||
|
||||
private String bindAddress = GatewayHub.DEFAULT_BIND_ADDRESS;
|
||||
private String startupPolicy = GatewayHub.DEFAULT_STARTUP_POLICY;
|
||||
|
||||
public GatewayHub mockGatewayHub(final String id, final int port) {
|
||||
final GatewayHub mockGatewayHub = mock(GatewayHub.class, String.format("%1$s.MockGatewayHub", getMockId()));
|
||||
|
||||
when(mockGatewayHub.getGateways()).thenReturn(gateways);
|
||||
when(mockGatewayHub.getGatewayIds()).thenReturn(getGatewayIds(gateways));
|
||||
when(mockGatewayHub.getId()).thenReturn(id);
|
||||
when(mockGatewayHub.getPort()).thenReturn(port);
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
bindAddress = invocation.getArgumentAt(0, String.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setBindAddress(anyString());
|
||||
|
||||
when(mockGatewayHub.getBindAddress()).thenAnswer(new Answer<String>() {
|
||||
@Override public String answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return bindAddress;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
manualStart = invocation.getArgumentAt(0, Boolean.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setManualStart(anyBoolean());
|
||||
|
||||
when(mockGatewayHub.getManualStart()).thenAnswer(new Answer<Boolean>() {
|
||||
@Override public Boolean answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return manualStart;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
maximumConnections = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setMaxConnections(anyInt());
|
||||
|
||||
when(mockGatewayHub.getMaxConnections()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return maximumConnections;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
maximumTimeBetweenPings = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setMaximumTimeBetweenPings(anyInt());
|
||||
|
||||
when(mockGatewayHub.getMaximumTimeBetweenPings()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return maximumTimeBetweenPings;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
socketBufferSize = invocation.getArgumentAt(0, Integer.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setSocketBufferSize(anyInt());
|
||||
|
||||
when(mockGatewayHub.getSocketBufferSize()).thenAnswer(new Answer<Integer>() {
|
||||
@Override public Integer answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return socketBufferSize;
|
||||
}
|
||||
});
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
startupPolicy = invocation.getArgumentAt(0, String.class);
|
||||
return null;
|
||||
}
|
||||
}).when(mockGatewayHub).setStartupPolicy(anyString());
|
||||
|
||||
when(mockGatewayHub.getStartupPolicy()).thenAnswer(new Answer<String>() {
|
||||
@Override public String answer(final InvocationOnMock invocation) throws Throwable {
|
||||
return startupPolicy;
|
||||
}
|
||||
});
|
||||
|
||||
when(mockGatewayHub.addGateway(anyString())).thenAnswer(new Answer<Gateway>() {
|
||||
@Override public Gateway answer(final InvocationOnMock invocation) throws Throwable {
|
||||
String id = invocation.getArgumentAt(0, String.class);
|
||||
return mockGatewayHub.addGateway(id, Gateway.DEFAULT_CONCURRENCY_LEVEL);
|
||||
}
|
||||
});
|
||||
|
||||
when(mockGatewayHub.addGateway(anyString(), anyInt())).thenAnswer(new Answer<Gateway>() {
|
||||
@Override public Gateway answer(final InvocationOnMock invocation) throws Throwable {
|
||||
String id = invocation.getArgumentAt(0, String.class);
|
||||
Integer concurrencyLevel = invocation.getArgumentAt(1, Integer.class);
|
||||
Gateway mockGateway = new MockGatewayFactory().mockGateway(id, concurrencyLevel);
|
||||
when(mockGateway.getGatewayHubId()).thenReturn(id);
|
||||
gateways.add(mockGateway);
|
||||
return mockGateway;
|
||||
}
|
||||
});
|
||||
|
||||
return mockGatewayHub;
|
||||
}
|
||||
|
||||
private List<String> getGatewayIds(final List<Gateway> gateways) {
|
||||
List<String> gatewayIds = new ArrayList<String>(gateways.size());
|
||||
|
||||
for (Gateway gateway : gateways) {
|
||||
gatewayIds.add(gateway.getId());
|
||||
}
|
||||
|
||||
return gatewayIds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,8 +51,8 @@ import com.gemstone.gemfire.cache.query.QueryService;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MockRegionFactory<K,V> {
|
||||
|
||||
private static QueryService queryService = mock(QueryService.class);
|
||||
private static RegionService regionService = mock(RegionService.class);
|
||||
private static QueryService mockQueryService = mock(QueryService.class);
|
||||
private static RegionService mockRegionService = mock(RegionService.class);
|
||||
|
||||
private com.gemstone.gemfire.cache.AttributesFactory<K,V> attributesFactory;
|
||||
|
||||
@@ -172,14 +172,15 @@ public class MockRegionFactory<K,V> {
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setDiskDirsAndSizes(any(File[].class), any(int[].class))).thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
File[] diskDirectories = (File[]) invocation.getArguments()[0];
|
||||
int[] diskSizes = (int[]) invocation.getArguments()[1];
|
||||
attributesFactory.setDiskDirsAndSizes(diskDirectories, diskSizes);
|
||||
return regionFactory;
|
||||
}
|
||||
});
|
||||
when(regionFactory.setDiskDirsAndSizes(any(File[].class), any(int[].class))).thenAnswer(
|
||||
new Answer<RegionFactory>() {
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
File[] diskDirectories = (File[]) invocation.getArguments()[0];
|
||||
int[] diskSizes = (int[]) invocation.getArguments()[1];
|
||||
attributesFactory.setDiskDirsAndSizes(diskDirectories, diskSizes);
|
||||
return regionFactory;
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setDiskStoreName(anyString())).thenAnswer(new Answer<RegionFactory>() {
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
@@ -223,14 +224,6 @@ public class MockRegionFactory<K,V> {
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setEnableGateway(anyBoolean())).thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
boolean enableGateway = (Boolean) invocation.getArguments()[0];
|
||||
attributesFactory.setEnableGateway(enableGateway);
|
||||
return regionFactory;
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setEnableSubscriptionConflation(anyBoolean())).thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
boolean enableSubscriptionConflation = (Boolean) invocation.getArguments()[0];
|
||||
@@ -279,14 +272,6 @@ public class MockRegionFactory<K,V> {
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setGatewayHubId(anyString())).thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
String gatewayHubId = (String) invocation.getArguments()[0];
|
||||
attributesFactory.setGatewayHubId(gatewayHubId);
|
||||
return regionFactory;
|
||||
}
|
||||
});
|
||||
|
||||
when(regionFactory.setIgnoreJTA(anyBoolean())).thenAnswer(new Answer<RegionFactory>(){
|
||||
@Override public RegionFactory answer(InvocationOnMock invocation) throws Throwable {
|
||||
boolean ignoreJta = (Boolean) invocation.getArguments()[0];
|
||||
@@ -500,14 +485,13 @@ public class MockRegionFactory<K,V> {
|
||||
return region;
|
||||
}
|
||||
|
||||
public static RegionService mockRegionService() {
|
||||
when(regionService.getQueryService()).thenReturn(mockQueryService());
|
||||
return regionService;
|
||||
}
|
||||
|
||||
public static QueryService mockQueryService() {
|
||||
return queryService;
|
||||
return mockQueryService;
|
||||
}
|
||||
|
||||
public static RegionService mockRegionService() {
|
||||
when(mockRegionService.getQueryService()).thenReturn(mockQueryService());
|
||||
return mockRegionService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.List;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory;
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventSubstitutionFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
@@ -105,28 +105,28 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory {
|
||||
}
|
||||
|
||||
//The following added in 7.0.1
|
||||
public AsyncEventQueueFactory setBatchConflationEnabled(boolean arg0) {
|
||||
this.batchConflationEnabled = arg0;
|
||||
public AsyncEventQueueFactory setBatchConflationEnabled(boolean batchConflationEnabled) {
|
||||
this.batchConflationEnabled = batchConflationEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncEventQueueFactory setBatchTimeInterval(int arg0) {
|
||||
this.batchTimeInterval = arg0;
|
||||
public AsyncEventQueueFactory setBatchTimeInterval(int batchTimeInterval) {
|
||||
this.batchTimeInterval = batchTimeInterval;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncEventQueueFactory setDiskSynchronous(boolean arg0) {
|
||||
this.diskSynchronous = arg0;
|
||||
public AsyncEventQueueFactory setDiskSynchronous(boolean diskSynchronous) {
|
||||
this.diskSynchronous = diskSynchronous;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncEventQueueFactory setDispatcherThreads(int arg0) {
|
||||
this.dispatcherThreads = arg0;
|
||||
public AsyncEventQueueFactory setDispatcherThreads(int dispatchThreads) {
|
||||
this.dispatcherThreads = dispatchThreads;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AsyncEventQueueFactory setOrderPolicy(OrderPolicy arg0) {
|
||||
this.orderPolicy = arg0;
|
||||
public AsyncEventQueueFactory setOrderPolicy(OrderPolicy orderPolicy) {
|
||||
this.orderPolicy = orderPolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class StubAsyncEventQueueFactory implements AsyncEventQueueFactory {
|
||||
@Override
|
||||
public AsyncEventQueueFactory setGatewayEventSubstitutionListener(final GatewayEventSubstitutionFilter gatewayEventSubstitutionFilter) {
|
||||
this.gatewayEventSubstitutionFilter = gatewayEventSubstitutionFilter;
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.gemstone.gemfire.cache.query.RegionNotFoundException;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.cache.snapshot.CacheSnapshotService;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
import com.gemstone.gemfire.cache.util.GatewayHub;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiver;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
@@ -85,9 +84,7 @@ public class StubCache implements Cache {
|
||||
|
||||
private GatewayConflictResolver gatewayConflictResolver;
|
||||
|
||||
private HashMap<String, Region> allRegions;
|
||||
|
||||
private List<GatewayHub> gatewayHubs;
|
||||
private Map<String, Region> rootRegions;
|
||||
|
||||
private LogWriter logWriter;
|
||||
private LogWriter securityLogWriter;
|
||||
@@ -105,8 +102,7 @@ public class StubCache implements Cache {
|
||||
private String name;
|
||||
|
||||
public StubCache(){
|
||||
allRegions = new HashMap<String,Region>();
|
||||
gatewayHubs = new ArrayList<GatewayHub>();
|
||||
rootRegions = new HashMap<String, Region>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -396,17 +392,6 @@ public class StubCache implements Cache {
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#addGatewayHub(java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public GatewayHub addGatewayHub(final String id, final int port) {
|
||||
GatewayHub gatewayHub = getGatewayHub(id);
|
||||
gatewayHub = (gatewayHub != null ? gatewayHub : new MockGatewayHubFactory().mockGatewayHub(id, port));
|
||||
gatewayHubs.add(gatewayHub);
|
||||
return gatewayHub;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#close(boolean)
|
||||
*/
|
||||
@@ -543,37 +528,6 @@ public class StubCache implements Cache {
|
||||
return this.gatewayConflictResolver;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#getGatewayHub()
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public GatewayHub getGatewayHub() {
|
||||
return (gatewayHubs.isEmpty() ? null : gatewayHubs.get(0));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#getGatewayHub(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public GatewayHub getGatewayHub(final String id) {
|
||||
for (GatewayHub gatewayHub : gatewayHubs) {
|
||||
if (gatewayHub.getId().equals(id)) {
|
||||
return gatewayHub;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#getGatewayHubs()
|
||||
*/
|
||||
@Override
|
||||
public List<GatewayHub> getGatewayHubs() {
|
||||
return this.gatewayHubs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#getGatewayReceivers()
|
||||
*/
|
||||
@@ -697,22 +651,12 @@ public class StubCache implements Cache {
|
||||
this.gatewayConflictResolver = arg0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#setGatewayHub(java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public GatewayHub setGatewayHub(String arg0, int arg1) {
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.Cache#setIsServer(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setIsServer(boolean arg0) {
|
||||
this.server = arg0;
|
||||
|
||||
public void setIsServer(boolean server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -866,7 +810,7 @@ public class StubCache implements Cache {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Map<String,Region> allRegions() {
|
||||
return this.allRegions;
|
||||
return this.rootRegions;
|
||||
}
|
||||
|
||||
public void setProperties(Properties gemfireProperties) {
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.List;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayEventSubstitutionFilter;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue;
|
||||
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueueFactory;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
|
||||
/**
|
||||
* The AsyncEventQueueFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
@@ -84,7 +84,8 @@ public class AsyncEventQueueFactoryBeanTest {
|
||||
String orderPolicy = TestUtils.readField("orderPolicy", factoryBean);
|
||||
|
||||
if (orderPolicy != null) {
|
||||
verify(mockAsyncEventQueueFactory).setOrderPolicy(eq(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase())));
|
||||
verify(mockAsyncEventQueueFactory).setOrderPolicy(eq(GatewaySender.OrderPolicy.valueOf(
|
||||
orderPolicy.toUpperCase())));
|
||||
}
|
||||
|
||||
Integer dispatcherThreads = TestUtils.readField("dispatcherThreads", factoryBean);
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.junit.Test;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.util.Gateway;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySender;
|
||||
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
|
||||
@@ -39,7 +38,6 @@ import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
|
||||
* @author John Blum
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewaySender
|
||||
* @see com.gemstone.gemfire.cache.util.Gateway
|
||||
* @see com.gemstone.gemfire.cache.wan.GatewaySenderFactory
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
@@ -76,7 +74,8 @@ public class GatewaySenderFactoryBeanTest {
|
||||
String orderPolicy = TestUtils.readField("orderPolicy", factoryBean);
|
||||
|
||||
if (orderPolicy != null) {
|
||||
verify(mockGatewaySenderFactory).setOrderPolicy(eq(Gateway.OrderPolicy.valueOf(orderPolicy.toUpperCase())));
|
||||
verify(mockGatewaySenderFactory).setOrderPolicy(eq(GatewaySender.OrderPolicy.valueOf(
|
||||
orderPolicy.toUpperCase())));
|
||||
}
|
||||
|
||||
Integer dispatcherThreads = TestUtils.readField("dispatcherThreads", factoryBean);
|
||||
|
||||
Reference in New Issue
Block a user