@@ -0,0 +1,1788 @@
+package com.coroptis.jblinktree;%0A%0Aimport java.util.Random;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.junit.Test;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A/**%0A * test verify that add and remove operations works in thread environment.%0A * %0A * @author jajir%0A * %0A */%0Apublic class TreeDeleteConcurrencyTest extends TestCase %7B%0A%0A    private final Logger logger = LoggerFactory%0A%09    .getLogger(TreeDeleteConcurrencyTest.class);%0A%0A    private Tree tree;%0A%0A    private Random random;%0A%0A    @Test%0A    public void testForThreadClash() throws Exception %7B%0A%09final int cycleCount = 10;%0A%09final int threadCount = 10;%0A%09final CountDownLatch doneLatch = new CountDownLatch(cycleCount%0A%09%09* threadCount);%0A%09final CountDownLatch startLatch = new CountDownLatch(1);%0A%0A%09for (int i = 0; i %3C threadCount; ++i) %7B%0A%09    Runnable runner = new Executer(new Worker() %7B%0A%0A%09%09@Override%0A%09%09public void doWork() %7B%0A%09%09    doWorkNow();%0A%09%09%7D%0A%09    %7D, startLatch, doneLatch, cycleCount);%0A%09    new Thread(runner, %22TestThread%22 + i).start();%0A%09%7D%0A%0A%09startLatch.countDown();%0A%09doneLatch.await(10, TimeUnit.SECONDS);%0A%09assertEquals(%22Some thread didn't finished work%22, 0,%0A%09%09doneLatch.getCount());%0A%09tree.verify();%0A%09logger.debug(%22I'm done!%22);%0A    %7D%0A%0A    @Override%0A    protected void setUp() throws Exception %7B%0A%09super.setUp();%0A%09NodeStore nodeStore = new NodeStoreImpl();%0A%09tree = new Tree(2, nodeStore);%0A%09random = new Random();%0A    %7D%0A%0A    @Override%0A    protected void tearDown() throws Exception %7B%0A%09tree = null;%0A%09super.tearDown();%0A    %7D%0A%0A    void doWorkNow() %7B%0A%09Integer integer = random.nextInt(100) + 1;%0A%09logger.debug(%22inserting :%22 + integer);%0A%09if (integer %25 2 == 0) %7B%0A%09    tree.insert(integer, integer);%0A%09%7D else %7B%0A%09    tree.remove(integer);%0A%09%7D%0A    %7D%0A%0A%7D%0A

test for inserting and deleting data in concurency environment