Ejemplo n.º 1
0
  @BeforeMethod
  protected void setUp() throws Exception {
    a = Util.createRandomAddress("A");
    b = Util.createRandomAddress("B");
    c = Util.createRandomAddress("C");
    v1 = View.create(a, 1, a, b);
    v2 = View.create(a, 2, a, b, c);

    nak = new NAKACK2();
    d1 = new Digest(v1.getMembersRaw(), new long[] {11, 11, 30, 35});
    d2 = new Digest(v2.getMembersRaw(), new long[] {10, 10, 30, 30, 50, 50});

    TP transport =
        new TP() {
          public boolean supportsMulticasting() {
            return false;
          }

          public void sendMulticast(byte[] data, int offset, int length) throws Exception {}

          public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length)
              throws Exception {}

          public String getInfo() {
            return null;
          }

          public Object down(Event evt) {
            return null;
          }

          protected PhysicalAddress getPhysicalAddress() {
            return null;
          }

          public TimeScheduler getTimer() {
            return new DefaultTimeScheduler(1);
          }
        };
    transport.setId(TP_ID);
    nak.setDownProtocol(transport);
    nak.start();
  }
  @BeforeMethod
  protected void setup() throws Exception {
    receiver = new MockProtocol();
    nak = (NAKACK2) new NAKACK2().setValue("use_mcast_xmit", false);
    transport = new MockTransport();
    ProtocolStack stack = new ProtocolStack();
    stack.addProtocols(transport, nak, receiver);
    stack.init();

    nak.down(new Event(Event.BECOME_SERVER));
    nak.down(new Event(Event.SET_LOCAL_ADDRESS, A));
    Digest digest = new Digest(view.getMembersRaw(), new long[] {0, 0, 0, 0});
    nak.down(new Event(Event.SET_DIGEST, digest));
  }