package com.neverwinterdp.demandspike;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.neverwinterdp.server.shell.Shell;
/**
 * @author Tuan Nguyen
 * @email  tuan08@gmail.com
 */
public class DemandSpikeServiceUnitTest {
  static DemandSpikeClusterBuilder clusterBuilder ;
  static protected Shell shell ;
  static String TOPIC = DemandSpikeClusterBuilder.TOPIC ;
    
  @BeforeClass
  static public void setup() throws Exception {
    clusterBuilder = new DemandSpikeClusterBuilder() ;
    clusterBuilder.start() ;
    shell = clusterBuilder.shell ;
  }

  @AfterClass
  static public void teardown() throws Exception {
    clusterBuilder.destroy() ; 
  }
 
  @Test
  public void testSparkngin() throws Exception {
    clusterBuilder.install() ; 
    shell.execute(
      "demandspike submit " + 
      "  --driver sparkngin --broker-connect 127.0.0.1:8181 --topic " + TOPIC +
      "  --member-role demandspike --max-duration 30000 --max-num-of-message 100000" 
    );
    Thread.sleep(30000);
    shell.execute(
      "server metric --type timer --filter * " 
    );
    clusterBuilder.uninstall();
  }
  
  @Test
  public void testKafka() throws Exception {
    clusterBuilder.install() ; 
    shell.execute(
      "demandspike submit " + 
      "  --driver kafka --broker-connect 127.0.0.1:9092 --topic " + TOPIC +
      "  --member-role demandspike --max-duration 30000 --max-num-of-message 100000" 
    );
    Thread.sleep(30000);
    shell.execute(
      "server metric --type timer --filter * " 
    );
    clusterBuilder.uninstall();
  }
}
@@ -422,18 +422,16 @@
 IC ;%0D%0A  
-  
 %0D%0A  @Bef

clean code