Examples of XorAccumulator


Examples of com.moesol.geoserver.sync.core.XorAccumulator

import junit.framework.TestCase;

public class XorAccumulatorTest extends TestCase {

  public void testUpdate() {
    XorAccumulator a = new XorAccumulator();
    byte[] v = new byte[20];
    v[0] = 1;
    a.update(v);
    assertEquals("0100000000000000000000000000000000000000", a.toString());
   
    v[19] = 1;
    a.update(v);
    assertEquals("0000000000000000000000000000000000000001", a.toString());
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

    a.update(v);
    assertEquals("0000000000000000000000000000000000000001", a.toString());
  }

  public void testToString() {
    XorAccumulator a = new XorAccumulator();
    assertEquals(40, a.toString().length());
    assertEquals("0000000000000000000000000000000000000000", a.toString());
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

    smallSet.add("A");
    smallSet.add("B");
    smallSet.add("C");
    smallSet.add("D");
   
    XorAccumulator s1 = computeSha1OfSet(smallSet);   
    Collections.shuffle(smallSet);
    XorAccumulator s2 = computeSha1OfSet(smallSet);
    assertEquals(s1, s2);
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

    assertEquals(s1, s2);
  }
 
  public void testReorderLarge() {
    fillWithRandom(largeSet, 10000);
    XorAccumulator s1 = computeSha1OfSet(largeSet);   
    Collections.shuffle(largeSet);
    XorAccumulator s2 = computeSha1OfSet(largeSet);
    assertEquals(s1, s2);
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

    assertEquals(s1, s2);
  }

  public void testReorderVeryLarge() {
    fillWithRandom(veryLargeSet, 100000);
    XorAccumulator s1 = computeSha1OfSet(veryLargeSet);   
    Collections.shuffle(veryLargeSet);
    XorAccumulator s2 = computeSha1OfSet(veryLargeSet);
    assertEquals(s1, s2);
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

    assertEquals(s1, s2);
  }
 
  public void testReorderVeryLargeWithOneChange() {
    fillWithRandom(veryLargeSet, 100000);
    XorAccumulator s1 = computeSha1OfSet(veryLargeSet);   
    Collections.shuffle(veryLargeSet);
    perturbZeroElement(veryLargeSet);
    XorAccumulator s2 = computeSha1OfSet(veryLargeSet);
    assertFalse(s1.equals(s2));
  }
View Full Code Here

Examples of com.moesol.geoserver.sync.core.XorAccumulator

      set.add(id.toString());
    }
  }

  private XorAccumulator computeSha1OfSet(List<String> smallSet) {
    XorAccumulator result = new XorAccumulator();
    long st = System.currentTimeMillis();
    for (String s : smallSet) {
      byte[] elSha1 = m_sha1.digest(s.getBytes());
      m_sha1.reset();
      result.update(elSha1);
    }
    if (DEBUG) {
      System.out.println(result);
    }
    long e = System.currentTimeMillis();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.