TestRecoverControllerpublic class TestRecoverController 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 RecoverController | writeController | private RecoverController | readController | private File | recDir | private String | feedId | private String | entryId |
Methods Summary |
---|
private void | createCorruptedFile()
File file = new File(this.recDir,"somefile.rec");
file.deleteOnExit();
FileWriter writer = new FileWriter(file);
writer.write("someString\nSomeOtherString");
writer.close();
| protected void | setUp()
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,true);
this.readController = new RecoverController(this.recDir,true,true);
| protected void | tearDown()
File[] files = this.recDir.listFiles();
for (int i = 0; i < files.length; i++) {
files[i].delete();
}
this.recDir.delete();
GDataServerRegistry.getRegistry().destroy();
| public void | testRecoverEntries()
testStorageModified();
int length = this.recDir.listFiles().length;
assertEquals(1,length);
this.readController.initialize();
try{
this.readController.recoverEntries(new StorageModifierStub(null,null,null,0,0));
}catch (Exception e) {
fail("unexpected exception"+e.getMessage());
}
this.readController.destroy();
assertEquals(1,this.recDir.listFiles().length);
createCorruptedFile();
this.readController.initialize();
try{
this.readController.recoverEntries(new StorageModifierStub(null,null,null,0,0));
}catch (Exception e) {
fail("unexpected exception"+e.getMessage());
}
this.readController.destroy();
assertEquals(2,this.recDir.listFiles().length);
| public void | testStorageModified()
this.writeController.initialize();
ServerBaseEntry entry = new ServerBaseEntry();
entry.setFeedId(this.feedId);
entry.setId(entryId);
entry.setUpdated(DateTime.now());
entry.setServiceConfig(new ProvidedServiceStub());
StorageEntryWrapper wrapper = new StorageEntryWrapper(entry,StorageOperation.INSERT);
this.writeController.storageModified(wrapper);
assertEquals(1,this.recDir.listFiles().length);
this.writeController.destroy();
|
|