SGF-199 fixed GatewaySender manual-start

This commit is contained in:
David Turanski
2013-09-16 18:35:36 -04:00
parent fb4e184794
commit a4b6acff07
7 changed files with 234 additions and 51 deletions

View File

@@ -48,9 +48,9 @@ import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
/**
* This test is only valid for GF 7.0 and above
*
*
* @author David Turanski
*
*
*/
public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest {
@@ -148,7 +148,8 @@ public class GemfireV7GatewayNamespaceTest extends RecreatingContextTest {
assertTrue(transportFilters.get(0) instanceof TestTransportFilter);
assertEquals(1, gws.getRemoteDSId());
assertEquals(true, gws.isManualStart());
assertEquals(false, gws.isManualStart());
assertEquals(true,gws.isRunning());
assertEquals(10, gws.getAlertThreshold());
assertEquals(11, gws.getBatchSize());
assertEquals(3000, gws.getBatchTimeInterval());

View File

@@ -1,35 +1,41 @@
/*
* Copyright 2002-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.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 com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.util.Gateway.OrderPolicy;
import com.gemstone.gemfire.cache.wan.GatewayEventFilter;
import com.gemstone.gemfire.cache.wan.GatewaySender;
import com.gemstone.gemfire.cache.wan.GatewaySenderFactory;
import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
* @author David Turanski
*
*/
public class StubGatewaySenderFactory implements GatewaySenderFactory {
private int alertThreshold;
private boolean batchConflationEnabled;
private int batchSize;
@@ -49,6 +55,8 @@ public class StubGatewaySenderFactory implements GatewaySenderFactory {
private String name;
private boolean running = true;
private int remoteSystemId;
public StubGatewaySenderFactory() {
@@ -92,6 +100,18 @@ public class StubGatewaySenderFactory implements GatewaySenderFactory {
when(gatewaySender.isDiskSynchronous()).thenReturn(this.diskSynchronous);
when(gatewaySender.isParallel()).thenReturn(this.parallel);
when(gatewaySender.isPersistenceEnabled()).thenReturn(this.persistenceEnabled);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
running = true;
return null;
}
}).when(gatewaySender).start();
when(gatewaySender.isRunning()).thenAnswer(new Answer<Boolean>(){
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return running;
}
});
return gatewaySender;
}