Methods Summary |
---|
protected void | setUp()
this.logFile = new File(System.getProperty("java.io.tmpdir"),"log");
this.logFile.deleteOnExit();
this.logFile.createNewFile();
this.actions = new HashMap<String,IndexAction>();
|
protected void | tearDown()
super.tearDown();
this.logFile.delete();
|
public void | testReadIndexLog()
writeLog().close();
Map<String,IndexAction> readActionMap = new HashMap<String,IndexAction>();
IndexLogReader.readIndexLog(this.logFile,readActionMap);
Set<String> keySet = this.actions.keySet();
assertEquals(10,keySet.size());
for (String string : keySet) {
assertTrue(readActionMap.get(string).equals(actions.get(string)));
}
|
public void | testReadIndexLogFixLogFile()
writeLog();
Map<String,IndexAction> readActionMap = IndexLogReader.readIndexLog(this.logFile,null);
Set<String> keySet = this.actions.keySet();
assertEquals(10,keySet.size());
for (String string : keySet) {
assertTrue(readActionMap.get(string).equals(actions.get(string)));
}
|
public void | testReadIndexLogNoInputMap()
writeLog().close();
Map<String,IndexAction> readActionMap = IndexLogReader.readIndexLog(this.logFile,null);
Set<String> keySet = this.actions.keySet();
assertEquals(10,keySet.size());
for (String string : keySet) {
assertTrue(readActionMap.get(string).equals(actions.get(string)));
}
|
public void | testWriterClosed()
IndexLogWriter writer = writeLog();
writer.close();
try{
writer.writeAction(null,null);
fail("writer is closed");
}catch (IllegalStateException e) {
}
try{
writer.close();
fail("writer is closed");
}catch (IllegalStateException e) {
}
|
private IndexLogWriter | writeLog()
this.actions = new HashMap<String,IndexAction>();
IndexLogWriter writer = new IndexLogWriter(this.logFile);
boolean totwice = true;
for (int i = 0; i < 10; i++) {
IndexAction a = null;
if(i%3 ==0)
a= IndexAction.INSERT;
if(i%3 ==1)
a= IndexAction.UPDATE;
if(i%3 ==2)
a= IndexAction.DELETE;
this.actions.put(""+i,a);
writer.writeAction(""+i,a);
/*
* double action
*/
if(i == 9 && totwice){
i = 0;
totwice = false;
}
}
return writer;
|