/** Get property or the default value - also set the default value if not present */ public String getOrSetDefault(String key, String expected) { String x = getProperty(key) ; if ( x == null ) { setProperty(key, expected) ; x = expected ; } return x ; }
public void addToMetaData(MetaFile mf) { mf.setProperty(ParamOrder, order) ; mf.setProperty(ParamKeyLength, recordFactory.keyLength()) ; mf.setProperty(ParamValueLength, recordFactory.valueLength()) ; mf.flush() ; }
/** Check property is an expected value or set if missing */ public void checkOrSetMetadata(String key, String expected) { String x = getProperty(key) ; if ( x == null ) { setProperty(key, expected) ; return ; } if ( x.equals(expected) ) return ; inconsistent(key, x, expected) ; }
@Test public void meta1() { clear() ; MetaFile f = new MetaFile("META", testfile) ; assertFalse(new File(testfileMeta).exists()) ; f.setProperty("key", "value") ; f.flush() ; assertTrue(new File(f.getFilename()).exists()) ; }
@Test public void meta1() { clear() ; MetaFile f = new MetaFile("META", testfile) ; assertFalse(new File(testfileMeta).exists()) ; f.setProperty("key", "value") ; f.flush() ; assertTrue(new File(f.getFilename()).exists()) ; }
@Test public void meta2() { clear() ; MetaFile f = new MetaFile("META", testfile) ; f.setProperty("test.value1", "1") ; f.flush(); MetaFile f2 = new MetaFile("META", testfile) ; assertEquals("1", f2.getProperty("test.value1")) ; assertNull(f2.getProperty("test.value.other")) ; }
@Test public void meta2() { clear() ; MetaFile f = new MetaFile("META", testfile) ; f.setProperty("test.value1", "1") ; f.flush(); MetaFile f2 = new MetaFile("META", testfile) ; assertEquals("1", f2.getProperty("test.value1")) ; assertNull(f2.getProperty("test.value.other")) ; }