public void testDoesNotAssignPassiveLeafIfDisabled() throws Exception { ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true); DHTSettings.ENABLE_PASSIVE_LEAF_DHT_MODE.setValue(false); long startTime = System.currentTimeMillis() - DHTSettings.MIN_PASSIVE_LEAF_DHT_INITIAL_UPTIME.getValue(); PrivilegedAccessor.setValue(nodeAssigner, "startTime", new Long(startTime)); mockery.checking(buildBandwdithExpectations(true)); mockery.checking( buildDHTExpectations( DHTMode.INACTIVE, true, true, false, // can't receive unsolicited DHTSettings.MIN_PASSIVE_LEAF_DHT_AVERAGE_UPTIME.getValue() + 1, false, false)); mockery.checking( new Expectations() { { never(dhtManager).start(with(Matchers.any(DHTMode.class))); } }); assignerRunnable.run(); mockery.assertIsSatisfied(); }
public void testPassiveLeafDoesNotNeedHardCore() throws Exception { // not accepted incoming previously therefore not hardcore long startTime = System.currentTimeMillis() - DHTSettings.MIN_PASSIVE_LEAF_DHT_INITIAL_UPTIME.getValue(); PrivilegedAccessor.setValue(nodeAssigner, "startTime", new Long(startTime)); mockery.checking(buildBandwdithExpectations(true)); mockery.checking( buildDHTExpectations( DHTMode.INACTIVE, true, true, false, // can't receive unsolicited DHTSettings.MIN_PASSIVE_LEAF_DHT_AVERAGE_UPTIME.getValue() + 1, false, false)); mockery.checking( new Expectations() { { one(dhtManager).start(DHTMode.PASSIVE_LEAF); } }); assignerRunnable.run(); mockery.assertIsSatisfied(); }