Search in sources :

Example 21 with BaseFileReader

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

the class YamlFileReaderTest method testInvalidKey.

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

Example 22 with BaseFileReader

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

the class YamlFileReaderTest method readSpaces.

@Test
public void readSpaces() {
    BaseFileReader reader = new BaseFileReader();
    Properties properties = reader.read("application.yaml");
    System.out.println(properties);
    assert properties.get("include.profiles").equals("local,alpha");
    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.username").equals("admin");
    assert properties.get("server.admin.password").equals("123456");
    assert properties.get("hello").equals("world");
    assert properties.get("foo").equals("bar");
    properties = reader.read("hello_yaml");
    assert properties.get("hello").equals("world");
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 23 with BaseFileReader

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

the class YamlFileReaderTest method readInvalidYamlFileLastPropertyKeyIsNull.

@Test
public void readInvalidYamlFileLastPropertyKeyIsNull() {
    // given
    BaseFileReader sut = new BaseFileReader();
    // when
    Throwable e = Asserts.assertThrows(() -> sut.read("v112_application_invalid.yaml"));
    // then
    Asserts.assertEquals(YamlInvalidSyntaxException.class, e.getClass());
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Test(org.testng.annotations.Test)

Example 24 with BaseFileReader

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

the class YamlFileReaderTest method testInvalidSpaces.

@Test
public void testInvalidSpaces() {
    BaseFileReader reader = new BaseFileReader();
    Properties properties = reader.read("invalid_yaml3.txt");
    System.out.println("testInvalidSpaces: " + properties);
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 25 with BaseFileReader

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

the class YamlFileReaderTest method readInvalidYamlFileLastSpaceCountEqualsLastSpaceCount.

@Test
public void readInvalidYamlFileLastSpaceCountEqualsLastSpaceCount() {
    // given
    BaseFileReader sut = new BaseFileReader();
    // when
    Throwable e = Asserts.assertThrows(() -> sut.read("v112_application_invalid2.yaml"));
    // then
    Asserts.assertEquals(YamlInvalidSyntaxException.class, e.getClass());
}
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