Package org.jgroups.util

Examples of org.jgroups.util.Digest


    void beforeMethod() {
        Map<Address, Digest.Entry> map=new HashMap<Address, Digest.Entry>();
        map.put(a1, new Digest.Entry(4, 500, 501));
        map.put(a2, new Digest.Entry(25, 26, 26));
        map.put(a3, new Digest.Entry(20, 25, 33));
        d=new Digest(map);
        md=new MutableDigest(map);
    }
View Full Code Here


        md=new MutableDigest(map);
    }


    public void testSize() {
        d2=new Digest(3);
        Assert.assertEquals(0, d2.size());
    }
View Full Code Here

    public void testDifference(){
    Map<Address, Digest.Entry> map=new HashMap<Address, Digest.Entry>();
      map.put(a1, new Digest.Entry(4, 500, 501));
      map.put(a2, new Digest.Entry(25, 26, 26));
      map.put(a3, new Digest.Entry(20, 25, 33));
      Digest digest =new Digest(map);
      
      Map<Address, Digest.Entry> map2=new HashMap<Address, Digest.Entry>();      
      map2.put(a1, new Digest.Entry(4, 500, 501));
      map2.put(a2, new Digest.Entry(25, 26, 26));
      map2.put(a3, new Digest.Entry(20, 37, 33));
      Digest digest2 =new Digest(map2);

        Assert.assertNotSame(digest, digest2);
     
      Digest diff = digest2.difference(digest);
      System.out.println(diff);
        assert diff.contains(a3);
        Assert.assertEquals(1, diff.size());
     
     
      Map<Address, Digest.Entry> map3=new HashMap<Address, Digest.Entry>();
      map3.put(a1, new Digest.Entry(4, 500, 501));
      map3.put(a2, new Digest.Entry(25, 26, 26));
      map3.put(a3, new Digest.Entry(20, 37, 33));
      map3.put(Util.createRandomAddress(), new Digest.Entry(1, 2, 3));
      Digest digest3 =new Digest(map3);
     
      diff = digest3.difference(digest);
      System.out.println(diff);
        Assert.assertEquals(2, diff.size());
     
      diff = digest3.difference(digest2);
      System.out.println(diff);
        Assert.assertEquals(1, diff.size());
     
      Digest diff2 = digest2.difference(digest3);
      System.out.println(diff2);
        Assert.assertEquals(1, diff2.size());
        Assert.assertEquals(diff, diff2);
    }
View Full Code Here

    public void testIsGreaterThanOrEqual() {
        Map<Address, Digest.Entry> map=new HashMap<Address, Digest.Entry>();
        map.put(a1, new Digest.Entry(4, 500, 501));
        map.put(a2, new Digest.Entry(25, 26, 26));
        map.put(a3, new Digest.Entry(20, 25, 33));
        Digest my=new Digest(map);

        System.out.println("\nd: " + d + "\nmy: " + my);
        assert my.isGreaterThanOrEqual(d);

        map.remove(a3);
        map.put(a3, new Digest.Entry(20, 26, 33));
        my=new Digest(map);
        System.out.println("\nd: " + d + "\nmy: " + my);
        assert my.isGreaterThanOrEqual(d);

        map.remove(a3);
        map.put(a3, new Digest.Entry(20, 22, 32));
        my=new Digest(map);
        System.out.println("\nd: " + d + "\nmy: " + my);
        assert !(my.isGreaterThanOrEqual(d));
    }
View Full Code Here

        assert !(d.equals(md));
    }


    public void testMutability() {
        Digest md2=md;
        Assert.assertEquals(md, md2);
        md.incrementHighestDeliveredSeqno(a2);
        Assert.assertEquals(md, md2);
    }
View Full Code Here

    }



    public void testImmutability2() {
        Digest tmp=d.copy();
        Assert.assertEquals(d, tmp);
    }
View Full Code Here

        Assert.assertEquals(d, tmp);
    }


    public void testImmutability3() {
        Digest tmp=new Digest(d);
        Assert.assertEquals(tmp, d);
    }
View Full Code Here

        Assert.assertEquals(tmp, d);
    }


    public void testImmutability4() {
        Digest copy=md.copy();
        Assert.assertEquals(copy, md);
        md.incrementHighestDeliveredSeqno(a1);
        assert !(copy.equals(md));
    }
View Full Code Here

        Assert.assertEquals(4, md.size());
    }


    public void testAddDigest() {
        Digest tmp=md.copy();
        md.add(tmp);
        Assert.assertEquals(3, md.size());
    }
View Full Code Here

    }



    public static void testConstructor2() {
        Digest dd=new Digest(3);
        Assert.assertEquals(0, dd.size());
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.Digest

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.