package com.hubspot.singularity;

import java.lang.management.ManagementFactory;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.test.TestingServer;
import org.junit.After;
import org.junit.Before;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.hubspot.horizon.HttpClient;
import com.hubspot.mesos.client.MesosClient;
import com.hubspot.singularity.scheduler.SingularityTestModule;

public class SingularityCuratorTestBase {

  @Inject
  protected CuratorFramework cf;
  @Inject
  protected TestingServer ts;
  @Inject
  @Named(MesosClient.HTTP_CLIENT_NAME)
  private HttpClient httpClient;

  private SingularityTestModule singularityTestModule;

  @Before
  public final void curatorSetup() throws Exception {
    singularityTestModule = new SingularityTestModule();

    singularityTestModule.getInjector().injectMembers(this);
    singularityTestModule.start();
  }

  @After
  public final void curatorTeardown() throws Exception {

    singularityTestModule.stop();

    if (ts != null) {
      ts.close();
    }

    if (cf != null) {
      cf.close();
    }

    if (httpClient != null) {
      httpClient.close();
    }

    System.out.println(ManagementFactory.getThreadMXBean().getThreadCount());
  }

}

@@ -31,56 +31,8 @@
 y;%0A%0A
-import java.lang.management.ManagementFactory;%0A%0A
 impo
@@ -994,18 +994,18 @@
     if (
-ts
+cf
  != null
@@ -1014,18 +1014,18 @@
 %7B%0A      
-ts
+cf
 .close()
@@ -1033,34 +1033,34 @@
 %0A    %7D%0A%0A    if (
-cf
+ts
  != null) %7B%0A    
@@ -1053,34 +1053,34 @@
 = null) %7B%0A      
-cf
+ts
 .close();%0A    %7D%0A
@@ -1147,86 +1147,8 @@
  %7D%0A%0A
-    System.out.println(ManagementFactory.getThreadMXBean().getThreadCount());%0A
   %7D%0A

fix accidental println