Exemplo n.º 1
0
  @Test
  public void testMakeBag() throws ExecException {
    Tuple t1 = TupleFac.newTuple(new String[] {"Foo", "Bar"});
    Tuple t2 = TupleFac.newTuple(new String[] {"Blue", "Green"});
    DefaultDataBag bag = makeBag(new Tuple[] {t1, t2});

    DefaultDataBag manualBag = new DefaultDataBag();
    manualBag.add(t1);
    manualBag.add(t2);

    assertTrue(compareBags(manualBag, bag));
  }
Exemplo n.º 2
0
  @Test
  public void testCompareBags() throws ExecException {
    // Test compareBags:
    DefaultDataBag bag1 = new DefaultDataBag();
    DefaultDataBag bag2 = new DefaultDataBag();

    // Test bag with one tuple of len 1:
    Tuple t1_len1 = tupleFac.newTuple(1);
    Tuple t2_len1 = tupleFac.newTuple(1);
    t1_len1.set(0, "foo");
    t2_len1.set(0, "foo");
    bag1.add(t1_len1);
    bag2.add(t2_len1);
    assertTrue(compareBags(bag1, bag2));
    t1_len1.set(0, "bar");
    assertFalse(compareBags(bag1, bag2));

    // Test bag with one tuple of len 2:
    bag1.clear();
    bag2.clear();
    Tuple t1_len2 = tupleFac.newTuple(2);
    Tuple t2_len2 = tupleFac.newTuple(2);
    t1_len2.set(0, "foo");
    t1_len2.set(1, "bar");
    t2_len2.set(0, "foo");
    t2_len2.set(1, "bar");
    bag1.add(t1_len2);
    bag2.add(t2_len2);
    assertTrue(compareBags(bag1, bag2));

    // Test unequal number of tuples in the two bags:
    Tuple t3_len2 = tupleFac.newTuple(2);
    t3_len2.set(0, "foo");
    t3_len2.set(1, "bar");
    bag1.add(t3_len2);
    assertFalse(compareBags(bag1, bag2));
  }
Exemplo n.º 3
0
 private DefaultDataBag makeBag(Tuple[] tuples) throws ExecException {
   DefaultDataBag bag = new DefaultDataBag();
   for (Tuple tuple : tuples) bag.add(tuple);
   return bag;
 }