@Override
  public void setUp() throws Exception {
    ranker = new LegacyRanker();

    Injector injector = LimeTestUtils.createInjectorNonEagerly();
    remoteFileDescFactory = injector.getInstance(RemoteFileDescFactory.class);
  }
    @Override
    public void setUp() throws Exception {
        networkManagerStub = new NetworkManagerStub();
        networkManagerStub.setPort(PORT);
        Injector injector = LimeTestUtils.createInjector(MyActivityCallback.class, new LimeTestUtils.NetworkManagerStubModule(networkManagerStub));
        super.setUp(injector);

        DownloadManagerImpl downloadManager = (DownloadManagerImpl)injector.getInstance(DownloadManager.class);
        callback = (MyActivityCallback) injector.getInstance(ActivityCallback.class);
        
        downloadManager.clearAllDownloads();
        
        //      Turn off by default, explicitly test elsewhere.
        networkManagerStub.setIncomingTLSEnabled(false);
        networkManagerStub.setOutgoingTLSEnabled(false);
        // duplicate queries are sent out each time, so avoid the DuplicateFilter
        Thread.sleep(2000);        

        // send a MessagesSupportedMessage
        testUP[0].send(injector.getInstance(MessagesSupportedVendorMessage.class));
        testUP[0].flush();
        
        // we expect to get a PushProxy request
        Message m;
        do {
            m = testUP[0].receive(TIMEOUT);
        } while (!(m instanceof PushProxyRequest));

        // we should answer the push proxy request
        PushProxyAcknowledgement ack = new PushProxyAcknowledgement(InetAddress
                .getLocalHost(), 6355, new GUID(m.getGUID()));
        testUP[0].send(ack);
        testUP[0].flush();
    }
  @Override
  protected void setUp() throws Exception {
    super.setUp(LimeTestUtils.createInjector(Stage.PRODUCTION));

    // get the resource file for com/limegroup/gnutella
    File file = TestUtils.getResourceFile("com/limegroup/gnutella/metadata/ID3V24.mp3");
    assertNotNull(gnutellaFileCollection.add(file).get(1, TimeUnit.SECONDS));
  }
  @Override
  public void setUp() throws Exception {
    Expand.expandFile(
        TestUtils.getResourceFile("com/limegroup/gnutella/xml/xml.war"),
        CommonUtils.getUserSettingsDir());

    Injector injector = LimeTestUtils.createInjector();
    limeXMLSchemaRepository = injector.getInstance(LimeXMLSchemaRepository.class);
  }
 @Override
 protected void setUp() throws Exception {
   Injector injector = LimeTestUtils.createInjector(Stage.PRODUCTION);
   super.setUp(injector);
   connectionManager = injector.getInstance(ConnectionManager.class);
   queryRequestFactory = injector.getInstance(QueryRequestFactory.class);
   simppManager = injector.getInstance(SimppManager.class);
   staticMessages = injector.getInstance(StaticMessages.class);
 }
  @Override
  public void setUp() throws Exception {
    networkManagerStub = new NetworkManagerStub();
    Injector injector =
        LimeTestUtils.createInjector(
            Stage.PRODUCTION,
            MyCallback.class,
            new LimeTestUtils.NetworkManagerStubModule(networkManagerStub));
    super.setUp(injector);

    fileManager = injector.getInstance(FileManager.class);
    messagesSupportedVendorMessage = injector.getInstance(MessagesSupportedVendorMessage.class);
    searchServices = injector.getInstance(SearchServices.class);
    responseFactory = injector.getInstance(ResponseFactory.class);
    queryReplyFactory = injector.getInstance(QueryReplyFactory.class);
    replyNumberVendorMessageFactory = injector.getInstance(ReplyNumberVendorMessageFactory.class);
    queryRequestFactory = injector.getInstance(QueryRequestFactory.class);
    downloadServices = injector.getInstance(DownloadServices.class);
    messageRouter = injector.getInstance(MessageRouter.class);
    messageFactory = injector.getInstance(MessageFactory.class);
    pingReplyFactory = injector.getInstance(PingReplyFactory.class);
    onDemandUnicaster = injector.getInstance(OnDemandUnicaster.class);
    callback = (MyCallback) injector.getInstance(ActivityCallback.class);
    macManager = injector.getInstance(MACCalculatorRepositoryManager.class);
    remoteFileDescFactory = injector.getInstance(RemoteFileDescFactory.class);
    pushEndpointFactory = injector.getInstance(PushEndpointFactory.class);

    networkManagerStub.setAcceptedIncomingConnection(true);
    networkManagerStub.setCanReceiveSolicited(true);
    networkManagerStub.setCanReceiveUnsolicited(true);
    networkManagerStub.setOOBCapable(true);
    networkManagerStub.setPort(SERVER_PORT);

    File file = TestUtils.getResourceFile("com/limegroup/gnutella/metadata/metadata.mp3");
    assertNotNull(fileManager.getGnutellaFileList().add(file).get(1, TimeUnit.SECONDS));

    UDP_ACCESS = new DatagramSocket[10];
    for (int i = 0; i < UDP_ACCESS.length; i++) UDP_ACCESS[i] = new DatagramSocket();

    for (int i = 0; i < testUP.length; i++) {
      assertTrue("should be open", testUP[i].isOpen());
      assertTrue(
          "should be up -> leaf",
          testUP[i].getConnectionCapabilities().isSupernodeClientConnection());
      BlockingConnectionUtils.drain(testUP[i], 100);
      // OOB client side needs server side leaf guidance
      testUP[i].send(messagesSupportedVendorMessage);
      testUP[i].flush();
    }

    Thread.sleep(250);

    // we should now be guess capable and tcp incoming capable....
    // test on acceptor since network manager is stubbed out
    //        assertTrue(injector.getInstance(Acceptor.class).acceptedIncoming());
  }
  @Override
  public void setUp() throws Exception {
    routedConnectionFactory =
        LimeTestUtils.createInjector().getInstance(RoutedConnectionFactory.class);

    ACCEPTOR = new ConnectionAcceptor();
    ACCEPTOR.start();
    ConnectionSettings.ALLOW_WHILE_DISCONNECTED.setValue(true);
    ConnectionSettings.PREFERENCING_ACTIVE.setValue(false);
  }
  @Override
  protected void setUp() throws Exception {
    setSettings();
    mockery = new Mockery();
    upTracker = mockery.mock(BandwidthTracker.class);
    downTracker = mockery.mock(BandwidthTracker.class);
    dhtManager = mockery.mock(DHTManager.class);
    connectionServices = mockery.mock(ConnectionServices.class);
    networkManager = mockery.mock(NetworkManager.class);
    searchServices = mockery.mock(SearchServices.class);
    cManager = mockery.mock(ConnectionManager.class);

    final ScheduledExecutorService ses =
        new ScheduledExecutorServiceStub() {

          @Override
          public ScheduledFuture<?> scheduleWithFixedDelay(
              Runnable command, long initialDelay, long delay, TimeUnit unit) {
            if (delay == NodeAssignerImpl.TIMER_DELAY && initialDelay == 0)
              assignerRunnable = command;
            return null;
          }
        };
    injector =
        LimeTestUtils.createInjectorNonEagerly(
            new AbstractModule() {
              @Override
              protected void configure() {
                bind(BandwidthTracker.class)
                    .annotatedWith(Names.named("uploadTracker"))
                    .toInstance(upTracker);
                bind(BandwidthTracker.class)
                    .annotatedWith(Names.named("downloadTracker"))
                    .toInstance(downTracker);
                bind(DHTManager.class).toInstance(dhtManager);
                bind(NetworkManager.class).toInstance(networkManager);
                bind(ConnectionServices.class).toInstance(connectionServices);
                bind(ScheduledExecutorService.class)
                    .annotatedWith(Names.named("backgroundExecutor"))
                    .toInstance(ses);
                bind(ConnectionManager.class).toInstance(cManager);
                bind(SearchServices.class).toInstance(searchServices);
                bind(Executor.class)
                    .annotatedWith(Names.named("unlimitedExecutor"))
                    .toInstance(immediateExecutor);
              }
            });
    nodeAssigner = injector.getInstance(NodeAssigner.class);

    nodeAssigner.start();
    assertNotNull(assignerRunnable);
  }
 @Override
 protected void setUp() throws Exception {
   Injector injector =
       LimeTestUtils.createInjector(
           new AbstractModule() {
             @Override
             protected void configure() {
               bind(LocalSocketAddressProvider.class).to(LocalSocketAddressProviderStub.class);
             }
           });
   pingRequestFactory = injector.getInstance(PingRequestFactory.class);
   messageFactory = injector.getInstance(MessageFactory.class);
   connectionServices = injector.getInstance(ConnectionServices.class);
   tlsManager = injector.getInstance(TLSManager.class);
 }
 @Override
 protected void setUp() throws Exception {
   networkManagerStub = new NetworkManagerStub();
   networkManagerStub.setAcceptedIncomingConnection(true);
   networkManagerStub.setPort(SERVER_PORT);
   networkManagerStub.setExternalAddress(new byte[] {(byte) 129, 1, 4, 10});
   Injector injector =
       LimeTestUtils.createInjector(
           MyActivityCallback.class,
           new LimeTestUtils.NetworkManagerStubModule(networkManagerStub));
   super.setUp(injector);
   callback = (MyActivityCallback) injector.getInstance(ActivityCallback.class);
   searchServices = injector.getInstance(SearchServices.class);
   responseFactory = injector.getInstance(ResponseFactory.class);
   queryReplyFactory = injector.getInstance(QueryReplyFactory.class);
 }
  @Override
  public void setUp() throws Exception {
    // TODO: this statically injects HttpClientManager -- fix!
    injector = LimeTestUtils.createInjector();

    httpServers = new TestBootstrapServer[11];
    tlsServers = new TestBootstrapServer[11];
    httpUrls = new String[11];
    tlsUrls = new String[11];
    httpsUrls = new String[11];

    for (int i = 0; i < 11; i++) {
      httpServers[i] = new TestBootstrapServer(HTTP_PORT + i);
      tlsServers[i] = new TestBootstrapServer(TLS_PORT + i, true);
      httpUrls[i] = "http://127.0.0.1:" + (HTTP_PORT + i);
      tlsUrls[i] = "tls://127.0.0.1:" + (TLS_PORT + i);
      httpsUrls[i] = "https://127.0.0.1:" + (TLS_PORT + i);
    }
  }
  @Override
  public void setUp() throws Exception {
    Injector injector = LimeTestUtils.createInjector(Stage.PRODUCTION);
    acceptor = (AcceptorImpl) injector.getInstance(Acceptor.class);

    // set values before everything is initialized
    acceptor.setIncomingExpireTime(MY_EXPIRE_TIME);
    acceptor.setWaitTimeAfterRequests(MY_WAIT_TIME);
    acceptor.setTimeBetweenValidates(MY_VALIDATE_TIME);

    super.setUp(injector);

    messagesSupportedVendorMessage = injector.getInstance(MessagesSupportedVendorMessage.class);
    networkManager = injector.getInstance(NetworkManager.class);
    udpService = injector.getInstance(UDPService.class);
    connectionManager = injector.getInstance(ConnectionManager.class);
    pingRequestFactory = injector.getInstance(PingRequestFactory.class);
    replyNumberVendorMessageFactory = injector.getInstance(ReplyNumberVendorMessageFactory.class);

    exchangeSupportedMessages();
  }
  @Override
  public void setUp() throws Exception {

    final ResponseVerifier testVerifier = new TestResponseVerifier();
    Injector injector =
        LimeTestUtils.createInjector(
            new AbstractModule() {
              @Override
              protected void configure() {
                bind(ResponseVerifier.class).toInstance(testVerifier);
              }
            });

    super.setUp(injector);
    connectionManager = injector.getInstance(ConnectionManager.class);
    connectionServices = injector.getInstance(ConnectionServices.class);
    searchServices = injector.getInstance(SearchServices.class);

    int tries = 0;
    do {
      Thread.sleep(1000);
      if (connectionServices.isConnected()
          && connectionManager.getInitializedConnections().isEmpty()
          && connectionManager
                  .getInitializedConnections()
                  .get(0)
                  .getRoutedConnectionStatistics()
                  .getQueryRouteTablePercentFull()
              > 0) break;
    } while (tries++ < 10);
    assertTrue(connectionServices.isConnected());
    assertFalse(connectionManager.getInitializedConnections().isEmpty());
    assertGreaterThan(
        0,
        connectionManager
            .getInitializedConnections()
            .get(0)
            .getRoutedConnectionStatistics()
            .getQueryRouteTablePercentFull());
  }
 @Override
 protected void setUp() throws Exception {
   Injector injector = LimeTestUtils.createInjectorNonEagerly();
   limeXMLDocumentHelper = injector.getInstance(LimeXMLDocumentHelper.class);
 }
 @Override
 protected void setUp() throws Exception {
   context = new Mockery();
   Injector injector = LimeTestUtils.createInjectorNonEagerly();
   remoteFileDescFactory = injector.getInstance(RemoteFileDescFactory.class);
 }
  public void testServicesAdded() {
    final FakeRegistry registry = new FakeRegistry();
    LimeTestUtils.createInjector(
        new AbstractModule() {
          @Override
          protected void configure() {
            bind(ServiceRegistry.class).toInstance(registry);
          }
        });

    // Add/remove as services change
    String[] names =
        new String[] {
          "Network Management",
          "NetworkManagerImpl",
          "Update Checks",
          "UpdateHandlerImpl",
          "Download Management",
          "DownloadManagerImpl",
          "Old Downloads",
          "",
          "Browse Host Handler",
          "BrowseHostHandlerManagerImpl",
          "Statistic Management",
          "StatisticsAccumulatorImpl",
          "Upload Management",
          "HTTPUploadManager",
          "Promotion System",
          "PromotionServicesImpl",
          "Shared Files",
          "FileManagerImpl",
          "Ultrapeer/DHT Management",
          "NodeAssignerImpl",
          "Connection Listener",
          "AcceptorImpl",
          "UPnP",
          "",
          "Directed Querier",
          "QueryUnicaster",
          "Connection Management",
          "ConnectionManagerImpl",
          "Content Management",
          "ContentManager",
          "Mojito DHT",
          "DHTManagerImpl",
          "Peer Locator",
          "HostCatcher",
          "Static Messages",
          "StaticMessages",
          "Message Routing",
          "StandardMessageRouter",
          "Core Glue",
          "LimeCoreGlue",
          "RUDP Message Routing",
          "LimeRUDPMessageHandler",
          "Peer Listener",
          "Pinger",
          "HTTP Request Listening",
          "HTTPAcceptor",
          "Magnet Processor",
          "LocalHTTPAcceptor",
          "Connection Dispatching",
          "",
          "OOB Throughput Measurer",
          "OutOfBandThroughputMeasurer",
          "Stale Connection Management",
          "ConnectionWatchdog",
          "Spam Management",
          "RatingTable",
          "Download Upgrade Task",
          "",
          "LimeWire Store Integration",
          "LWSIntegrationServicesImpl",
          "Local Socket Listener",
          "LocalAcceptor",
          "Various Core Services",
          "",
          "QRP Updater",
          "QRPUpdater",
          "Gnutella Connections",
          "",
          "Firewall Manager",
          "FirewallServiceImpl",
          "DAAP",
          "",
          "Metadata Loader",
          "",
          "What's New Manager",
          "",
          "P2P Network Keyword Library",
          "",
          "Uptime Statistics",
          "UptimeStatTimer",
          "PushEndpointCacheImpl WeakHashMap Cleaner",
          "ScheduledService",
          "OnDemandUnicaster.Expirer",
          "ScheduledService",
          "OnDemandUnicaster.QueriedHostsExpirer",
          "ScheduledService",
          "ForMeReplyHandler.Clear Push Requests",
          "ScheduledService",
          "DiskContrller.CacheCleaner",
          "ScheduledService",
          "urncache persister",
          "ScheduledService",
          "TorrentManager",
          "LazyTorrentManager",
          "Settings Saver",
          "SettingsSaverService",
          "URNBlacklistManager",
          "URNBlacklistManagerImpl"
        };

    List<String> missing = new ArrayList<String>();

    boolean found;
    for (int i = 0; i < names.length; i += 2) {
      found = false;
      for (Iterator<Service> iterator = registry.services.iterator(); iterator.hasNext(); ) {
        Service service = iterator.next();
        if (service.getServiceName().equals(names[i])
            && service.getClass().getSimpleName().equals(names[i + 1])) {
          found = true;
          iterator.remove();
          break;
        }
      }
      if (!found) missing.add("[" + names[i] + "/" + names[i + 1] + "]");
    }

    if (!missing.isEmpty() || !registry.services.isEmpty()) {
      fail("couldn't find: " + missing + ", and had extra: " + toNames(registry.services));
    }
  }
 @Override
 protected void setUp() throws Exception {
   setUp(LimeTestUtils.createInjector());
 }