コード例 #1
0
  public void testDoesNotAssignActiveIfNotHardcore() throws Exception {
    // not accepted incoming previously therefore not hardcore
    long startTime =
        System.currentTimeMillis() - DHTSettings.MIN_ACTIVE_DHT_INITIAL_UPTIME.getValue();
    PrivilegedAccessor.setValue(nodeAssigner, "startTime", new Long(startTime));

    mockery.checking(buildBandwdithExpectations(true));
    mockery.checking(
        buildDHTExpectations(
            DHTMode.INACTIVE,
            true,
            true,
            true,
            DHTSettings.MIN_ACTIVE_DHT_AVERAGE_UPTIME.getValue() + 1,
            false,
            false));

    mockery.checking(
        new Expectations() {
          {
            one(dhtManager).start(DHTMode.PASSIVE_LEAF);
          }
        });

    assignerRunnable.run();
    mockery.assertIsSatisfied();
  }
コード例 #2
0
  public void testStopsDHTWhenDisabled() throws Exception {
    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
    long startTime =
        System.currentTimeMillis() - DHTSettings.MIN_ACTIVE_DHT_INITIAL_UPTIME.getValue();
    PrivilegedAccessor.setValue(nodeAssigner, "startTime", new Long(startTime));

    mockery.checking(buildBandwdithExpectations(true));
    mockery.checking(
        buildDHTExpectations(
            DHTMode.ACTIVE,
            false,
            true,
            true,
            DHTSettings.MIN_ACTIVE_DHT_AVERAGE_UPTIME.getValue() + 1,
            false,
            false));

    mockery.checking(
        new Expectations() {
          {
            one(dhtManager).stop();
          }
        });

    assignerRunnable.run();
    mockery.assertIsSatisfied();
  }
コード例 #3
0
  public void testDoesNotAssignLowInitialUptime() throws Exception {
    ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);

    // no initial uptime
    mockery.checking(buildBandwdithExpectations(true));
    mockery.checking(
        buildDHTExpectations(
            DHTMode.INACTIVE,
            true,
            true,
            true,
            DHTSettings.MIN_ACTIVE_DHT_AVERAGE_UPTIME.getValue() + 1,
            false,
            false));

    mockery.checking(
        new Expectations() {
          {
            never(dhtManager).start(with(Matchers.any(DHTMode.class)));
          }
        });

    assignerRunnable.run();
    mockery.assertIsSatisfied();
  }