Skip to content
Snippets Groups Projects
Commit c683b4d9 authored by ribeaudc's avatar ribeaudc
Browse files

[DMV-15] change: - Remove dots from properties.

- Allow properties to be overwritten by command line parameters.
add: - More Unit tests.

SVN: 6310
parent a6cae2d7
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.utilities.PropertyUtils; ...@@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.utilities.PropertyUtils;
public final class FileWithHighwaterMark extends AbstractHashable implements Serializable public final class FileWithHighwaterMark extends AbstractHashable implements Serializable
{ {
static final String SEP = "-";
public static final int DEFAULT_HIGHWATER_MARK = -1; public static final int DEFAULT_HIGHWATER_MARK = -1;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -82,7 +84,7 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser ...@@ -82,7 +84,7 @@ public final class FileWithHighwaterMark extends AbstractHashable implements Ser
assert StringUtils.isNotBlank(filePropertyKey) : "File property key is blank"; assert StringUtils.isNotBlank(filePropertyKey) : "File property key is blank";
final String filePath = PropertyUtils.getMandatoryProperty(properties, filePropertyKey); final String filePath = PropertyUtils.getMandatoryProperty(properties, filePropertyKey);
final long highwaterMarkInKb = final long highwaterMarkInKb =
PropertyUtils.getLong(properties, filePropertyKey.concat(".").concat( PropertyUtils.getLong(properties, filePropertyKey.concat(SEP).concat(
HIGHWATER_MARK_PROPERTY_KEY), -1L); HIGHWATER_MARK_PROPERTY_KEY), -1L);
return new FileWithHighwaterMark(new File(filePath), highwaterMarkInKb); return new FileWithHighwaterMark(new File(filePath), highwaterMarkInKb);
} }
......
...@@ -64,13 +64,13 @@ public final class FileWithHighwaterMarkTest ...@@ -64,13 +64,13 @@ public final class FileWithHighwaterMarkTest
assertEquals(new File(path), fileWithHighwaterMark.getFile()); assertEquals(new File(path), fileWithHighwaterMark.getFile());
assertEquals(-1, fileWithHighwaterMark.getHighwaterMark()); assertEquals(-1, fileWithHighwaterMark.getHighwaterMark());
// 100Kb // 100Kb
properties.setProperty(filePropertyKey + "." properties.setProperty(filePropertyKey + FileWithHighwaterMark.SEP
+ FileWithHighwaterMark.HIGHWATER_MARK_PROPERTY_KEY, "100"); + FileWithHighwaterMark.HIGHWATER_MARK_PROPERTY_KEY, "100");
fileWithHighwaterMark = FileWithHighwaterMark.fromProperties(properties, filePropertyKey); fileWithHighwaterMark = FileWithHighwaterMark.fromProperties(properties, filePropertyKey);
assertEquals(new File(path), fileWithHighwaterMark.getFile()); assertEquals(new File(path), fileWithHighwaterMark.getFile());
assertEquals(100, fileWithHighwaterMark.getHighwaterMark()); assertEquals(100, fileWithHighwaterMark.getHighwaterMark());
// Meaningless value // Meaningless value
properties.setProperty(filePropertyKey + "." properties.setProperty(filePropertyKey + FileWithHighwaterMark.SEP
+ FileWithHighwaterMark.HIGHWATER_MARK_PROPERTY_KEY, "notANumber"); + FileWithHighwaterMark.HIGHWATER_MARK_PROPERTY_KEY, "notANumber");
fileWithHighwaterMark = FileWithHighwaterMark.fromProperties(properties, filePropertyKey); fileWithHighwaterMark = FileWithHighwaterMark.fromProperties(properties, filePropertyKey);
assertEquals(new File(path), fileWithHighwaterMark.getFile()); assertEquals(new File(path), fileWithHighwaterMark.getFile());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment