@Test
public void testThreeBeforeAndAfter() throws Exception {

    Over func = new Over();
    DataBag inbag = BagFactory.getInstance().newDefaultBag();
    for (int i = 0; i < 10; i++) {
        Tuple t = TupleFactory.getInstance().newTuple(1);
        t.set(0, 1);
        inbag.add(t);
    }
    Tuple t = TupleFactory.getInstance().newTuple(4);
    t.set(0, inbag);
    t.set(1, "sum(int)");
    t.set(2, 3);
    t.set(3, 3);
    DataBag outbag = func.exec(t);
    assertEquals(10, outbag.size());
    int sum = 1;
    for (Tuple to : outbag) {
        assertEquals(1, to.size());
        switch (sum++) {
            case 1:
            case 10:
                assertEquals(new Long(4), to.get(0));
                break;
            case 2:
            case 9:
                assertEquals(new Long(5), to.get(0));
                break;
            case 3:
            case 8:
                assertEquals(new Long(6), to.get(0));
                break;
            case 4:
            case 5:
            case 6:
            case 7:
                assertEquals(new Long(7), to.get(0));
                break;
            default:
                // Huh?
                throw new RuntimeException("We shouldn't be here, sum is "
                        + sum);
        }
    }
}