/** @return the configuration node used to create this object */
  public HierarchicalConfiguration getConfig() {
    final HierarchicalConfiguration config = new HierarchicalConfiguration();
    Node node = new Node("grSimNetwork");
    node.addAttribute(new Node("id", key));
    config.setRoot(node);
    config.addProperty("ip", ip);
    config.addProperty("port", port);
    config.addProperty("teamYellow", teamYellow);

    return config;
  }
Esempio n. 2
0
  @BeforeClass(groups = {"functional", "real_server"})
  public void startServer() {
    // set up a document root
    documentRoot = Files.createTempDir();

    // create listeners configuration
    config = new HierarchicalConfiguration();
    config.addProperty("listeners.listener.port", Integer.toString(port));
    config.addProperty("listeners.listener.filesRoot", documentRoot.getAbsolutePath());
    // the values below could, in fact, be missing; there are defaults in
    // RequestListenerConfiguration
    config.addProperty("jerry.listeners.listener.http.connection_timeout", "3000");
    config.addProperty("jerry.listeners.listener.http.socket_timeout", "3000");
    config.addProperty("jerry.listeners.listener.http.socket_buffer_size", "16384");
    config.addProperty("jerry.listeners.listener.workers.core_pool_size", "30");
    config.addProperty("jerry.listeners.listener.workers.max_pool_size", "500");
    config.addProperty("jerry.listeners.listener.workers.keep_alive_time", "5");
    config.addProperty("jerry.listeners.listener.workers.queue_size", "80");

    // create webserver
    server = new JerryServer();

    // Now try to bind the listener on an open port
    for (int i = 0; i < 10; i++) {
      try {
        // increment port number
        server.loadConfiguration(config);
        server.start();
        break;
      } catch (BindException e) {
        System.out.println("Couldn't start server on " + port + ". Trying " + port + 1);
        // increment port number
        config.setProperty("listeners.listener.port", Integer.toString(++port));
        continue;
      } catch (IOException e) {
        Assert.fail("Error loading configuration: ", e);
      }
    }
  }