use of org.apache.geode.distributed.internal.membership.gms.interfaces.Manager in project geode by apache.
the class GMSHealthMonitorJUnitTest method initMocks.
@Before
public void initMocks() throws UnknownHostException {
// System.setProperty("gemfire.bind-address", "localhost");
mockDistConfig = mock(DistributionConfig.class);
mockConfig = mock(ServiceConfig.class);
messenger = mock(Messenger.class);
joinLeave = mock(JoinLeave.class);
manager = mock(Manager.class);
services = mock(Services.class);
Stopper stopper = mock(Stopper.class);
Properties nonDefault = new Properties();
nonDefault.put(ACK_WAIT_THRESHOLD, "1");
nonDefault.put(ACK_SEVERE_ALERT_THRESHOLD, "10");
nonDefault.put(DISABLE_TCP, "true");
nonDefault.put(MCAST_PORT, "0");
nonDefault.put(MCAST_TTL, "0");
nonDefault.put(LOG_FILE, "");
nonDefault.put(LOG_LEVEL, "fine");
nonDefault.put(MEMBER_TIMEOUT, "2000");
nonDefault.put(LOCATORS, "localhost[10344]");
DM dm = mock(DM.class);
SocketCreatorFactory.setDistributionConfig(new DistributionConfigImpl(new Properties()));
InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
when(mockConfig.getMemberTimeout()).thenReturn(memberTimeout);
when(mockConfig.getMembershipPortRange()).thenReturn(portRange);
when(services.getConfig()).thenReturn(mockConfig);
when(services.getMessenger()).thenReturn(messenger);
when(services.getJoinLeave()).thenReturn(joinLeave);
when(services.getCancelCriterion()).thenReturn(stopper);
when(services.getManager()).thenReturn(manager);
when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
when(stopper.isCancelInProgress()).thenReturn(false);
if (mockMembers == null) {
mockMembers = new ArrayList<InternalDistributedMember>();
for (int i = 0; i < 7; i++) {
InternalDistributedMember mbr = new InternalDistributedMember("localhost", 8888 + i);
if (i == 0 || i == 1) {
mbr.setVmKind(DistributionManager.LOCATOR_DM_TYPE);
mbr.getNetMember().setPreferredForCoordinator(true);
}
mockMembers.add(mbr);
}
}
when(joinLeave.getMemberID()).thenReturn(mockMembers.get(myAddressIndex));
when(messenger.getMemberID()).thenReturn(mockMembers.get(myAddressIndex));
gmsHealthMonitor = new GMSHealthMonitorTest();
gmsHealthMonitor.init(services);
gmsHealthMonitor.start();
}
Aggregations