@@ -0,0 +1,2508 @@
+package org.mapdb;%0A%0Aimport junit.framework.TestCase;%0A%0Apublic class AtomicStringTest extends TestCase %7B%0A%0A    DB db;%0A    Atomic.String ai;%0A%0A%0A    @Override%0A    protected void setUp() throws Exception %7B%0A        db = DBMaker.memoryDB().transactionDisable().make();%0A        ai = db.atomicStringCreate(%22test%22, %22test%22);%0A    %7D%0A%0A    @Override%0A    protected void tearDown() throws Exception %7B%0A        db.close();%0A    %7D%0A%0A%0A    /*%0A     * constructor initializes to given value%0A     */%0A    public void testConstructor() %7B%0A        assertEquals(%22test%22, ai.get());%0A    %7D%0A%0A    /*%0A     * default constructed initializes to empty string%0A     */%0A    public void testConstructor2() %7B%0A        Atomic.String ai = db.atomicString(%22test2%22);%0A        assertEquals(%22%22, ai.get());%0A    %7D%0A%0A    /*%0A     * get returns the last value set%0A     */%0A    public void testGetSet() %7B%0A        assertEquals(%22test%22, ai.get());%0A        ai.set(%22test2%22);%0A        assertEquals(%22test2%22, ai.get());%0A        ai.set(%22test3%22);%0A        assertEquals(%22test3%22, ai.get());%0A%0A    %7D%0A%0A    /*%0A     * compareAndSet succeeds in changing value if equal to expected else fails%0A     */%0A    public void testCompareAndSet()%7B%0A        assertTrue(ai.compareAndSet(%22test%22, %22test2%22));%0A        assertTrue(ai.compareAndSet(%22test2%22, %22test3%22));%0A        assertEquals(%22test3%22, ai.get());%0A        assertFalse(ai.compareAndSet(%22test2%22, %22test4%22));%0A        assertNotSame(%22test5%22, ai.get());%0A        assertTrue(ai.compareAndSet(%22test3%22, %22test5%22));%0A        assertEquals(%22test5%22, ai.get());%0A    %7D%0A%0A    /*%0A     * compareAndSet in one thread enables another waiting for value%0A     * to succeed%0A     */%0A    public void testCompareAndSetInMultipleThreads() throws InterruptedException %7B%0A        Thread t = new Thread(new Runnable() %7B%0A            public void run() %7B%0A                while(!ai.compareAndSet(%22test2%22, %22test3%22)) Thread.yield();%0A            %7D%7D);%0A%0A        t.start();%0A        assertTrue(ai.compareAndSet(%22test%22, %22test2%22));%0A        t.join(0);%0A        assertFalse(t.isAlive());%0A        assertEquals(ai.get(), %22test3%22);%0A    %7D%0A%0A    /*%0A     * getAndSet returns previous value and sets to given value%0A     */%0A    public void testGetAndSet()%7B%0A        assertEquals(%22test%22, ai.getAndSet(%22test2%22));%0A        assertEquals(%22test2%22, ai.getAndSet(%22test3%22));%0A        assertEquals(%22test3%22, ai.getAndSet(%22test4%22));%0A    %7D%0A%0A    /*%0A     * toString returns current value.%0A     */%0A    public void testToString() %7B%0A        assertEquals(ai.toString(), ai.get());%0A        assertEquals(ai.toString(), %22test%22);%0A    %7D%0A%0A%7D%0A

Add unit tests for Atomic.String class