@Test public void testDistinct()
{

    List<Binding> undistinct = new ArrayList<>();
    undistinct.add(b12);
    undistinct.add(b19);
    undistinct.add(b02);
    undistinct.add(b12);
    undistinct.add(b19);
    undistinct.add(b12);
    undistinct.add(b02);
    undistinct.add(x10);
    
    List<Binding> control = Iter.toList(Iter.distinct(undistinct.iterator()));
    List<Binding> distinct = new ArrayList<>();
    
    
    DistinctDataBag<Binding> db = new DistinctDataBag<>(
            new ThresholdPolicyCount<Binding>(2),
            SerializationFactoryFinder.bindingSerializationFactory(),
            new BindingComparator(new ArrayList<SortCondition>())); 
    try
    {
        db.addAll(undistinct);
        
        Iterator<Binding> iter = db.iterator(); 
        while (iter.hasNext())
        {
            distinct.add(iter.next());
        }
        Iter.close(iter);
    }
    finally
    {
        db.close();
    }
    
    assertEquals(control.size(), distinct.size());
    assertTrue(ResultSetCompare.equalsByTest(control, distinct, NodeUtils.sameNode));
}