/**
   * Called before the tests start.
   *
   * <p>Sets up the node and initializes connector and users that can be used throughout the tests.
   *
   * @throws Exception
   */
  @BeforeClass
  public static void startServer() throws Exception {

    // start node
    node = LocalNode.newNode();
    testAgent = MockAgentFactory.getAdam();
    testAgent.unlockPrivateKey(testPass); // agent must be unlocked in order to be stored
    node.storeAgent(testAgent);
    node.launch();

    ServiceAgent testService = ServiceAgent.createServiceAgent(testTemplateService, "a pass");
    testService.unlockPrivateKey("a pass");

    node.registerReceiver(testService);

    // start connector
    logStream = new ByteArrayOutputStream();

    connector = new WebConnector(true, HTTP_PORT, false, 1000);
    connector.setLogStream(new PrintStream(logStream));
    connector.start(node);
    Thread.sleep(1000); // wait a second for the connector to become ready
    testAgent = MockAgentFactory.getAdam();

    connector.updateServiceList();
    // avoid timing errors: wait for the repository manager to get all services before continuing
    try {
      System.out.println("waiting..");
      Thread.sleep(10000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
  @Before
  public void startServer() throws Exception {
    // start Node
    node = LocalNode.newNode();

    adam = MockAgentFactory.getAdam();
    adam.unlockPrivateKey(adamsPass);
    node.storeAgent(adam);

    node.launch();

    ServiceAgent testService = ServiceAgent.createServiceAgent(testServiceClass, "a pass");
    testService.unlockPrivateKey("a pass");

    node.registerReceiver(testService);

    // start connector
    logStream = new ByteArrayOutputStream();
    connector = new HttpConnector();
    connector.setSocketTimeout(10000);
    connector.setLogStream(new PrintStream(logStream));
    connector.start(node);
  }