FileDocCategorySizeDatePackage
TestIndexSchemaField.javaAPI DocApache Lucene 2.1.05256Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.search.config

TestIndexSchemaField

public class TestIndexSchemaField extends TestCase
author
Simon Willnauer

Fields Summary
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
    
protected voidtearDown()

        super.tearDown();
    
public voidtestCheckRequieredValues()

        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 voidtestSetFieldType()

        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) {
            
        }
        
    
public voidtestSetIndexByName()

        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 voidtestSetStoreByName()

        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());
        
        
    
public voidtestSetType()

        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());
    
public voidtestSetboost()

        IndexSchemaField f = new IndexSchemaField();
        f.setBoost(-0.1f);
        assertEquals(1.0f,f.getBoost());
        f.setBoost(2.50f);
        assertEquals(2.50f,f.getBoost());
    
public voidtestToSTringNoNullPEx()

        assertNotNull(new IndexSchemaField().toString());