FileDocCategorySizeDatePackage
TestRevocerReader.javaAPI DocApache Lucene 2.1.04583Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.storage.lucenestorage.recover

TestRevocerReader

public class TestRevocerReader extends TestCase
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.

Fields Summary
private RecoverReader
recReader
private static final String
feedId
private static final String
entryId
private static final Long
timestamp
private String
title
private static final com.google.gdata.data.DateTime
dateTime
private String
delete
private String
insert
Constructors Summary
Methods Summary
protected voidsetUp()

         
        this.recReader = new RecoverReader();
        GDataServerRegistry.getRegistry().registerService(new ProvidedServiceStub());
        
    
protected voidtearDown()

        super.tearDown();
    
public voidtestRecoverDeletedEntries()

        StringReader reader = new StringReader(this.delete);
        assertNotNull(this.recReader.recoverEntries(new BufferedReader(reader)));
        reader = new StringReader(this.delete);
        List<StorageEntryWrapper> recList = this.recReader.recoverEntries(new BufferedReader(reader));
        assertEquals(1,recList.size());
        StorageEntryWrapper delWrapper = recList.get(0);
        assertEquals(StorageOperation.DELETE,delWrapper.getOperation());
        assertEquals(feedId,delWrapper.getFeedId());
        assertEquals(entryId,delWrapper.getEntryId());
        
    
public voidtestRecoverInsertedEntries()

        
        StringReader reader = new StringReader(this.insert);
        List<StorageEntryWrapper> recList = this.recReader.recoverEntries(new BufferedReader(reader));
        assertEquals(1,recList.size());
        StorageEntryWrapper insWrapper = recList.get(0);
        assertEquals(StorageOperation.INSERT,insWrapper.getOperation());
        assertEquals(feedId,insWrapper.getFeedId());
        assertEquals(entryId,insWrapper.getEntryId());
        assertEquals(dateTime,insWrapper.getEntry().getUpdated());
        assertEquals(this.title,insWrapper.getEntry().getTitle().getPlainText());
        
        
    
public voidtestRecoverReader()

        StringReader reader = new StringReader(this.insert+this.delete);
        List<StorageEntryWrapper> recList = this.recReader.recoverEntries(new BufferedReader(reader));
        assertEquals(2,recList.size());
        assertEquals(StorageOperation.INSERT,recList.get(0).getOperation());
        assertEquals(StorageOperation.DELETE,recList.get(1).getOperation());
        
        reader = new StringReader("some corrupted\n###########\n"+this.insert);
        recList = this.recReader.recoverEntries(new BufferedReader(reader));
        assertEquals(1,recList.size());
        assertEquals(StorageOperation.INSERT,recList.get(0).getOperation());