lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r425538 [4/4] - in /lucene/java/trunk: ./ contrib/gdata-server/ contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ contrib/gdata-server/src/java/org/apache/lucene/gdata/...
Date Tue, 25 Jul 2006 22:23:06 GMT
Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,133 @@
+package org.apache.lucene.gdata.storage.lucenestorage;
+
+import org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.ConcurrencyException;
+
+import junit.framework.TestCase;
+
+public class TestSingelHostConcurrencyLock extends TestCase {
+    SingleHostConcurrentStorageLock lock;
+    boolean threadResult = false;
+    protected void setUp() throws Exception {
+        this.lock = (SingleHostConcurrentStorageLock)SingleHostConcurrentStorageLock.getConcurrentStorageLock();
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        threadResult = false;
+        this.lock.close();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.getConcurrentStorageLock()'
+     */
+    public void testGetConcurrentStorageLock() {
+        ConcurrentStorageLock lock = SingleHostConcurrentStorageLock.getConcurrentStorageLock();
+        assertEquals(lock,SingleHostConcurrentStorageLock.getConcurrentStorageLock() );
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.setLock(String)'
+     */
+    public void testSetLock() throws InterruptedException {
+        final String key = "someKey";
+        final String nextKey = "fooKey";
+        assertTrue(lock.setLock(key));
+        assertTrue(lock.isKeyLocked(key));
+        
+        try{
+            this.lock.setLock(key);
+            fail("thread has already locked the key");
+        }catch (Exception e) {
+            // TODO: handle exception
+        }
+        
+        try{
+            assertTrue(lock.setLock(nextKey));
+            fail("thread has already locked the key");
+        }catch (Exception e) {
+            // TODO: handle exception
+        }
+        
+        Thread t = new Thread(new Runnable(){
+            public void run(){
+                threadResult = lock.setLock(key);
+              
+                
+                
+            }
+        });
+        t.start();
+        t.join(300);
+        assertFalse(threadResult);
+        
+        t = new Thread(new Runnable(){
+            public void run(){
+                threadResult = lock.setLock(nextKey);
+              
+                
+                
+            }
+        });
+        t.start();
+        t.join(300);
+        assertTrue(threadResult);
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.releaseLock(String)'
+     */
+    public void testReleaseLock() throws InterruptedException {
+        final String key = "someKey";
+        final String nextKey = "fooKey";
+        assertTrue(lock.setLock(key));
+        assertTrue(lock.isKeyLocked(key));
+        assertTrue(lock.releaseLock(key));
+        assertTrue(this.lock.setLock(key));
+        try{
+            assertTrue(lock.setLock(nextKey));
+            fail("thread has already locked the key");
+        }catch (Exception e) {
+            // TODO: handle exception
+        }
+        
+        Thread t = new Thread(new Runnable(){
+            public void run(){
+                threadResult = lock.setLock(nextKey);
+            }
+        });
+        t.start();
+        t.join(300);
+        assertTrue(threadResult);
+        try{
+        this.lock.releaseLock(nextKey);
+           fail("current thread is not owner");
+        }catch (ConcurrencyException e) {
+            // TODO: handle exception
+        }
+
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.releaseThreadLocks()'
+     */
+    public void testReleaseThreadLocks() {
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.isKeyLocked(String)'
+     */
+    public void testIsKeyLocked() {
+
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.SingleHostConcurrentStorageLock.close()'
+     */
+    public void testClose() {
+
+    }
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,236 @@
+package org.apache.lucene.gdata.storage.lucenestorage;
+
+import java.io.IOException;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
+import org.apache.lucene.gdata.utils.ProvidedServiceStub;
+
+import com.google.gdata.data.DateTime;
+
+public class TestStorageBuffer extends TestCase {
+    private static final String FEEDID = "feed";
+    private static final String ENTRYID = "someID";
+    private StorageBuffer buffer;
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.buffer = new StorageBuffer(10);
+    }
+
+    protected void tearDown() throws Exception {
+        this.buffer.close();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.StorageBuffer(int)'
+     */
+    public void testStorageBuffer() {
+        assertEquals(StorageBuffer.DEFAULT_BUFFER_COUNT,new StorageBuffer(StorageBuffer.DEFAULT_BUFFER_COUNT-1).getBufferSize());
+        assertEquals(StorageBuffer.DEFAULT_BUFFER_COUNT,new StorageBuffer(StorageBuffer.DEFAULT_BUFFER_COUNT).getBufferSize());
+        assertEquals(StorageBuffer.DEFAULT_BUFFER_COUNT+1,new StorageBuffer(StorageBuffer.DEFAULT_BUFFER_COUNT+1).getBufferSize());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.addEntry(StorageEntryWrapper)'
+     */
+    public void testAddEntry() throws IOException {
+        
+        ServerBaseEntry e = createServerBaseEntry(ENTRYID,FEEDID);
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        assertEquals(1,this.buffer.getSortedEntries(FEEDID).size());
+        this.buffer.addEntry(wrapper);
+        assertEquals(1,this.buffer.getSortedEntries(FEEDID).size());
+        
+        e.setId("someotherID");
+        e.setFeedId(FEEDID);
+        e.setServiceConfig(new ProvidedServiceStub());
+        wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        assertEquals(2,this.buffer.getSortedEntries(FEEDID).size());
+        e.setId("someotherID");
+        e.setFeedId("someOtherFeed");
+        e.setServiceConfig(new ProvidedServiceStub());
+        wrapper = new StorageEntryWrapper(e,StorageOperation.UPDATE);
+        this.buffer.addEntry(wrapper);
+        wrapper = new StorageEntryWrapper(e,StorageOperation.DELETE);
+        e.setId("deleted and ingnored");
+        e.setFeedId("someOtherFeed");
+        e.setServiceConfig(new ProvidedServiceStub());
+        this.buffer.addEntry(wrapper);
+        assertEquals(2,this.buffer.getSortedEntries(FEEDID).size());
+        assertEquals(1,this.buffer.getSortedEntries("someOtherFeed").size());
+        assertEquals("Contains 2 different IDs",2,this.buffer.getExculdList().length);
+        
+    }
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.addDeleted(String, String)'
+     */
+    public void testAddDeleted() throws IOException {
+        
+        this.buffer.addDeleted(ENTRYID,FEEDID);
+        assertNull(this.buffer.getSortedEntries(FEEDID));
+        assertEquals(1,this.buffer.getExculdList().length);
+        assertEquals(ENTRYID,this.buffer.getExculdList()[0]);
+        
+        this.buffer.addDeleted(ENTRYID,FEEDID);
+        assertNull(this.buffer.getSortedEntries(FEEDID));
+        assertEquals(1,this.buffer.getExculdList().length);
+        assertEquals(ENTRYID,this.buffer.getExculdList()[0]);
+        
+        
+    }
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.getFeedLastModified(String)'
+     */
+    public void testGetFeedLastModified() throws IOException, InterruptedException {
+        ServerBaseEntry e = createServerBaseEntry(ENTRYID,FEEDID);
+        e.setUpdated(new DateTime(System.currentTimeMillis()-200,0));
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        assertEquals(new Long(e.getUpdated().getValue()),this.buffer.getFeedLastModified(FEEDID));
+        //test update
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-180,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.UPDATE);
+        this.buffer.addEntry(wrapper);
+        Long firstAddTimestamp = new Long(e.getUpdated().getValue());
+        assertEquals(firstAddTimestamp,this.buffer.getFeedLastModified(FEEDID));
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-160,0));
+        assertFalse("updated after add" ,e.getUpdated().equals(this.buffer.getFeedLastModified(FEEDID)));
+        
+        //insert for other feed
+        String otherID = "someOtherFeedID";
+        e.setFeedId(otherID);
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-140,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        assertEquals(new Long(e.getUpdated().getValue()),this.buffer.getFeedLastModified(otherID));
+        assertEquals(firstAddTimestamp,this.buffer.getFeedLastModified(FEEDID));
+        
+        assertTrue(firstAddTimestamp.equals(this.buffer.getFeedLastModified(FEEDID)));
+        this.buffer.addDeleted(e.getId(),FEEDID);
+        // time will be set inside the buffer
+        assertTrue(firstAddTimestamp < this.buffer.getFeedLastModified(FEEDID));
+        
+        
+    }
+    
+  
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.getSortedEntries(String)'
+     */
+    public void testGetSortedEntries() throws IOException, InterruptedException {
+        assertNull(this.buffer.getSortedEntries(FEEDID));
+        ServerBaseEntry e = createServerBaseEntry("2",FEEDID);
+        e.setUpdated(new DateTime(System.currentTimeMillis()-200,0));
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        e.setId("0");
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-180,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        e.setId("1");
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-160,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        e.setId("0");
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-140,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.UPDATE);
+        this.buffer.addEntry(wrapper);
+//      force timestamp
+        e.setUpdated(new DateTime(System.currentTimeMillis()-120,0));
+        wrapper = new StorageEntryWrapper(e,StorageOperation.DELETE);
+        this.buffer.addEntry(wrapper);
+        List<StorageEntryWrapper> list = this.buffer.getSortedEntries(FEEDID);
+       assertEquals(3,list.size());
+        for (int i = 0; i < 3; i++) {
+            assertEquals(""+i,list.get(i).getEntryId());   
+        }
+        
+
+    }
+
+  
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.getEntry(String, String)'
+     */
+    public void testGetEntry() throws IOException {
+        assertNull(this.buffer.getEntry(ENTRYID,FEEDID));
+        ServerBaseEntry e = createServerBaseEntry(ENTRYID,FEEDID);
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        assertSame(wrapper,this.buffer.getEntry(ENTRYID,FEEDID));
+        
+        e = createServerBaseEntry("0",FEEDID);
+        wrapper = new StorageEntryWrapper(e,StorageOperation.UPDATE);
+        this.buffer.addEntry(wrapper);
+        assertSame(wrapper,this.buffer.getEntry("0",FEEDID));
+        
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.getExculdList()'
+     */
+    public void testGetExculdList() throws IOException {
+        ServerBaseEntry e = createServerBaseEntry(ENTRYID,FEEDID);
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        this.buffer.addEntry(wrapper);
+        assertEquals(1,this.buffer.getExculdList().length);
+        assertEquals(wrapper.getEntryId(),this.buffer.getExculdList()[0]);
+        
+        wrapper = new StorageEntryWrapper(e,StorageOperation.UPDATE);
+        this.buffer.addEntry(wrapper);
+        assertEquals(1,this.buffer.getExculdList().length);
+        assertEquals(wrapper.getEntryId(),this.buffer.getExculdList()[0]);
+        this.buffer.addDeleted(ENTRYID,FEEDID);
+        assertEquals(1,this.buffer.getExculdList().length);
+        assertEquals(wrapper.getEntryId(),this.buffer.getExculdList()[0]);
+        
+         e = createServerBaseEntry("someOtherEntry","someOtherFeed");
+        wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        this.buffer.addEntry(wrapper);
+        this.buffer.addEntry(wrapper);
+        assertEquals(2,this.buffer.getExculdList().length);
+        
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.storage.lucenestorage.StorageBuffer.close()'
+     */
+    public void testClose() throws IOException {
+        ServerBaseEntry e = createServerBaseEntry(ENTRYID,FEEDID);
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(e,StorageOperation.INSERT);
+        
+        this.buffer.addEntry(wrapper);
+        assertNotNull(this.buffer.getSortedEntries(FEEDID));
+        assertNotNull(this.buffer.getEntry(ENTRYID,FEEDID));
+        assertEquals(1,this.buffer.getExculdList().length);
+        this.buffer.close();
+        assertNull(this.buffer.getSortedEntries(FEEDID));
+        assertNull(this.buffer.getEntry(ENTRYID,FEEDID));
+        assertEquals(0,this.buffer.getExculdList().length);
+        
+        
+
+    }
+    public ServerBaseEntry createServerBaseEntry(String entryID, String feedId) throws IOException{
+        ServerBaseEntry e = new ServerBaseEntry();
+        e.setId(entryID);
+        e.setFeedId(feedId);
+        e.setServiceConfig(new ProvidedServiceStub());
+       return e;
+    }
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,443 @@
+package org.apache.lucene.gdata.storage.lucenestorage;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+import org.apache.lucene.gdata.server.registry.ComponentType;
+import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
+import org.apache.lucene.gdata.server.registry.ProvidedService;
+import org.apache.lucene.gdata.storage.ModificationConflictException;
+import org.apache.lucene.gdata.storage.Storage;
+import org.apache.lucene.gdata.storage.StorageController;
+import org.apache.lucene.gdata.storage.StorageException;
+import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
+import org.apache.lucene.gdata.utils.MultiThreadEntryStub;
+import org.apache.lucene.gdata.utils.ProvidedServiceStub;
+import org.apache.lucene.gdata.utils.Visitor;
+
+import com.google.gdata.data.DateTime;
+
+public class TestStorageImplementation extends TestCase {
+    private static GDataServerRegistry reg = null;
+
+    private Storage storage;
+
+    public static boolean fail = false;
+
+    protected void setUp() throws Exception {
+
+        if (reg == null) {
+            reg = GDataServerRegistry.getRegistry();
+            if(reg.lookup(StorageController.class,ComponentType.STORAGECONTROLLER)!= null);
+                reg.destroy();
+            reg.registerComponent(StorageCoreControllerStub.class,null);
+
+        }
+        this.storage = reg.lookup(StorageController.class,
+                ComponentType.STORAGECONTROLLER).getStorage();
+    }
+
+    protected void tearDown() throws Exception {
+        this.storage.close();
+        fail = false;
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.storeEntry(ServerBaseEntry)'
+     */
+    public void testStoreEntry() {
+
+        try {
+            this.storage.storeEntry(null);
+            fail("entry is null");
+        } catch (StorageException e) {
+            //
+        }
+        ServerBaseEntry entry = new ServerBaseEntry();
+        entry.setServiceConfig(new ProvidedServiceStub());
+
+        try {
+            this.storage.storeEntry(entry);
+            fail("feed is null");
+        } catch (StorageException e) {
+            //
+        }
+
+        entry.setFeedId("someID");
+        try {
+            this.storage.storeEntry(entry);
+
+        } catch (StorageException e1) {
+            fail("unexpected exception");
+
+        }
+        entry.setServiceConfig(null);
+        try {
+            this.storage.storeEntry(entry);
+            fail("no service config");
+        } catch (StorageException e) {
+
+        }
+        entry.setVersion(5);
+        try {
+            this.storage.storeEntry(entry);
+            fail("version is greater than 1");
+        } catch (StorageException e) {
+
+        }
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.deleteEntry(ServerBaseEntry)'
+     */
+    public void testDeleteEntry() throws InterruptedException {
+        try {
+            this.storage.storeEntry(null);
+            fail("entry is null");
+        } catch (StorageException e) {
+            //
+        }
+        ServerBaseEntry entry = new ServerBaseEntry();
+        entry.setServiceConfig(new ProvidedServiceStub());
+        entry.setId("someID");
+        entry.setFeedId("someID");
+        try {
+            this.storage.storeEntry(entry);
+
+        } catch (StorageException e) {
+            fail("unexpected exception");
+            //
+        }
+        entry.setFeedId(null);
+        try {
+            this.storage.deleteEntry(entry);
+            fail("feed is null");
+        } catch (StorageException e) {
+            //
+        }
+
+        entry.setFeedId("someID");
+        try {
+            this.storage.deleteEntry(entry);
+
+        } catch (StorageException e1) {
+            e1.printStackTrace();
+            fail("unexpected exception");
+
+        }
+        entry.setFeedId("someID");
+        
+        try {
+            this.storage.deleteEntry(entry);
+
+        } catch (StorageException e1) {
+            e1.printStackTrace();
+            fail("unexpected exception");
+
+        }
+        
+        
+        
+        Object monitor = new Object();
+        AtomicBoolean reached = new AtomicBoolean(false);
+
+        MultiThreadEntryStub concuEntry = new MultiThreadEntryStub();
+        concuEntry.setId(System.currentTimeMillis() + "");
+        ProvidedService conf = new ProvidedServiceStub();
+        
+        concuEntry.setServiceConfig(conf);
+        concuEntry.setUpdated(DateTime.now());
+        concuEntry.setFeedId("feed");
+        this.storage.storeEntry(concuEntry);
+        storage.close();
+        concuEntry.acceptGetVersionVisitor(getMonitorVisitor(monitor,reached));
+
+
+        Thread t1 = getDelThread(storage, concuEntry, false);
+
+        Thread t2 = getDelThread(storage, concuEntry, true);
+        t1.start();
+        /*
+         * Wait active -- not nice but works fine here
+         * wait until thread parked
+         */
+
+        while (true) {
+            synchronized (monitor) {
+                if (reached.get())
+                    break;
+                monitor.wait(10);
+            }
+        }
+        t2.start();
+        t2.join(800);
+        /*
+         * Wait active -- not nice but works fine here
+         * wake up the waiting thread
+         */
+        while (true) {
+            synchronized (monitor) {
+                if (!reached.get())
+                    break;
+                monitor.notifyAll();
+            }
+        }
+        t1.join(300);
+        if (fail)
+            fail("thread failed -- see stacktrace");
+       
+       
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.updateEntry(ServerBaseEntry)'
+     */
+    public void testUpdateEntry() throws InterruptedException {
+        Object monitor = new Object();
+        AtomicBoolean reached = new AtomicBoolean(false);
+
+        MultiThreadEntryStub concuEntry = new MultiThreadEntryStub();
+        concuEntry.setId(System.currentTimeMillis() + "");
+        ProvidedService conf = new ProvidedServiceStub();
+        
+        concuEntry.setServiceConfig(conf);
+        concuEntry.setUpdated(DateTime.now());
+        concuEntry.setFeedId("feed");
+        this.storage.storeEntry(concuEntry);
+        storage.close();
+        concuEntry.acceptGetEntryVisitor(getMonitorVisitor(monitor,reached));
+
+
+        Thread t1 = getUpdThread(storage, concuEntry, false);
+
+        Thread t2 = getUpdThread(storage, concuEntry, true);
+        t1.start();
+        /*
+         * Wait active -- not nice but works fine here
+         * wait until thread parked
+         */
+
+        while (true) {
+            synchronized (monitor) {
+                if (reached.get())
+                    break;
+                monitor.wait(10);
+            }
+        }
+        t2.start();
+        t2.join(800);
+        /*
+         * Wait active -- not nice but works fine here
+         * wake up the waiting thread
+         */
+        while (true) {
+            synchronized (monitor) {
+                if (!reached.get())
+                    break;
+                monitor.notifyAll();
+            }
+        }
+        t1.join(300);
+        if (fail)
+            fail("thread failed -- see stacktrace");
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getFeed(ServerBaseFeed)'
+     */
+    public void testGetFeed() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getEntry(ServerBaseEntry)'
+     */
+    public void testGetEntry() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.close()'
+     */
+    public void testClose() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.storeAccount(GDataAccount)'
+     */
+    public void testStoreAccount() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.updateAccount(GDataAccount)'
+     */
+    public void testUpdateAccount() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.deleteAccount(String)'
+     */
+    public void testDeleteAccount() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.storeFeed(ServerBaseFeed,
+     * String)'
+     */
+    public void testStoreFeed() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.deleteFeed(String)'
+     */
+    public void testDeleteFeed() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.updateFeed(ServerBaseFeed,
+     * String)'
+     */
+    public void testUpdateFeed() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getServiceForFeed(String)'
+     */
+    public void testGetServiceForFeed() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getAccount(String)'
+     */
+    public void testGetAccount() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getAccountNameForFeedId(String)'
+     */
+    public void testGetAccountNameForFeedId() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getEntryLastModified(String,
+     * String)'
+     */
+    public void testGetEntryLastModified() {
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.getFeedLastModified(String)'
+     */
+    public void testGetFeedLastModified() {
+
+    }
+    static class Runner implements Runnable {
+        Storage s;
+
+        StorageController c;
+
+        ServerBaseEntry e;
+
+        boolean expConf;
+
+        StorageOperation op;
+
+        public Runner(Storage s, ServerBaseEntry e,
+                boolean expectConflict, StorageOperation op) {
+            this.s = s;
+            this.e = e;
+            this.expConf = expectConflict;
+            this.op = op;
+        }
+
+        public void run() {
+           
+            try {
+                if (this.op == StorageOperation.DELETE)
+                    this.s.deleteEntry(e);
+                if (this.op == StorageOperation.UPDATE)
+                    this.s.updateEntry(e);
+                if (expConf)
+                    fail = true;
+            } catch (ModificationConflictException ex) {
+                if (!expConf)
+                    fail = true;
+                ex.printStackTrace();
+
+            } catch (StorageException ex) {
+                ex.printStackTrace();
+                fail = true;
+            }
+
+        }
+    }
+    
+    private Visitor getMonitorVisitor(final Object monitor, final AtomicBoolean reached){
+        /*
+         * The executing thread stops at a defined position while holding the semaphore inside the storageImpl
+         */
+        return new Visitor(){
+          public void execute(Object[] o){
+            synchronized (monitor) {
+            try {
+                reached.set(true);
+                monitor.wait();
+                reached.set(false);
+              
+            } catch (InterruptedException e) {
+                //                   
+            }
+            }
+          }
+        };
+    }
+
+    private Thread getDelThread(Storage s, ServerBaseEntry e,
+            boolean conflictExpected) {
+        Thread t1 = new Thread(new Runner(s, e, conflictExpected,
+                StorageOperation.DELETE));
+        t1.setPriority(Thread.MAX_PRIORITY);
+        return t1;
+    }
+
+    private Thread getUpdThread(Storage s, ServerBaseEntry e,
+            boolean conflictExpected) {
+        Thread t1 = new Thread(new Runner(s, e, conflictExpected,
+                StorageOperation.UPDATE));
+        t1.setPriority(Thread.MAX_PRIORITY);
+        return t1;
+    }
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageModifier.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageModifier.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageModifier.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageModifier.java Tue Jul 25 15:23:01 2006
@@ -7,10 +7,7 @@
 import org.apache.lucene.gdata.data.GDataAccount;
 import org.apache.lucene.gdata.data.ServerBaseEntry;
 import org.apache.lucene.gdata.data.ServerBaseFeed;
-import org.apache.lucene.gdata.server.registry.ComponentType;
-import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 import org.apache.lucene.gdata.server.registry.ProvidedService;
-import org.apache.lucene.gdata.storage.StorageController;
 import org.apache.lucene.gdata.storage.StorageException;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
 import org.apache.lucene.gdata.storage.lucenestorage.util.ReferenceCounter;
@@ -23,6 +20,7 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
 
 import com.google.gdata.data.BaseEntry;
 import com.google.gdata.data.DateTime;
@@ -50,13 +48,16 @@
     private static String service = "myService";
 
     protected void setUp() throws Exception {
-        GDataServerRegistry.getRegistry().registerComponent(
-                StorageCoreController.class);
+        this.controller = new StorageCoreController();
+        this.dir = new RAMDirectory();
+        this.controller.setStorageDir(this.dir);
+        this.controller.setKeepRecoveredFiles(false);
+        this.controller.setOptimizeInterval(10);
+        this.controller.setRecover(false);
+        this.controller.setBufferSize(10);
+        this.controller.setPersistFactor(10);
+        this.controller.initialize();
         this.configurator = new ProvidedServiceStub();
-        GDataServerRegistry.getRegistry().registerService(this.configurator);
-        this.controller = (StorageCoreController) GDataServerRegistry
-                .getRegistry().lookup(StorageController.class,
-                        ComponentType.STORAGECONTROLLER);
         this.modifier = this.controller.getStorageModifier();
         this.dir = this.controller.getDirectory();
 
@@ -65,8 +66,9 @@
     protected void tearDown() throws Exception {
         this.count = 1;
         // destroy all resources
-        GDataServerRegistry.getRegistry().destroy();// TODO remove dependency
-                                                    // here
+        this.controller.destroy();
+        
+
 
     }
 
@@ -121,7 +123,8 @@
             assertEquals("updated Title:", insertString, fetchedEntry
                     .getTitle().getPlainText());
         }
-
+        
+       
     }
 
     /*
@@ -132,14 +135,16 @@
             ParseException, StorageException {
 
         Thread a = getRunnerThread(this.count);
-        a.start();
+        
 
         Thread b = getRunnerThread((this.count += 10));
         b.start();
-        // wait for the first thread to check for the inserted entries
+        a.start();
+//         wait for the first thread to check for the inserted entries
         a.join();  
         try{
         for (int i = 1; i < this.count; i++) {
+           
             ReferenceCounter<StorageQuery> innerQuery = this.controller
                     .getStorageQuery();
             BaseEntry e = innerQuery.get().singleEntryQuery("" + i, feedId,
@@ -358,6 +363,7 @@
                     StorageEntryWrapper wrapper = new StorageEntryWrapper(en,
                             StorageOperation.INSERT);
                     modifier.insertEntry(wrapper);
+//                    System.out.println("insert: "+i+" Thread: "+Thread.currentThread().getName());
                 } catch (Exception e1) {
 
                     e1.printStackTrace();

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageQuery.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageQuery.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageQuery.java Tue Jul 25 15:23:01 2006
@@ -10,15 +10,13 @@
 import org.apache.lucene.gdata.data.GDataAccount;
 import org.apache.lucene.gdata.data.ServerBaseEntry;
 import org.apache.lucene.gdata.data.ServerBaseFeed;
-import org.apache.lucene.gdata.server.registry.ComponentType;
-import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 import org.apache.lucene.gdata.server.registry.ProvidedService;
-import org.apache.lucene.gdata.storage.StorageController;
 import org.apache.lucene.gdata.storage.StorageException;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
 import org.apache.lucene.gdata.storage.lucenestorage.util.ReferenceCounter;
 import org.apache.lucene.gdata.utils.ProvidedServiceStub;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
 
 import com.google.gdata.data.BaseEntry;
 import com.google.gdata.data.BaseFeed;
@@ -37,12 +35,17 @@
     private static String accountName = "simon";
     private static String service = ProvidedServiceStub.SERVICE_NAME;
     protected void setUp() throws Exception {
-        GDataServerRegistry.getRegistry().registerComponent(StorageCoreController.class);
         this.configurator = new ProvidedServiceStub();
-        
-        
-        GDataServerRegistry.getRegistry().registerService(this.configurator);
-        this.controller = (StorageCoreController)GDataServerRegistry.getRegistry().lookup(StorageController.class,ComponentType.STORAGECONTROLLER);
+        this.controller = new StorageCoreController();
+        this.dir = new RAMDirectory();
+        this.controller.setStorageDir(this.dir);
+        this.controller.setKeepRecoveredFiles(false);
+        this.controller.setOptimizeInterval(10);
+        this.controller.setRecover(false);
+        this.controller.setBufferSize(10);
+        this.controller.setPersistFactor(10);
+        this.controller.initialize();
+        this.configurator = new ProvidedServiceStub();
         this.modifier = this.controller.getStorageModifier();
         this.dir = this.controller.getDirectory();        
         ServerBaseFeed feed = new ServerBaseFeed();
@@ -55,12 +58,8 @@
         insertEntries(this.count);
         this.query = this.controller.getStorageQuery();
         
-       
-        
-        
     }
     
-    
     /**
      * @param entrycount
      * @throws IOException
@@ -93,7 +92,7 @@
 
     protected void tearDown() throws Exception {
         this.query.decrementRef();
-        GDataServerRegistry.getRegistry().destroy();
+        this.controller.destroy();
     }
     
     /*
@@ -245,6 +244,43 @@
         this.query = this.controller.getStorageQuery();
         assertEquals(entry.getUpdated().getValue(),this.query.get().getFeedLastModified(feedId));
     }
+    
+    public void testCheckVersionId() throws IOException, StorageException{
+        this.modifier.forceWrite();
+        ReferenceCounter<StorageQuery> sQuery = this.controller.getStorageQuery();
+        ServerBaseEntry entry = new ServerBaseEntry(new Entry());
+        entry.setId("test");
+        entry.setServiceConfig(this.configurator);
+        entry.setUpdated(new DateTime(System.currentTimeMillis(),0));
+        entry.setFeedId(feedId);
+        entry.setVersion(5);
+        StorageEntryWrapper wrapper = new StorageEntryWrapper(entry,StorageOperation.INSERT);
+        this.modifier.insertEntry(wrapper);
+        //test in buffer
+        assertTrue(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),entry.getVersion()));
+        assertFalse(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),10000));
+        assertFalse(sQuery.get().checkEntryVersion(entry.getId(),"someOtherFeed",entry.getVersion()));
+        assertFalse(sQuery.get().checkEntryVersion("foobar",entry.getFeedId(),entry.getVersion()));
+        
+        
+        this.modifier.forceWrite();
+        //test in buffer after written
+        assertTrue(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),entry.getVersion()));
+        assertFalse(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),10000));
+        assertFalse(sQuery.get().checkEntryVersion(entry.getId(),"someOtherFeed",entry.getVersion()));
+        assertFalse(sQuery.get().checkEntryVersion("foobar",entry.getFeedId(),entry.getVersion()));
+        sQuery.decrementRef();
+        sQuery = this.controller.getStorageQuery();
+        //test in index
+        assertTrue(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),entry.getVersion()));
+        assertFalse(sQuery.get().checkEntryVersion(entry.getId(),entry.getFeedId(),10000));
+        assertFalse(sQuery.get().checkEntryVersion("foobar",entry.getFeedId(),entry.getVersion()));
+        sQuery.decrementRef();
+        
+        
+        
+        
+    }
     private void entryQueryHelper(ReferenceCounter<StorageQuery> currentQuery) throws IOException,  ParseException{
         
         List<String> entryIdList = new ArrayList<String>();
@@ -255,7 +291,9 @@
         assertEquals(entryIdList.size(),entryList.size());
         List<String> entryIdCompare = new ArrayList<String>();
         for (BaseEntry entry : entryList) {
+            assertEquals("1",entry.getVersionId());
             entryIdCompare.add(entry.getId());
+            
         }
         assertTrue(entryIdList.containsAll(entryIdCompare));
         

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRecoverController.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRecoverController.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRecoverController.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRecoverController.java Tue Jul 25 15:23:01 2006
@@ -3,35 +3,34 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.rmi.registry.Registry;
+
+import junit.framework.TestCase;
 
 import org.apache.lucene.gdata.data.ServerBaseEntry;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 import org.apache.lucene.gdata.storage.StorageException;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper;
-import org.apache.lucene.gdata.storage.lucenestorage.StorageModifier;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageModifierStub;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
 import org.apache.lucene.gdata.utils.ProvidedServiceStub;
-import org.easymock.MockControl;
 
 import com.google.gdata.data.DateTime;
 
-import junit.framework.TestCase;
-
 public class TestRecoverController extends TestCase {
     private RecoverController writeController;
     private RecoverController readController;
-    private File recDir = new File("./temp/");
+    private File recDir;
     private String feedId = "feedid";
     private String entryId = "entryId";
     
     protected void setUp() throws Exception {
+        this.recDir = new File("unittest"+System.currentTimeMillis());
         if(!this.recDir.exists())
             this.recDir.mkdir();
+        this.recDir.deleteOnExit();
         GDataServerRegistry.getRegistry().registerService(new ProvidedServiceStub());
-        this.writeController = new RecoverController(this.recDir,false,false);
-        this.readController = new RecoverController(this.recDir,true,false);
+        this.writeController = new RecoverController(this.recDir,false,true);
+        this.readController = new RecoverController(this.recDir,true,true);
         
         
 
@@ -82,8 +81,8 @@
             fail("unexpected exception"+e.getMessage());
         }
         this.readController.destroy();
-        assertEquals(0,this.recDir.listFiles().length);
-        assertNotSame(length,this.recDir.listFiles().length);
+        assertEquals(1,this.recDir.listFiles().length);
+        
         createCorruptedFile();
         this.readController.initialize();
         try{
@@ -92,7 +91,7 @@
             fail("unexpected exception"+e.getMessage());
         }
         this.readController.destroy();
-        assertEquals(1,this.recDir.listFiles().length);
+        assertEquals(2,this.recDir.listFiles().length);
     }
     
     

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRevocerReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRevocerReader.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRevocerReader.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRevocerReader.java Tue Jul 25 15:23:01 2006
@@ -8,7 +8,6 @@
 import junit.framework.TestCase;
 
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
-import org.apache.lucene.gdata.server.registry.ProvidedService;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper;
 import org.apache.lucene.gdata.storage.lucenestorage.StorageEntryWrapper.StorageOperation;
 import org.apache.lucene.gdata.utils.ProvidedServiceStub;

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.gdata.utils;
+
+
+
+
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+
+import com.google.gdata.data.BaseEntry;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class MultiThreadEntryStub extends ServerBaseEntry {
+    
+    
+    private Visitor getEntryVisitor;
+    private Visitor getVersionVisitor;
+    /**
+     * 
+     */
+    public MultiThreadEntryStub() {
+        
+     
+    }
+    
+    /**
+     * @param arg0
+     */
+    public MultiThreadEntryStub(BaseEntry arg0) {
+        super(arg0);
+        
+    }
+   
+    
+    
+    public void acceptGetEntryVisitor(Visitor visitor){
+        this.getEntryVisitor = visitor;
+    }
+    public void acceptGetVersionVisitor(Visitor visitor){
+       this.getVersionVisitor = visitor;
+    }
+    /**
+     * @see org.apache.lucene.gdata.data.ServerBaseEntry#getEntry()
+     */
+    @Override
+    public BaseEntry getEntry() {
+       
+        if(this.getEntryVisitor != null){
+            this.getEntryVisitor.execute(null);
+
+        }
+        return super.getEntry();
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.data.ServerBaseEntry#getVersion()
+     */
+    @Override
+    public int getVersion() {
+
+        if(this.getVersionVisitor != null){
+            this.getVersionVisitor.execute(null);
+
+        }
+        return super.getVersion();
+    }
+
+
+    
+    
+    
+    
+    
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/ProvidedServiceStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/ProvidedServiceStub.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/ProvidedServiceStub.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/ProvidedServiceStub.java Tue Jul 25 15:23:01 2006
@@ -35,4 +35,7 @@
         return SERVICE_NAME;
     }
 
+    public void destroy() {
+    }
+
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageControllerStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageControllerStub.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageControllerStub.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageControllerStub.java Tue Jul 25 15:23:01 2006
@@ -57,4 +57,9 @@
     public void initialize() {
     }
 
+    public String releaseId() {
+        
+        return null;
+    }
+
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageStub.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageStub.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageStub.java Tue Jul 25 15:23:01 2006
@@ -170,4 +170,9 @@
         return null;
     }
 
+    public String releaseId() {
+        
+        return null;
+    }
+
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestDateFormater.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestDateFormater.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestDateFormater.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestDateFormater.java Tue Jul 25 15:23:01 2006
@@ -1,11 +1,8 @@
 package org.apache.lucene.gdata.utils;
 
 import java.text.ParseException;
-import java.util.Calendar;
+import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.TimeZone;
-
-import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;
 
 import junit.framework.TestCase;
 
@@ -18,24 +15,30 @@
     protected void tearDown() throws Exception {
         super.tearDown();
     }
-
     /*
      * Test method for 'org.apache.lucene.gdata.utils.DateFormater.formatDate(Date, String)'
      */
     public void testFormatDate() throws ParseException {
-        
         // this reg. --> bit weak but does the job
             java.util.regex.Pattern pattern =  java.util.regex.Pattern.compile("[A-Z][a-z]{1,2}, [0-9]{1,2} [A-Z][a-z]{2} [0-9]{4} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [A-Z]{2,4}");
             Date date = new Date();
-           
             String formatedDate = DateFormater.formatDate(date,DateFormater.HTTP_HEADER_DATE_FORMAT);
-           
             assertTrue(pattern.matcher(formatedDate).matches());    
-           
+            DateFormater.parseDate("Sun, 25 Jun 2006 13:51:23 +0000",DateFormater.HTTP_HEADER_DATE_FORMAT,DateFormater.HTTP_HEADER_DATE_FORMAT_TIME_OFFSET);
             DateFormater.parseDate("Sun, 25 Jun 2006 13:51:23 CEST",DateFormater.HTTP_HEADER_DATE_FORMAT,DateFormater.HTTP_HEADER_DATE_FORMAT_TIME_OFFSET);
             //TODO extend this
-            
+    }
+    
+    public void testFormatDateStack(){
+        DateFormater formater = new DateFormater();
+        SimpleDateFormat f1 = formater.getFormater();
+        SimpleDateFormat f2 = formater.getFormater();
+        assertNotSame(f1,f2);
+        formater.returnFomater(f1);
+        assertSame(f1,formater.getFormater());
+        formater.returnFomater(f2);
+        assertSame(f2,formater.getFormater());
         
     }
-
+    
 }

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,139 @@
+package org.apache.lucene.gdata.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class TestSimpleObjectPool extends TestCase {
+    private Pool testPool;
+    private int SIZE = 10;
+    protected void setUp() throws Exception {
+        this.testPool =new SimpleObjectPool(SIZE,new ObjectFactoryStub());
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.utils.SimpleObjectPool.SimpleObjectPool(int, PoolObjectFactory<Type>)'
+     */
+    public void testSimpleObjectPool() {
+        SimpleObjectPool pool = new SimpleObjectPool(1,new ObjectFactoryStub());
+        assertEquals(pool.getSize(),SimpleObjectPool.MINIMALSIZE);
+        pool = new SimpleObjectPool(-100,new ObjectFactoryStub());
+        assertEquals(pool.getSize(),SimpleObjectPool.MINIMALSIZE);
+        pool = new SimpleObjectPool(new ObjectFactoryStub());
+        assertEquals(pool.getSize(),SimpleObjectPool.DEFAULTSIZE);
+        pool = new SimpleObjectPool(100,new ObjectFactoryStub());
+        
+        assertEquals(100,pool.getSize());
+        try{
+        pool = new SimpleObjectPool(1,null);
+            fail("factory must not be null");
+        }catch (Exception e) {
+            // TODO: handle exception
+        }
+        
+
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.utils.SimpleObjectPool.aquire()'
+     */
+    public void testAquire() {
+        List l = new ArrayList(SIZE);
+        for (int i = 0; i < SIZE; i++) {
+            Object o = this.testPool.aquire();
+            assertNotNull(o);
+            assertFalse(l.contains(o));
+            l.add(o);
+            
+        }
+        for (Object object : l) {
+            this.testPool.release(object);
+        }
+        for (int i = 0; i < SIZE; i++) {
+            Object o = this.testPool.aquire();
+            assertNotNull(o);
+            assertTrue(l.contains(o));
+         
+            
+        }
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.utils.SimpleObjectPool.release(Type)'
+     */
+    public void testRelease() {
+        List l = new ArrayList(SIZE);
+        for (int i = 0; i < SIZE; i++) {
+            Object o = this.testPool.aquire();
+            assertNotNull(o);
+            assertFalse(l.contains(o));
+            l.add(o);
+            
+        }
+        
+        for (Object object : l) {
+            this.testPool.release(object);
+        }
+        for (int i = 0; i < 10; i++) {
+            this.testPool.release(new Object());
+        }
+        
+        for (int i = 0; i < SIZE; i++) {
+            Object o = this.testPool.aquire();
+            assertNotNull(o);
+            assertTrue(l.contains(o));
+         
+            
+        }
+        
+        //############################
+        
+        for (Object object : l) {
+            this.testPool.release(object);
+        }
+        
+        for (int i = 0; i < SIZE +SIZE; i++) {
+            Object o = this.testPool.aquire();
+            assertNotNull(o);
+            
+            if(i>= SIZE)
+                assertFalse(l.contains(o));
+            else
+            assertTrue(l.contains(o));
+        }
+    }
+    
+    public void testDestroy(){
+        this.testPool.destroy();
+        try{
+        this.testPool.aquire();
+        fail("pool is already closed");
+        }catch (Exception e) {
+            // TODO: handle exception
+        }
+        this.testPool.release(new Object());
+    }
+    
+    static class ObjectFactoryStub implements PoolObjectFactory{
+
+        public Object getInstance() {
+            
+            return new Object();
+        }
+
+        
+
+        public void destroyInstance(Object type) {
+            //
+        }
+        
+        
+    }
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,5 @@
+package org.apache.lucene.gdata.utils;
+
+public interface Visitor {
+    public void execute(Object[] objects);
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xml?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xml (original)
+++ lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xml Tue Jul 25 15:23:01 2006
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gdata>
-	<service name="feed" public="true">
+	<service name="feed" poolSize="20" public="true">
 		<feed-class>com.google.gdata.data.Feed</feed-class>
 		<entry-class>com.google.gdata.data.Entry</entry-class>
 		<extension-profile>
 			com.google.gdata.data.ExtensionProfile
 		</extension-profile>
 	</service>
-	<service name="calendar" public="true">
+	<service name="calendar" poolSize="20" public="true">
 		<feed-class>
 			com.google.gdata.data.extensions.EventFeed
 		</feed-class>
@@ -20,16 +20,34 @@
 	</service>
 	<server-components>
 		<component>
-			org.apache.lucene.gdata.storage.lucenestorage.StorageCoreController
+			<class>
+				org.apache.lucene.gdata.storage.lucenestorage.StorageCoreController
+			</class>
+			<configuration>
+				<property name="bufferSize">20</property>
+				<property name="optimizeInterval">20</property>
+				<property name="persistFactor">20</property>
+				<property name="directory">/tmp/storage</property>
+				<property name="recover">true</property>
+	            <property name="keepRecoveredFiles">false</property>
+			</configuration>
 		</component>
 		<component>
-			org.apache.lucene.gdata.servlet.handler.DefaultRequestHandlerFactory
+			<class>
+				org.apache.lucene.gdata.servlet.handler.DefaultRequestHandlerFactory
+			</class>
 		</component>
 		<component>
-			org.apache.lucene.gdata.server.ServiceFactory
+			<class>org.apache.lucene.gdata.server.ServiceFactory</class>
 		</component>
 		<component>
-			org.apache.lucene.gdata.server.authentication.BlowfishAuthenticationController
+			<class>
+				org.apache.lucene.gdata.server.authentication.BlowfishAuthenticationController
+			</class>
+			<configuration>
+				<property name="key">cryptKey</property>
+				<property name="loginTimeout">60</property>
+			</configuration>
 		</component>
 	</server-components>
 </gdata>

Added: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd (added)
+++ lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd Tue Jul 25 15:23:01 2006
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+	<xs:element name="feed-class" type="xs:string" />
+	<xs:element name="entry-class" type="xs:string" />
+	<xs:element name="extension-profile" type="xs:string" />
+	<xs:element name="class" type="xs:string" />
+
+	<xs:element name="property">
+		<xs:complexType mixed="true">
+			<xs:attribute name="name" type="xs:string" use="required" />
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="configuration">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="property" minOccurs="1"
+					maxOccurs="unbounded" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="service">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="feed-class" maxOccurs="1"
+					minOccurs="1" />
+				<xs:element ref="entry-class" maxOccurs="1"
+					minOccurs="1" />
+				<xs:element ref="extension-profile" maxOccurs="1"
+					minOccurs="1" />
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required" />
+			<xs:attribute name="public" type="xs:boolean" />
+			<xs:attribute name="poolSize" type="xs:nonNegativeInteger"
+				use="required" />
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="component">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="class" maxOccurs="1" minOccurs="1" />
+				<xs:element ref="configuration" minOccurs="0"
+					maxOccurs="1" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="server-components">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="component" minOccurs="1"
+					maxOccurs="unbounded" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="gdata">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="service" minOccurs="1"
+					maxOccurs="unbounded" />
+				<xs:element ref="server-components" maxOccurs="1"
+					minOccurs="1" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>

Propchange: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/lucenestorage.properties.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/lucenestorage.properties.xml?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/lucenestorage.properties.xml (original)
+++ lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/lucenestorage.properties.xml Tue Jul 25 15:23:01 2006
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?> 
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> 
-<properties> 
-<comment>Lucene Storage Properties</comment> 
-<entry key="gdata.server.storage.lucene.buffersize">20</entry> 
-<entry key="gdata.server.storage.lucene.persistFactor">20</entry> 
-<entry key="gdata.server.storage.lucene.optimizeInterval">20</entry> 
-<entry key="gdata.server.storage.lucene.directory">/tmp/storage/</entry> 
-<entry key="gdata.server.storage.lucene.recover">true</entry> 
-<entry key="gdata.server.storage.lucene.recover.keepFiles">false</entry> 
-</properties> 
\ No newline at end of file

Modified: lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/web.xml?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/web.xml (original)
+++ lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/web.xml Tue Jul 25 15:23:01 2006
@@ -13,6 +13,11 @@
 			org.apache.lucene.gdata.server.registry.RegistryContextListener
 		</listener-class>
 	</listener>
+	<listener>
+		<listener-class>
+			org.apache.lucene.gdata.server.registry.GDataRequestListener
+		</listener-class>
+	</listener>
 	<servlet>
 		<servlet-name>ControllerServlet</servlet-name>
 		<servlet-class>



Mime
View raw message