Search in sources :

Example 16 with BaseFileReader

use of com.tvd12.properties.file.reader.BaseFileReader in project properties-file by tvd12.

the class YamlFileReaderTest method testDashKey.

@Test(expectedExceptions = YamlInvalidSyntaxException.class)
public void testDashKey() {
    BaseFileReader reader = new BaseFileReader();
    reader.read("invalid_yaml4.txt");
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Test(org.testng.annotations.Test)

Example 17 with BaseFileReader

use of com.tvd12.properties.file.reader.BaseFileReader in project properties-file by tvd12.

the class V112PropertiesUtilTest method readVariablePropertiesFile.

@Test
public void readVariablePropertiesFile() {
    // given
    Map<Object, Object> properties = new BaseFileReader().read("v112_application.properties");
    // when
    PropertiesUtil.setVariableValues(properties);
    // then
    Map<Object, Object> expectation = new HashMap<>();
    expectation.put("app.hello", "world");
    expectation.put("app.hi", "world");
    Asserts.assertEquals(expectation, properties, false);
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 18 with BaseFileReader

use of com.tvd12.properties.file.reader.BaseFileReader in project properties-file by tvd12.

the class V112PropertiesUtilTest method readVariableYamlFile.

@Test
public void readVariableYamlFile() {
    // given
    Map<Object, Object> properties = new BaseFileReader().read("v112_application.yaml");
    // when
    PropertiesUtil.setVariableValues(properties);
    // then
    Map<Object, Object> expectation = new HashMap<>();
    expectation.put("app.hello", "world");
    expectation.put("app.hi", "world");
    Asserts.assertEquals(expectation, properties, false);
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 19 with BaseFileReader

use of com.tvd12.properties.file.reader.BaseFileReader in project properties-file by tvd12.

the class YamlFileReaderTest method readTabs.

@Test
public void readTabs() {
    BaseFileReader reader = new BaseFileReader();
    Properties properties = reader.read("application2_yaml.txt");
    System.out.println(properties);
    assert properties.get("cors.allow_origin").equals("*");
    assert properties.get("cors.enable").equals("true");
    assert properties.get("server.port").equals("3005");
    assert properties.get("server.host").equals("0.0.0.0");
    assert properties.get("server.admin.User-Name1").equals("admin");
    assert properties.get("server.admin.password2").equals("123456");
    assert properties.get("hello").equals("world");
    assert properties.get("foo").equals("bar");
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 20 with BaseFileReader

use of com.tvd12.properties.file.reader.BaseFileReader in project properties-file by tvd12.

the class YamlFileReaderTest method testEmptyKey.

@Test(expectedExceptions = YamlInvalidSyntaxException.class)
public void testEmptyKey() {
    BaseFileReader reader = new BaseFileReader();
    reader.read("invalid_yaml2.txt");
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Test(org.testng.annotations.Test)

Aggregations

BaseFileReader (com.tvd12.properties.file.reader.BaseFileReader)28 Test (org.testng.annotations.Test)26 Properties (java.util.Properties)8 BaseTest (com.tvd12.test.base.BaseTest)6 File (java.io.File)5 HashMap (java.util.HashMap)5 InputStreamUtil (com.tvd12.properties.file.util.InputStreamUtil)2 InputStream (java.io.InputStream)2 Method (java.lang.reflect.Method)2 EzyFileUtil.getFileName (com.tvd12.ezyfox.util.EzyFileUtil.getFileName)1 ResourceFile (com.tvd12.ezyhttp.server.core.resources.ResourceFile)1 ResourceLoader (com.tvd12.ezyhttp.server.core.resources.ResourceLoader)1 PropertiesMapper (com.tvd12.properties.file.mapping.PropertiesMapper)1 FileReader (com.tvd12.properties.file.reader.FileReader)1 MultiFileReader (com.tvd12.properties.file.reader.MultiFileReader)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1