WebCookbook { public static void main(String[] args) { String home = System.getenv().get("HOME"); String filesPath = MainArgs.getOptArg("files", "-f", args, (null==home?"~":home)+"/www"); String host = MainArgs.getOptArg("host", "-h", args, null); int port = Integer.valueOf(MainArgs.getOptArg("port", "-p", args, "8080")); GraphManager gm = new GraphManager(); populateGraph(gm, host, port, filesPath); StageScheduler.defaultScheduler(gm).startup(); }  static void main(String[] args);  }
@Test public void makeCallsTest() { int fieldPort = (int) (3000 + (System.nanoTime()%12000)); GraphManager.showThreadIdOnTelemetry = true; ClientCoordinator.registerDomain("127.0.0.1"); WebCookbook.main(new String[] {"-h", "127.0.0.1", "-p", String.valueOf(fieldPort)}); GraphManager gm = new GraphManager(); int tracks = 1; TLSCertificates tlsCertificates = null; int connectionsInBits = 3; int maxPartialResponses = 1; int clientRequestCount=7; int clientRequestSize=2000; Pipe<ClientHTTPRequestSchema>[] clientRequests = Pipe.buildPipes( tracks, ClientHTTPRequestSchema.instance.newPipeConfig(20, 1<<9)); Pipe<NetResponseSchema>[] clientResponses = Pipe.buildPipes( tracks, NetResponseSchema.instance.newPipeConfig(20, 1<<20)); NetGraphBuilder.buildHTTPClientGraph(gm, clientResponses, clientRequests, maxPartialResponses, connectionsInBits, clientRequestCount, clientRequestSize, tlsCertificates); clientRequests[0].initBuffers(); ClientHTTPRequestSchema.publishGET(clientRequests[0], 1, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/person/add?id=333&name=nathan", null); ClientHTTPRequestSchema.publishGET(clientRequests[0], 1, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/person/add?id=444&name=scott", null); ClientHTTPRequestSchema.publishGET(clientRequests[0], 1, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/person/list", null); ClientHTTPRequestSchema.publishGET(clientRequests[0], 2, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/resource/reqPerSec.png", null); ClientHTTPRequestSchema.publishGET(clientRequests[0], 3, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/proxy/person/list", null); ClientHTTPRequestSchema.publishGET(clientRequests[0], 3, fieldPort, ClientCoordinator.registerDomain("127.0.0.1"), -1L, 0, "/proxy/resource/reqPerSec.png", null); int expectedResponseCount = 6; Pipe.publishEOF(clientRequests[0]); StringBuilder results = new StringBuilder(); ConsoleJSONDumpStage.newInstance(gm, clientResponses[0], Appendables.join(results, System.out)); NonThreadScheduler scheduler = new NonThreadScheduler(gm); scheduler.startup(); int i = 200; while (--i>=0) { try { Thread.sleep(10); if (respCount(results)==expectedResponseCount) { break; } } catch (InterruptedException e) { e.printStackTrace(); } scheduler.run(); } scheduler.shutdown(); int c = respCount(results); assertEquals("Expeced response count",expectedResponseCount,c); }