Package com.googlecode.protobuf.socketrpc.RpcConnectionFactory

Examples of com.googlecode.protobuf.socketrpc.RpcConnectionFactory.Connection


  }

  public void testClientFactory() throws IOException {
    PersistentRpcConnectionFactory persistentFactory =
        PersistentRpcConnectionFactory.createInstance(factory);
    Connection persistent = doTestFactoryTest(persistentFactory);

    // Check that connection is closed only when factory is closed
    assertFalse(persistent.isClosed());
    assertFalse(connection.isClosed());
    persistentFactory.close();
    assertTrue(persistent.isClosed());
    assertTrue(connection.isClosed());
  }
View Full Code Here


  }

  public void testServerFactory() throws IOException {
    ServerRpcConnectionFactory persistentFactory =
        PersistentRpcConnectionFactory.createServerInstance(factory);
    Connection persistent = doTestFactoryTest(persistentFactory);

    // Check that connection is closed only when factory is closed
    assertFalse(persistent.isClosed());
    assertFalse(connection.isClosed());
    assertFalse(factory.closed);
    persistentFactory.close();
    assertTrue(persistent.isClosed());
    assertTrue(connection.isClosed());
    assertTrue(factory.closed);
  }
View Full Code Here

  }

  public Connection doTestFactoryTest(RpcConnectionFactory persistentFactory)
      throws IOException {
    // Send and receive first
    Connection persistent = persistentFactory.createConnection();
    persistent.sendProtoMessage(MESSAGE2);
    Builder builder = Request.newBuilder();
    persistent.receiveProtoMessage(builder);
    assertEquals(MESSAGE1, builder.build());
    persistent.close();

    // Receive and send second
    persistent = persistentFactory.createConnection();
    builder = Request.newBuilder();
    persistent.receiveProtoMessage(builder);
    assertEquals(MESSAGE2, builder.build());
    persistent.sendProtoMessage(MESSAGE1);
    persistent.close();

    // Send and receive third
    persistent = persistentFactory.createConnection();
    persistent.sendProtoMessage(MESSAGE2);
    builder = Request.newBuilder();
    persistent.receiveProtoMessage(builder);
    assertEquals(MESSAGE1, builder.build());
    persistent.close();

    // Get 3 messages from output
    ByteArrayInputStream is = new ByteArrayInputStream(
        socket.getOutputBytes());
    assertEquals(MESSAGE2, Request.parseDelimitedFrom(is));
View Full Code Here

    new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          while (runServer.get()) {
            Connection connection = persistentFactory.createConnection();
            count.incrementAndGet();
            receiveRequest(connection);
          }
        } catch (IOException e) {
          failed.set(true);
View Full Code Here

TOP

Related Classes of com.googlecode.protobuf.socketrpc.RpcConnectionFactory.Connection

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.