Esempio n. 1
0
  /**
   * Test compatability of publish interface between version 4.1.0 and current verison.
   *
   * <p>1) 4.1.0 client could talk with current server. 2) current client could talk with 4.1.0
   * server, but no message seq id would be returned
   */
  @Test(timeout = 60000)
  public void testPublishCompat410() throws Exception {
    ByteString topic = ByteString.copyFromUtf8("TestPublishCompat410");
    ByteString data = ByteString.copyFromUtf8("testdata");

    // start bookkeeper 410
    BookKeeperCluster410 bkc410 = new BookKeeperCluster410(3);
    bkc410.start();

    int port = PortManager.nextFreePort();
    int sslPort = PortManager.nextFreePort();

    // start 410 server
    Server410 s410 = new Server410(zkUtil.getZooKeeperConnectString(), port, sslPort);
    s410.start();

    ClientCurrent ccur = new ClientCurrent("localhost:" + port + ":" + sslPort);
    Client410 c410 = new Client410("localhost:" + port + ":" + sslPort);

    // client c410 could publish message to 410 server
    assertNull(c410.publish(topic, data));
    // client ccur could publish message to 410 server
    // but no message seq id would be returned
    assertNull(ccur.publish(topic, data));

    // stop 410 server
    s410.stop();

    // start 420 server
    Server420 s420 = new Server420(zkUtil.getZooKeeperConnectString(), port, sslPort);
    s420.start();

    // client c410 could publish message to 410 server
    // but no message seq id would be returned
    assertNull(c410.publish(topic, data));
    // client ccur could publish message to current server
    assertNotNull(ccur.publish(topic, data));

    ccur.close();
    c410.close();

    // stop 420 server
    s420.stop();
    bkc410.stop();
  }