move properties based settings loader out of the way
This commit is contained in:
parent
abe8e4adf8
commit
7b220eac39
7 changed files with 26 additions and 7 deletions
|
@ -53,7 +53,7 @@ public class PropertiesSettingsLoader implements SettingsLoader {
|
|||
|
||||
@Override
|
||||
public boolean canLoad(String source) {
|
||||
return true;
|
||||
return source != null && source.charAt(0) == '#';
|
||||
}
|
||||
|
||||
public Map<String, String> load(BytesReference ref) throws IOException {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
org.xbib.settings.content.PropertiesSettingsLoader
|
|
@ -143,9 +143,17 @@ public class SettingsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesLoader() {
|
||||
public void testPropertiesLoaderFromResource() {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
.loadFromResource(".properties", new ByteArrayInputStream("a.b=c".getBytes(StandardCharsets.UTF_8)))
|
||||
.loadFromResource("properties", new ByteArrayInputStream("a.b=c".getBytes(StandardCharsets.UTF_8)))
|
||||
.build();
|
||||
assertEquals("{a.b=c}", settings.getAsMap().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesLoaderFromString() {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
.loadFromString("#\na.b=c")
|
||||
.build();
|
||||
assertEquals("{a.b=c}", settings.getAsMap().toString());
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
org.xbib.settings.content.PropertiesSettingsLoader
|
|
@ -1,6 +1,10 @@
|
|||
package org.xbib.settings.datastructures.json.test;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.datastructures.json.tiny.JsonBuilder;
|
||||
import org.xbib.settings.Settings;
|
||||
import org.xbib.settings.SettingsLoader;
|
||||
import org.xbib.settings.datastructures.json.JsonSettingsLoader;
|
||||
|
|
|
@ -44,6 +44,6 @@ public class PropertiesSettingsLoader implements SettingsLoader {
|
|||
|
||||
@Override
|
||||
public boolean canLoad(String source) {
|
||||
return true;
|
||||
return source != null && source.charAt(0) == '#';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,11 +116,18 @@ public class SettingsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesLoader() {
|
||||
public void testPropertiesLoaderFromResource() {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
.loadFromResource(".properties", new ByteArrayInputStream("a.b=c".getBytes(StandardCharsets.UTF_8)))
|
||||
.loadFromResource("properties", new ByteArrayInputStream("a.b=c".getBytes(StandardCharsets.UTF_8)))
|
||||
.build();
|
||||
assertEquals("{a.b=c}", settings.getAsMap().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesLoaderFromString() {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
.loadFromString("#\na.b=c")
|
||||
.build();
|
||||
assertEquals("{a.b=c}", settings.getAsMap().toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue