lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r430568 [6/8] - in /lucene/java/trunk/contrib/gdata-server: ./ lib/ src/java/org/apache/lucene/gdata/data/ src/java/org/apache/lucene/gdata/search/ src/java/org/apache/lucene/gdata/search/analysis/ src/java/org/apache/lucene/gdata/search/co...
Date Thu, 10 Aug 2006 22:32:47 GMT
Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataCategoryStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataCategoryStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataCategoryStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataCategoryStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,105 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+import org.apache.lucene.gdata.search.index.GdataIndexerException;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class TestGdataCategoryStrategy extends TestCase {
+    private static final String FIELD = "foo";
+
+    private static final float BOOST = 2.0f;
+
+    GdataCategoryStrategy strategy;
+
+    private IndexSchemaField field;
+
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+        //store and index will be ignored
+        field.setStore(Field.Store.NO);
+        field.setIndex(Field.Index.TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        this.strategy = new GdataCategoryStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<?
+     * extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("retun value is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        assertNull(this.strategy.content);
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+
+        String content = "fooBar";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.content);
+        assertNotNull(this.strategy.categoryScheme);
+        assertEquals(content+" "+content, this.strategy.content.trim());
+        assertEquals(content, this.strategy.categoryScheme);
+
+        Field[] fields = this.strategy.createLuceneField();
+        assertEquals(2, fields.length);
+        assertEquals(this.field.getName(), fields[0].name());
+        assertEquals(content+" "+content, fields[0].stringValue().trim());
+        assertEquals(this.strategy.categorySchemeField, fields[1].name());
+        assertEquals(content, fields[1].stringValue());
+        // this is also stored an untok.
+        assertFalse(fields[0].isStored());
+        assertTrue(fields[0].isTokenized());
+        // test for xpath exc.
+        this.field.setPath(null);
+        this.strategy = new GdataCategoryStrategy(field);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataCategoryStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataDateStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataDateStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataDateStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataDateStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,115 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+import org.apache.lucene.gdata.search.index.GdataIndexerException;
+
+import com.google.gdata.data.DateTime;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class TestGdataDateStrategy extends TestCase {
+    private static final String FIELD = "foo";
+
+    private static final float BOOST = 2.0f;
+
+    ContentStrategy strategy;
+
+    private IndexSchemaField field;
+
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+        field.setStore(Field.Store.NO);
+        field.setIndex(Field.Index.TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        this.strategy = new GdataDateStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<?
+     * extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("retun value is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        assertNull(this.strategy.content);
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+        // test with proper date 
+        String content = "2005-01-09T08:00:00Z";
+        String parsedConent = Long.toString(DateTime.parseDateTime(content)
+                .getValue());
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.content);
+        assertEquals(parsedConent, this.strategy.content);
+
+        Field[] fields = this.strategy.createLuceneField();
+        assertEquals(1, fields.length);
+        assertEquals(this.field.getName(), fields[0].name());
+        assertEquals(parsedConent, fields[0].stringValue());
+        // timestamp is stored and untok.
+        assertTrue(fields[0].isStored());
+        assertFalse(fields[0].isTokenized());
+        
+        this.strategy = new GdataDateStrategy(this.field);
+        content = "2005-01-09T##08:00:00Z";
+        stub.setReturnValueTextContent(content);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("unparsable date must fail");
+        } catch (NotIndexableException e) {
+        }
+        
+        
+        // test for xpath exc.
+        this.field.setPath(null);
+        this.strategy = new GdataDateStrategy(this.field);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+
+    }
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestGdataDateStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestHTMLStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestHTMLStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestHTMLStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestHTMLStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,75 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestHTMLStrategy extends TestCase {
+    private static final String FIELD = "foo";
+    private static final float BOOST = 2.0f;
+    ContentStrategy strategy;
+    private IndexSchemaField field;
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+        field.setStore(Field.Store.YES);
+        field.setIndex(Field.Index.UN_TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        this.strategy = new HTMLStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<? extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try{
+        this.strategy.processIndexable(stub);
+        fail("retun value is null must fail");
+        }catch (NotIndexableException e) {}
+        assertNull(this.strategy.content);
+        String content = "fooBar";
+        //just to make sure the filter is applied.
+        String htmlContent = "<b>"+content+"</b>";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(htmlContent);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.content);
+        assertEquals(content,this.strategy.content);
+        
+        
+        // test for xpath exc.
+        this.field.setPath(null);
+        try{
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+            }catch (NotIndexableException e) {}
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestHTMLStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestKeywordStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestKeywordStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestKeywordStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestKeywordStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,104 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+import org.apache.lucene.gdata.search.index.GdataIndexerException;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class TestKeywordStrategy extends TestCase {
+    private static final String FIELD = "foo";
+
+    private static final float BOOST = 2.0f;
+
+    ContentStrategy strategy;
+
+    private IndexSchemaField field;
+
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+        field.setStore(Field.Store.NO);
+        field.setIndex(Field.Index.TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        
+        this.strategy = new KeywordStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<?
+     * extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("retun value is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        assertNull(this.strategy.content);
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+
+        String content = "fooBar";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.content);
+        assertEquals(content, this.strategy.content);
+
+        Field[] fields = this.strategy.createLuceneField();
+        assertEquals(1, fields.length);
+        assertEquals(this.field.getName(), fields[0].name());
+        assertEquals(content, fields[0].stringValue());
+        // this is also stored an untok.
+        assertTrue(fields[0].isStored());
+        assertFalse(fields[0].isTokenized());
+        
+        
+        // test for xpath exc.
+        this.field.setPath(null);
+        this.strategy = new KeywordStrategy(field);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        try {
+            this.strategy.createLuceneField();
+            fail("content is not set");
+        } catch (GdataIndexerException e) {
+        }
+
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestKeywordStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestMixedStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestMixedStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestMixedStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestMixedStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,102 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+
+/**
+ * @author Simon Willnauer
+ * 
+ */
+public class TestMixedStrategy extends TestCase {
+    private static final String FIELD = "foo";
+
+    private static final float BOOST = 2.0f;
+
+    MixedContentStrategy strategy;
+
+    private IndexSchemaField field;
+
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+
+        field.setStore(Field.Store.YES);
+        field.setIndex(Field.Index.UN_TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        field.setTypePath("/path");
+        this.strategy = new MixedContentStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<?
+     * extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("retun value is null must fail");
+        } catch (NotIndexableException e) {
+        }
+        assertNull(this.strategy.content);
+        String content = "fooBar";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.strategy.content);
+        assertEquals(content, this.strategy.strategy.content);
+        assertEquals(this.strategy.strategy.getClass(), PlainTextStrategy.class);
+
+       
+
+        content = "html";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.strategy.content);
+        assertEquals(content, this.strategy.strategy.content);
+        assertEquals(this.strategy.strategy.getClass(), HTMLStrategy.class);
+
+        content = "xhtml";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.strategy.content);
+        assertEquals(content, this.strategy.strategy.content);
+        assertEquals(this.strategy.strategy.getClass(), XHtmlStrategy.class);
+
+        
+        // test for xpath exc.
+        this.field.setPath(null);
+        try {
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+        } catch (NotIndexableException e) {
+        }
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestMixedStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestPlainTextStrategy.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestPlainTextStrategy.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestPlainTextStrategy.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestPlainTextStrategy.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,73 @@
+/**
+ * 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.search.analysis;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestPlainTextStrategy extends TestCase {
+    private static final String FIELD = "foo";
+    private static final float BOOST = 2.0f;
+    ContentStrategy strategy;
+    private IndexSchemaField field;
+    protected void setUp() throws Exception {
+        this.field = new IndexSchemaField();
+        field.setName(FIELD);
+        field.setStore(Field.Store.YES);
+        field.setIndex(Field.Index.UN_TOKENIZED);
+        field.setBoost(BOOST);
+        field.setPath("/path");
+        this.strategy = new PlainTextStrategy(field);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.analysis.PlainTextStrategy.processIndexable(Indexable<? extends Node, ? extends ServerBaseEntry>)'
+     */
+    public void testProcessIndexable() throws NotIndexableException {
+        IndexableStub stub = new IndexableStub();
+        stub.setReturnNull(true);
+        try{
+        this.strategy.processIndexable(stub);
+        fail("retun value is null must fail");
+        }catch (NotIndexableException e) {}
+        assertNull(this.strategy.content);
+        String content = "fooBar";
+        stub.setReturnNull(false);
+        stub.setReturnValueTextContent(content);
+        this.strategy.processIndexable(stub);
+        assertNotNull(this.strategy.content);
+        assertEquals(content,this.strategy.content);
+        
+        
+        // test for xpath exc.
+        this.field.setPath(null);
+        try{
+            this.strategy.processIndexable(stub);
+            fail("path is null must fail");
+            }catch (NotIndexableException e) {}
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/analysis/TestPlainTextStrategy.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchema.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchema.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchema.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,159 @@
+/** 
+ * 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.search.config;
+
+import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.gdata.search.config.IndexSchemaField.ContentType;
+import org.apache.lucene.gdata.search.index.IndexDocument;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestIndexSchema extends TestCase {
+    IndexSchema schema;
+
+    protected void setUp() throws Exception {
+        schema = new IndexSchema();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.config.IndexSchema.initialize()'
+     */
+    public void testInitialize() {
+        try {
+            schema.initialize();
+            fail("def search field is null");
+        } catch (RuntimeException e) {
+            // TODO: handle exception
+        }
+        schema.setDefaultSearchField("someField");
+        try {
+            schema.initialize();
+            fail("name is null");
+        } catch (RuntimeException e) {
+            // TODO: handle exception
+        }
+        schema.setName("someName");
+        try {
+            schema.initialize();
+            fail("indexLocation  is null");
+        } catch (RuntimeException e) {
+            // TODO: handle exception
+        }
+        schema.setIndexLocation("/loc/loc");
+        try {
+            schema.initialize();
+            fail("default search field is not set as a field");
+        } catch (RuntimeException e) {
+            // TODO: handle exception
+        }
+        IndexSchemaField f = new IndexSchemaField();
+        f.setName(schema.getDefaultSearchField());
+        f.setContentType(ContentType.TEXT);
+        schema.addSchemaField(f);
+        try {
+            schema.initialize();
+            fail("field check failed");
+        } catch (RuntimeException e) {
+            // TODO: handle exception
+        }
+        f.setPath("path");
+        schema.initialize();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.config.IndexSchema.addSchemaField(IndexSchemaField)'
+     */
+    public void testAddSchemaField() {
+        schema.addSchemaField(null);
+        assertEquals(0, schema.getFields().size());
+
+        IndexSchemaField f = new IndexSchemaField();
+        f.setName(IndexDocument.FIELD_ENTRY_ID);
+        schema.addSchemaField(f);
+        assertEquals(0, schema.getFields().size());
+
+        f.setName(IndexDocument.FIELD_FEED_ID);
+        schema.addSchemaField(f);
+        assertEquals(0, schema.getFields().size());
+
+        f.setName("some");
+        schema.addSchemaField(f);
+        assertEquals(1, schema.getFields().size());
+        assertEquals(StandardAnalyzer.class, schema.getServiceAnalyzer()
+                .getClass());
+        assertEquals(StandardAnalyzer.class, schema.getSchemaAnalyzer()
+                .getClass());
+        f.setName("someOther");
+        f.setAnalyzerClass(StopAnalyzer.class);
+        schema.addSchemaField(f);
+        assertEquals(2, schema.getFields().size());
+        assertEquals(PerFieldAnalyzerWrapper.class, schema.getSchemaAnalyzer()
+                .getClass());
+        schema.addSchemaField(f);
+        assertEquals(3, schema.getFields().size());
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.config.IndexSchema.getSearchableFieldNames()'
+     */
+    public void testGetSearchableFieldNames() {
+        IndexSchemaField f = new IndexSchemaField();
+        f.setName("some");
+        schema.addSchemaField(f);
+        assertEquals(1, schema.getSearchableFieldNames().size());
+        assertTrue(schema.getSearchableFieldNames().contains("some"));
+    }
+
+    public void testEquals() {
+        assertFalse(schema.equals(null));
+        assertFalse(schema.equals(new String()));
+        assertTrue(schema.equals(schema));
+        assertFalse(schema.equals(new IndexSchema()));
+        IndexSchema s1 = new IndexSchema();
+        s1.setName("someName");
+        assertFalse(schema.equals(s1));
+        schema.setName(s1.getName());
+        assertTrue(schema.equals(s1));
+    }
+
+    public void testHashCode() {
+        assertEquals(schema.hashCode(), schema.hashCode());
+        assertNotNull(schema.hashCode());
+        IndexSchema s1 = new IndexSchema();
+        s1.setName("someName");
+        assertTrue(schema.hashCode() != s1.hashCode());
+        schema.setName(s1.getName());
+        assertTrue(schema.hashCode() == s1.hashCode());
+    }
+
+    public void testToSTringNoNullPEx() {
+        assertNotNull(schema.toString());
+    }
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchema.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchemaField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchemaField.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchemaField.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchemaField.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,154 @@
+/** 
+ * 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.search.config;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.data.ServerBaseEntry;
+import org.apache.lucene.gdata.search.analysis.ContentStrategy;
+import org.apache.lucene.gdata.search.analysis.Indexable;
+import org.apache.lucene.gdata.search.analysis.NotIndexableException;
+import org.apache.lucene.gdata.search.analysis.PlainTextStrategy;
+import org.apache.lucene.gdata.search.config.IndexSchemaField.ContentType;
+import org.w3c.dom.Node;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestIndexSchemaField extends TestCase {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.config.IndexSchemaField.checkRequieredValues()'
+     */
+    public void testCheckRequieredValues() {
+        IndexSchemaField f = new IndexSchemaField();
+        assertFalse(f.checkRequieredValues());
+        f.setName("someName");
+        assertFalse(f.checkRequieredValues());
+        f.setPath("somePath");
+        assertFalse(f.checkRequieredValues());
+        f.setType("text");
+        assertTrue(f.checkRequieredValues());
+        f.setType("mixed");
+        assertFalse(f.checkRequieredValues());
+        f.setTypePath("sometypepath");
+        assertTrue(f.checkRequieredValues());
+        
+        f.setType("custom");
+        assertFalse(f.checkRequieredValues());
+        f.setFieldClass(TestContentStragtegy.class);
+        assertTrue(f.checkRequieredValues());
+    }
+    public void testSetFieldType(){
+        IndexSchemaField f = new IndexSchemaField();
+        f.setFieldClass(TestContentStragtegy.class);
+        try{
+            f.setFieldClass(PlainTextStrategy.class);
+            fail("no pub const.");
+        }catch (RuntimeException e) {
+            
+        }
+        try{
+            f.setFieldClass(null);
+            fail("is null");
+        }catch (RuntimeException e) {
+            
+        }
+        
+    }
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.config.IndexSchemaField.setAnalyzerClass(Class<? extends Analyzer>)'
+     */
+    public void testSetType() {
+        IndexSchemaField f = new IndexSchemaField();
+        f.setType("notatype");
+        assertNull(f.getContentType());
+        f.setType("custom");
+        assertEquals(ContentType.CUSTOM,f.getContentType());
+        f.setType("text");
+        assertEquals(ContentType.TEXT,f.getContentType());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.config.IndexSchemaField.setStoreByName(String)'
+     */
+    public void testSetStoreByName() {
+        IndexSchemaField f = new IndexSchemaField();
+        f.setStoreByName("someother");
+        assertEquals(Field.Store.NO,f.getStore());
+        f.setStoreByName("COMPRESS");
+        assertEquals(Field.Store.COMPRESS,f.getStore());
+        f.setStoreByName("YeS");
+        assertEquals(Field.Store.YES,f.getStore());
+        f.setStoreByName("No");
+        assertEquals(Field.Store.NO,f.getStore());
+        
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.config.IndexSchemaField.setIndexByName(String)'
+     */
+    public void testSetIndexByName() {
+        IndexSchemaField f = new IndexSchemaField();
+        f.setIndexByName("UN_done");
+        assertEquals(Field.Index.TOKENIZED,f.getIndex());
+        f.setIndexByName("UN_tokenized");
+        assertEquals(Field.Index.UN_TOKENIZED,f.getIndex());
+        f.setIndexByName("tokenized");
+        assertEquals(Field.Index.TOKENIZED,f.getIndex());
+        f.setIndexByName("no");
+        assertEquals(Field.Index.NO,f.getIndex());
+        f.setIndexByName("no_norms");
+        assertEquals(Field.Index.NO_NORMS,f.getIndex());
+        
+        
+    }
+    
+    public void testSetboost(){
+        IndexSchemaField f = new IndexSchemaField();
+        f.setBoost(-0.1f);
+        assertEquals(1.0f,f.getBoost());
+        f.setBoost(2.50f);
+        assertEquals(2.50f,f.getBoost());
+    }
+    
+    public void testToSTringNoNullPEx(){
+        assertNotNull(new IndexSchemaField().toString());
+    }
+    static class TestContentStragtegy extends ContentStrategy{
+        
+        public TestContentStragtegy(IndexSchemaField fieldConfiguration) {
+            super(fieldConfiguration);
+            // TODO Auto-generated constructor stub
+        }
+
+        @Override
+        public void processIndexable(Indexable<? extends Node, ? extends ServerBaseEntry> indexable) throws NotIndexableException {
+        }
+        
+    }
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/config/TestIndexSchemaField.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/FutureStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/FutureStub.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/FutureStub.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/FutureStub.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,103 @@
+/**
+ * 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.search.index;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class FutureStub<T> implements Future<T>{
+    T object;
+    CountDownLatch latch;
+    boolean wait;
+    
+    /**
+     * 
+     */
+    public FutureStub(T returnObject, CountDownLatch latch) {
+        this(returnObject,latch,false);
+    }
+    /**
+     * 
+     */
+    public FutureStub(T returnObject, CountDownLatch latch, boolean wait) {
+        super();
+        this.object = returnObject;
+        this.latch =latch;
+        this.wait =wait;
+    }
+    public FutureStub(T returnObject) {
+        this(returnObject,null);
+    }
+
+    /**
+     * @see java.util.concurrent.Future#cancel(boolean)
+     */
+    public boolean cancel(boolean arg0) {
+
+        return false;
+    }
+
+    /**
+     * @see java.util.concurrent.Future#isCancelled()
+     */
+    public boolean isCancelled() {
+
+        return false;
+    }
+
+    /**
+     * @see java.util.concurrent.Future#isDone()
+     */
+    public boolean isDone() {
+
+        return true;
+    }
+
+    /**
+     * @see java.util.concurrent.Future#get()
+     */
+    public T get() throws InterruptedException, ExecutionException {
+        doLatch(); 
+        return this.object;
+    }
+
+    /**
+     * @see java.util.concurrent.Future#get(long, java.util.concurrent.TimeUnit)
+     */
+    public T get(long arg0, TimeUnit arg1) throws InterruptedException,
+            ExecutionException, TimeoutException {
+       doLatch();
+        return this.object;
+    }
+    
+    private void doLatch() throws InterruptedException{
+        if(latch != null){
+            if(!wait)
+            this.latch.countDown();
+            else
+                this.latch.await(5000,TimeUnit.MILLISECONDS);
+        }
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/FutureStub.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexDocumentStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexDocumentStub.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexDocumentStub.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexDocumentStub.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,112 @@
+/**
+ * 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.search.index;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class IndexDocumentStub implements IndexDocument {
+    Document document;
+    Term deleteTerm;
+    IndexAction action;
+    CountDownLatch latch;
+    boolean commitAfter;
+    boolean optimizeAfter;
+    /**
+     * 
+     */
+    public IndexDocumentStub(Document doc, Term deleteTerm, IndexAction action, CountDownLatch latch) {
+        this.document = doc;
+        this.deleteTerm = deleteTerm;
+        this.action = action;
+        this.latch = latch;
+    }
+    public IndexDocumentStub(Document doc, Term deleteTerm, IndexAction action) {
+        this(doc,deleteTerm,action,null);
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexDocument#isUpdate()
+     */
+    public boolean isUpdate() {
+
+        return isAction(IndexAction.UPDATE);
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexDocument#isDelete()
+     */
+    public boolean isDelete() {
+
+        return isAction(IndexAction.DELETE);
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexDocument#isInsert()
+     */
+    public boolean isInsert() {
+
+     return isAction(IndexAction.INSERT);
+    }
+    private boolean isAction(IndexAction currentAction){
+        return this.action == currentAction;
+    }
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexDocument#getWriteable()
+     */
+    public Document getWriteable() {
+        if(latch != null)
+        latch.countDown();        
+        return this.document;
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexDocument#getDeletealbe()
+     */
+    public Term getDeletealbe() {
+        if(latch != null)
+            latch.countDown();
+        return this.deleteTerm;
+    }
+    public boolean commitAfter() {
+        
+        return this.commitAfter;
+    }
+    public boolean optimizeAfter() {
+        
+        return this.optimizeAfter;
+    }
+    /**
+     * @param commitAfter The commitAfter to set.
+     */
+    public void setCommitAfter(boolean commitAfter) {
+        this.commitAfter = commitAfter;
+    }
+    /**
+     * @param optimizeAfter The optimizeAfter to set.
+     */
+    public void setOptimizeAfter(boolean optimizeAfter) {
+        this.optimizeAfter = optimizeAfter;
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexDocumentStub.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexEventListenerStub.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexEventListenerStub.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexEventListenerStub.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexEventListenerStub.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,46 @@
+/**
+ * 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.search.index;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class IndexEventListenerStub implements IndexEventListener {
+    AtomicInteger count;
+    /**
+     * 
+     */
+    public IndexEventListenerStub() {
+        super();
+       this.count = new AtomicInteger(0);
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.search.index.IndexEventListener#commitCallBack(java.lang.String)
+     */
+    public void commitCallBack(String service) {
+        this.count.incrementAndGet();
+    }
+    
+    public int getCalledCount(){
+        return this.count.get();
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/IndexEventListenerStub.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexDocument.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexDocument.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexDocument.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexDocument.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,123 @@
+/** 
+ * 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.search.index;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.gdata.search.analysis.ContentStrategy;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+import org.apache.lucene.gdata.search.config.IndexSchemaField.ContentType;
+import org.apache.lucene.index.Term;
+
+public class TestGdataIndexDocument extends TestCase {
+    static String ENTRYID = "someEId";
+    static String FEEDID = "someFId";
+    GDataIndexDocument delDocument;
+    GDataIndexDocument updDocument;
+    GDataIndexDocument insDocument;
+    protected void setUp() throws Exception {
+        this.delDocument = new GDataIndexDocument(IndexAction.DELETE,ENTRYID,FEEDID,false,true);
+        this.insDocument = new GDataIndexDocument(IndexAction.INSERT,ENTRYID,FEEDID,true,false);
+        this.updDocument = new GDataIndexDocument(IndexAction.UPDATE,ENTRYID,FEEDID,false,true);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.addField(ContentStrategy)'
+     */
+    public void testAddField() {
+        assertEquals(0,this.delDocument.fields.size());    
+        this.delDocument.addField(null);
+        assertEquals(0,this.delDocument.fields.size());
+        IndexSchemaField ifield = new IndexSchemaField();
+        ifield.setContentType(ContentType.TEXT);
+        this.delDocument.addField(ContentStrategy.getFieldStrategy(ifield));
+        assertEquals(1,this.delDocument.fields.size());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.getWriteable()'
+     */
+    public void testGetWriteable() {
+        assertNotNull(this.insDocument.getWriteable());
+        Document doc = this.insDocument.getWriteable();
+        assertEquals(2,doc.getFields().size());
+        assertEquals(ENTRYID,doc.getField(GDataIndexDocument.FIELD_ENTRY_ID).stringValue());
+        assertEquals(FEEDID,doc.getField(GDataIndexDocument.FIELD_FEED_ID).stringValue());
+        
+        
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.getDeletealbe()'
+     */
+    public void testGetDeletealbe() {
+        assertNotNull(this.insDocument.getDeletealbe());
+        Term t = this.insDocument.getDeletealbe();
+        assertEquals(IndexDocument.FIELD_ENTRY_ID,t.field());
+        assertEquals(ENTRYID,t.text());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.isUpdate()'
+     */
+    public void testIsUpdate() {
+        assertFalse(this.insDocument.isUpdate());
+        assertTrue(this.updDocument.isUpdate());
+        assertFalse(this.delDocument.isUpdate());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.isDelete()'
+     */
+    public void testIsDelete() {
+        assertFalse(this.insDocument.isDelete());
+        assertFalse(this.updDocument.isDelete());
+        assertTrue(this.delDocument.isDelete());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.isInsert()'
+     */
+    public void testIsInsert() {
+        assertTrue(this.insDocument.isInsert());
+        assertFalse(this.updDocument.isInsert());
+        assertFalse(this.delDocument.isInsert());
+    }
+
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.commitAfter()'
+     */
+    public void testCommitAfter() {
+        assertTrue(this.insDocument.commitAfter());
+        assertFalse(this.updDocument.commitAfter());
+        assertFalse(this.delDocument.commitAfter());
+    }
+    
+    /*
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexDocument.optimizeAfter()'
+     */
+    public void testOptimizeAfter() {
+        assertFalse(this.insDocument.optimizeAfter());
+        assertTrue(this.updDocument.optimizeAfter());
+        assertTrue(this.delDocument.optimizeAfter());
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexDocument.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexWriter.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexWriter.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexWriter.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,79 @@
+/**
+ * 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.search.index;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.gdata.search.config.IndexSchema;
+import org.apache.lucene.gdata.search.config.IndexSchemaField;
+import org.apache.lucene.store.RAMDirectory;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestGdataIndexWriter extends TestCase {
+    IndexSchema schemaNoPerFielAnalyzer;
+    IndexSchema schemaPerFielAnalyzer;
+    long VALUE_GT_DEFAULT_LONG = 15000;
+    int VALUE_GT_DEFAULT_INT = 10000;
+    
+    protected void setUp() throws Exception {
+        this.schemaNoPerFielAnalyzer = new IndexSchema();
+        this.schemaPerFielAnalyzer = new IndexSchema();
+        IndexSchemaField field = new IndexSchemaField();
+        field.setName("someField");
+        field.setAnalyzerClass(StopAnalyzer.class);
+        this.schemaPerFielAnalyzer.addSchemaField(field);
+        this.schemaPerFielAnalyzer.setCommitLockTimeout(VALUE_GT_DEFAULT_LONG);
+        this.schemaPerFielAnalyzer.setMaxBufferedDocs(VALUE_GT_DEFAULT_INT);
+        this.schemaPerFielAnalyzer.setMaxFieldLength(VALUE_GT_DEFAULT_INT);
+        this.schemaPerFielAnalyzer.setMaxMergeDocs(VALUE_GT_DEFAULT_INT);
+        this.schemaPerFielAnalyzer.setMergeFactor(VALUE_GT_DEFAULT_INT);
+        this.schemaPerFielAnalyzer.setWriteLockTimeout(VALUE_GT_DEFAULT_LONG);
+        this.schemaPerFielAnalyzer.setUseCompoundFile(true);
+    }
+
+
+    /**
+     * Test method for 'org.apache.lucene.gdata.search.index.GDataIndexWriter.GDataIndexWriter(Directory, boolean, IndexSchema)'
+     * @throws IOException 
+     */
+    public void testGDataIndexWriter() throws IOException {
+        try{
+        new GDataIndexWriter(new RAMDirectory(),true,null);
+        fail("no index schema");
+        }catch (IllegalArgumentException e) {}
+        GDataIndexWriter writer = new GDataIndexWriter(new RAMDirectory(),true,this.schemaNoPerFielAnalyzer);
+        assertTrue(writer.getAnalyzer().getClass() == StandardAnalyzer.class);
+        
+        writer = new GDataIndexWriter(new RAMDirectory(),true,this.schemaPerFielAnalyzer);
+        assertTrue(writer.getAnalyzer().getClass() == PerFieldAnalyzerWrapper.class);
+        assertEquals(VALUE_GT_DEFAULT_LONG,writer.getCommitLockTimeout());
+        assertEquals(VALUE_GT_DEFAULT_LONG,writer.getWriteLockTimeout());
+        assertEquals(VALUE_GT_DEFAULT_INT,writer.getMaxBufferedDocs());
+        assertEquals(VALUE_GT_DEFAULT_INT,writer.getMaxMergeDocs());
+        assertEquals(VALUE_GT_DEFAULT_INT,writer.getMaxFieldLength());
+        assertEquals(VALUE_GT_DEFAULT_INT,writer.getMergeFactor());
+        assertTrue(writer.getUseCompoundFile());
+    }
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexWriter.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexer.java?rev=430568&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexer.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexer.java Thu Aug 10 15:32:40 2006
@@ -0,0 +1,549 @@
+/**
+ * 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.search.index;
+
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.TestCase;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.gdata.search.config.IndexSchema;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class TestGdataIndexer extends TestCase {
+    private GDataIndexer indexer;
+
+    private Directory dir;
+
+    private static IndexSchema config;
+
+    private static String FIELD_ID = "id";
+
+    static {
+        config = new IndexSchema();
+        config.setName("testService");
+        config.setCommitLockTimeout(-1);
+        config.setServiceAnalyzer(new StandardAnalyzer());
+        config.setMaxBufferedDocs(-1);
+        config.setMaxFieldLength(-1);
+        config.setMaxMergeDocs(-1);
+        config.setWriteLockTimeout(-1);
+        config.setMergeFactor(-1);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    @Override
+    protected void setUp() throws Exception {
+        this.dir = new RAMDirectory();
+        this.indexer = GDataIndexer.createGdataIndexer(config, this.dir, true);
+        super.setUp();
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    @Override
+    protected void tearDown() throws Exception {
+        this.indexer.destroy();
+    }
+    public void testStaticFactoryMethodes() throws IOException{
+        GDataIndexer i =GDataIndexer.createGdataIndexer(config, new RAMDirectory(), true);
+        assertNotNull(i);
+        assertEquals(IndexTask.class,i.indexTask.getClass());
+        
+        i =GDataIndexer.createTimedGdataIndexer(config, new RAMDirectory(), true,60);
+        assertNotNull(i);
+        assertEquals(TimedIndexTask.class,i.indexTask.getClass());
+        assertEquals(60,((TimedIndexTask)i.indexTask).getIdleTime());
+        
+        i.destroy();
+    }
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.GDataIndexer(IndexServiceConfiguration,
+     * Directory, boolean)'
+     */
+    public void testGDataIndexer() throws InterruptedException, IOException {
+        try {
+            new GDataIndexer(null, dir, true);
+            fail("config is null");
+        } catch (IllegalArgumentException e) {
+            //
+        }
+
+        try {
+            new GDataIndexer(config, null, true);
+            fail("dir is null");
+        } catch (IllegalArgumentException e) {
+            //
+        }
+        
+        GDataIndexer in = new GDataIndexer(config,new RAMDirectory(),true);
+        in.setIndexTask(null);
+        in.init();
+        assertNotNull(in.indexTask);
+        assertEquals(IndexTask.class,in.indexTask.getClass());
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.addIndexableDocumentTask(Future<IndexDocument>)'
+     */
+    public void testAddIndexableDocumentTask() throws InterruptedException,
+            IOException {
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm = new Term(FIELD_ID, id);
+        /*
+         * Latch will be decremented in FutureStub#get() and
+         * IndexDocumentStub#getIndexable
+         */
+        CountDownLatch l = new CountDownLatch(2);
+        IndexDocument iDoc = new IndexDocumentStub(doc, delTerm,
+                IndexAction.INSERT, l);
+        Future<IndexDocument> future = new FutureStub<IndexDocument>(iDoc, l);
+
+        this.indexer.addIndexableDocumentTask(future);
+        // wait for the latch do decrement
+        l.await(5000, TimeUnit.MILLISECONDS);
+
+        this.indexer.commit(false);
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        // test for update
+        /*
+         * Latch will be decremented in FutureStub#get() and
+         * IndexDocumentStub#getIndexable
+         */
+        l = new CountDownLatch(2);
+        iDoc = new IndexDocumentStub(doc, delTerm, IndexAction.UPDATE, l);
+        future = new FutureStub<IndexDocument>(iDoc, l);
+        this.indexer.addIndexableDocumentTask(future);
+        l.await(5000, TimeUnit.MILLISECONDS);
+        this.indexer.commit(false);
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+
+        // test for delete
+        /*
+         * Latch will be decremented in FutureStub#get()
+         */
+        l = new CountDownLatch(1);
+        iDoc = new IndexDocumentStub(doc, delTerm, IndexAction.DELETE, l);
+        future = new FutureStub<IndexDocument>(iDoc, l);
+
+        this.indexer.addIndexableDocumentTask(future);
+        /*
+         * wait for the indexer task to add the deleted
+         */
+        while (this.indexer.docsDeleted.get() == 0)
+            l.await(5000, TimeUnit.MILLISECONDS);
+
+        this.indexer.commit(false);
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(0, h.length());
+        s.close();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.addDocument(IndexDocument)'
+     */
+public void testAddDocument() throws IOException {
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm =  new Term(FIELD_ID, id);
+        IndexDocument iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.INSERT);
+        
+        this.indexer.addDocument(iDoc);
+        assertEquals(1,this.indexer.docsAdded.get());
+        assertEquals(0,this.indexer.docsDeleted.get());
+        assertEquals(0,this.indexer.docsUpdated.get());
+        this.indexer.addDocument(iDoc);
+        this.indexer.commit(false);
+        
+        
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.UPDATE);
+        try{
+            this.indexer.addDocument(iDoc);
+            fail("document has not insert action ");
+        }catch (GdataIndexerException e) {
+            
+        }
+        
+    }
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.updateDocument(IndexDocument)'
+     */
+    public void testUpdateDocument() throws IOException {
+        
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm =  new Term(FIELD_ID, id);
+        IndexDocument iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.INSERT);
+        /*
+         * write doc to index
+         */
+        this.indexer.writer.addDocument(doc);
+        this.indexer.closeWriter();
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.UPDATE);
+        /*
+         * updateDoc via indexer 
+         */
+        this.indexer.updateDocument(iDoc);
+        assertEquals(0,this.indexer.docsAdded.get());
+        assertEquals(0,this.indexer.docsDeleted.get());
+        assertEquals(1,this.indexer.docsUpdated.get());
+        
+        this.indexer.commit(false);
+        
+        
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.DELETE);
+        try{
+            this.indexer.updateDocument(iDoc);
+            fail("document has not update action ");
+        }catch (GdataIndexerException e) {
+            
+        }
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.deleteDocument(IndexDocument)'
+     */
+    public void testDeleteDocument() throws IOException {
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm =  new Term(FIELD_ID, id);
+        IndexDocument iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.INSERT);
+        /*
+         * write doc to index
+         */
+        this.indexer.writer.addDocument(doc);
+       
+        this.indexer.closeWriter();
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        
+        /*
+         * del doc via indexer
+         */
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.DELETE);
+        this.indexer.deleteDocument(iDoc);
+        assertEquals(0,this.indexer.docsAdded.get());
+        assertEquals(1,this.indexer.docsDeleted.get());
+        assertEquals(0,this.indexer.docsUpdated.get());
+        this.indexer.commit(false);
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(0, h.length());
+        s.close();
+        
+        /*
+         * test insert / del without commit
+         */ 
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                 IndexAction.INSERT);
+        this.indexer.addDocument(iDoc);
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.DELETE);
+        this.indexer.deleteDocument(iDoc);
+        this.indexer.commit(false);
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(0, h.length());
+        s.close();
+        
+        /*
+         * test insert / update / del without commit
+         */
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.INSERT);
+        this.indexer.addDocument(iDoc);
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.UPDATE);
+        this.indexer.updateDocument(iDoc);
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.DELETE);
+        this.indexer.deleteDocument(iDoc);
+        this.indexer.commit(false);
+        s = new IndexSearcher(this.dir);
+        h = s.search(new TermQuery(delTerm));
+        assertEquals(0, h.length());
+        s.close();
+        
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.UPDATE);
+        try{
+            this.indexer.deleteDocument(iDoc);
+            fail("document has not delete action ");
+        }catch (GdataIndexerException e) {
+            
+        }
+        
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.commit(boolean)'
+     */
+    public void testCommit() throws IOException {
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm =  new Term(FIELD_ID, id);
+        IndexDocument iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.INSERT);
+        this.indexer.addDocument(iDoc);
+         iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.UPDATE);
+        this.indexer.updateDocument(iDoc);
+        this.indexer.updateDocument(iDoc);
+        iDoc = new IndexDocumentStub(doc,delTerm,
+                IndexAction.DELETE);
+        this.indexer.deleteDocument(iDoc);
+        IndexEventListenerStub evListener = new IndexEventListenerStub();
+        this.indexer.registerIndexEventListener(evListener);
+        assertEquals(1,this.indexer.docsAdded.get());
+        assertEquals(1,this.indexer.docsDeleted.get());
+        assertEquals(2,this.indexer.docsUpdated.get());
+        assertEquals(0,evListener.getCalledCount());
+        this.indexer.commit(true);
+        this.indexer.commit(false);
+        assertEquals(1,evListener.getCalledCount());
+        assertEquals(0,this.indexer.docsAdded.get());
+        assertEquals(0,this.indexer.docsDeleted.get());
+        assertEquals(0,this.indexer.docsUpdated.get());
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(0, h.length());
+        s.close();
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.registerIndexEventListener(IndexEventListener)'
+     */
+    public void testRegisterIndexEventListener() {
+        IndexEventListenerStub evListener = new IndexEventListenerStub();
+        this.indexer.registerIndexEventListener(evListener);
+        this.indexer.registerIndexEventListener(evListener);
+        assertEquals(0,evListener.getCalledCount());
+        this.indexer.notifyCommitListeners("someId");
+        this.indexer.notifyCommitListeners("someId");
+        assertEquals(2,evListener.getCalledCount());
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.removeIndexEventListener(IndexEventListener)'
+     */
+    public void testRemoveIndexEventListener() {
+        IndexEventListenerStub evListener = new IndexEventListenerStub();
+        this.indexer.registerIndexEventListener(evListener);
+        assertEquals(0,evListener.getCalledCount());
+        this.indexer.notifyCommitListeners("someId");
+        assertEquals(1,evListener.getCalledCount());
+        this.indexer.removeIndexEventListener(evListener);
+        this.indexer.removeIndexEventListener(evListener);
+        this.indexer.notifyCommitListeners("someId");
+        assertEquals(1,evListener.getCalledCount());
+        
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.notifyCommitListeners(String)'
+     */
+    public void testNotifyCommitListeners() {
+        IndexEventListenerStub evListener = new IndexEventListenerStub();
+        IndexEventListenerStub evListener1 = new IndexEventListenerStub();
+        IndexEventListenerStub evListener2 = new IndexEventListenerStub();
+        this.indexer.registerIndexEventListener(evListener);
+        this.indexer.registerIndexEventListener(evListener1);
+        this.indexer.registerIndexEventListener(evListener2);
+        assertEquals(0,evListener.getCalledCount());
+        this.indexer.notifyCommitListeners("someId");
+        assertEquals(1,evListener.getCalledCount());
+        assertEquals(1,evListener1.getCalledCount());
+        assertEquals(1,evListener2.getCalledCount());
+        this.indexer.removeIndexEventListener(evListener);
+        this.indexer.notifyCommitListeners("someId");
+        assertEquals(1,evListener.getCalledCount());
+        assertEquals(2,evListener1.getCalledCount());
+        assertEquals(2,evListener2.getCalledCount());
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.closeWriter()'
+     */
+    public void testCloseWriter() throws IOException{
+        assertNotNull(this.indexer.writer);
+        this.indexer.closeWriter();
+        assertNull(this.indexer.writer);
+
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.closeSearcher()'
+     */
+    public void testCloseSearcher() throws IOException {
+        this.indexer.openSearcher();
+        assertNotNull(this.indexer.searcher);
+        this.indexer.closeSearcher();
+        assertNull(this.indexer.searcher);
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.openSearcher()'
+     */
+    public void testOpenSearcher() throws IOException {
+        this.indexer.searcher = null;
+        this.indexer.openSearcher();
+         assertNotNull(this.indexer.searcher);
+    }
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.openWriter()'
+     */
+    public void testOpenWriter() throws IOException {
+        this.indexer.closeWriter();
+        assertNull(this.indexer.writer);
+       this.indexer.openWriter();
+        assertNotNull(this.indexer.writer);
+    }
+
+
+    /*
+     * Test method for
+     * 'org.apache.lucene.gdata.search.index.GDataIndexer.destroy()'
+     */
+    public void testDestroy() throws InterruptedException, IOException {
+        this.indexer.destroy();
+        String id = "myID";
+        Field f = new Field(FIELD_ID, id, Field.Store.YES,
+                Field.Index.UN_TOKENIZED);
+        Document doc = new Document();
+        doc.add(f);
+        Term delTerm = new Term(FIELD_ID, id);
+        IndexDocument iDoc = new IndexDocumentStub(doc, delTerm,
+                IndexAction.INSERT);
+        Future<IndexDocument> future = new FutureStub<IndexDocument>(iDoc);
+        try{
+        this.indexer.addIndexableDocumentTask(future);
+        fail("indexer already closed exc. expected");
+        }catch (IllegalStateException e) {}
+        this.indexer = GDataIndexer.createGdataIndexer(config, dir, true);
+        CountDownLatch documentLatch = new CountDownLatch(1);
+        iDoc = new IndexDocumentStub(doc, delTerm,
+                IndexAction.INSERT,documentLatch);
+        
+        CountDownLatch latch = new CountDownLatch(1);
+        future = new FutureStub<IndexDocument>(iDoc,latch,true);
+        this.indexer.addIndexableDocumentTask(future);
+        this.indexer.destroy();
+        latch.countDown();
+        documentLatch.await(5000,TimeUnit.MILLISECONDS);
+        // wait active for the commit
+        while(this.indexer.writer != null){}
+        
+        IndexSearcher s = new IndexSearcher(this.dir);
+        Hits h = s.search(new TermQuery(delTerm));
+        assertEquals(1, h.length());
+        s.close();
+        
+        
+    }
+    
+    public void testInnerClassFuture() throws InterruptedException, ExecutionException, TimeoutException{
+        Future f = new GDataIndexer.FinishingFuture();
+        assertNull(f.get());
+        assertNull(f.get(0,TimeUnit.MICROSECONDS));
+        assertTrue(f.isDone());
+        assertFalse(f.isCancelled());
+        assertFalse(f.cancel(true));
+        
+    }
+
+   
+
+}

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

Propchange: lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/search/index/TestGdataIndexer.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message