Package com.google.caliper.runner.ServerSocketService

Examples of com.google.caliper.runner.ServerSocketService.OpenedSocket


            new StreamReader(new InputStreamReader(process.getInputStream(), processCharset))));
    worker.socketFuture().addListener(
        new Runnable() {
          @Override public void run() {
            try {
              OpenedSocket openedSocket = worker.socketFuture().get();
              logger.fine("successfully opened the pipe from the worker");
              socketWriter = openedSocket.writer();
              runningReadStreams.addAndGet(1);
              openStreams.addAndGet(1);
              streamExecutor.submit(threadRenaming("worker-socket",
                  new StreamReader(openedSocket.reader())));
            } catch (ExecutionException e) {
              notifyFailed(e.getCause());
            } catch (InterruptedException e) {
              throw new AssertionError("impossible, future is already done.");
            }
View Full Code Here


  @Test public void getConnectionId_requestComesInFirst() throws Exception {
    UUID id = UUID.randomUUID();
    ListenableFuture<OpenedSocket> pendingServerConnection = service.getConnection(id);
    assertFalse(pendingServerConnection.isDone());
    OpenedSocket clientSocket = openConnectionAndIdentify(id);
    // Assert that the ends are hooked up to each other
    assertEndsConnected(clientSocket, pendingServerConnection.get());
  }
View Full Code Here

    assertEndsConnected(clientSocket, pendingServerConnection.get());
  }

  @Test public void getConnectionIdTwice_acceptComesFirst() throws Exception {
    UUID id = UUID.randomUUID();
    OpenedSocket clientSocket = openConnectionAndIdentify(id);

    ListenableFuture<OpenedSocket> pendingServerConnection = service.getConnection(id);
    // wait for the service to fully initialize the connection
    OpenedSocket serverSocket = pendingServerConnection.get();
    assertEndsConnected(clientSocket, serverSocket);
    try {
      // the second request is an error
      service.getConnection(id).get();
      fail();
View Full Code Here

  /**
   * Opens a connection to the service and identifies itself using the id.
   */
  private OpenedSocket openConnectionAndIdentify(UUID id) throws IOException {
    OpenedSocket clientSocket = openClientConnection();
    Writer writer = clientSocket.writer();
    writer.write(gson.toJson(new StartupAnnounceMessage(id)));
    writer.write('\n');
    writer.flush();
    return clientSocket;
  }
View Full Code Here

TOP

Related Classes of com.google.caliper.runner.ServerSocketService.OpenedSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.