<commit_before>package tgm.hit.rtn.dlock;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 *
 */
public class Test_DLockClient_lockWhile {
    Object[] testObjects;
    DLock lock;

    @Before
    public void prepare() {
        testObjects = new Object[]{"blub", 1};
        lock = new DLock(peerManager, dLockClient);
    }

    @Test
    public void testObjectsPassed() {
        lock.lockWhile(new Callback() {
            @Override
            public void run(Object... params) {
                Assert.assertArrayEquals(params, testObjects);
            }
        }, testObjects);
    }
}<commit_msg>implemented a class using the Callback interface<commit_after>package tgm.hit.rtn.dlock;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 *
 */
public class Test_DLockClient_lockWhile {
    Integer[] sumThis;
    int expectedResult;
    DLock lock;

    @Before
    public void prepare() {
        sumThis = new Integer[]{1, 1, 2};
        expectedResult=4;
        lock = new DLock();
    }

    @Test
    public void testObjectsPassed() {
        int myResult=0;
        try {
            Integer result=(Integer) lock.lockWhile(new Sum(), sumThis);
            myResult=result.intValue();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Assert.assertEquals(myResult,expectedResult);
    }

}
class Sum implements Callback<Integer,Integer>{

    @Override
    public Integer run(Integer... params) {
        if(params==null)return 0;
        if(params.length==0)return 0;
        int sum=0;
        for (int i = 0; i < params.length; i++) {
            sum+=params[i].intValue();
        }
        return sum;
    }
}
{'fraction_non_alphanumeric': 0.1182237600922722, 'fraction_numerical': 0.006343713956170703, 'mean_word_length': 2.2674199623352167, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4229524', 'n_tokens_mistral': 528, 'n_tokens_neox': 513, 'n_words': 120}