Search in sources :

Example 1 with BaseFileReader

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

the class PropertiesFileReaderTest method loadInputStreamTest.

@SuppressWarnings("unchecked")
@Test(expectedExceptions = { PropertiesFileException.class })
public void loadInputStreamTest() throws PropertiesFileException, IOException {
    InputStream stream = mock(InputStream.class);
    when(stream.read()).thenThrow(IOException.class);
    new BaseFileReader().loadInputStream(stream);
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) InputStream(java.io.InputStream) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 2 with BaseFileReader

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

the class PropertiesFileReaderTest method testWithValidData2.

@Test
public void testWithValidData2() throws PropertiesFileException {
    File file = new File(getClass().getClassLoader().getResource("classes.properties").getFile());
    assertNotNull(new BaseFileReader().read(Lists.newArrayList(file, file)));
    assertNotNull(new BaseFileReader().read(Lists.newArrayList(file, file)));
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) File(java.io.File) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 3 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 4 with BaseFileReader

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

the class PropertiesFileReaderTest method loadInputStreamTest.

@SuppressWarnings("unchecked")
@Test(expectedExceptions = { PropertiesFileException.class })
public void loadInputStreamTest() throws PropertiesFileException, IOException {
    InputStream stream = mock(InputStream.class);
    when(stream.read()).thenThrow(IOException.class);
    new BaseFileReader().loadInputStream(stream);
}
Also used : BaseFileReader(com.tvd12.properties.file.reader.BaseFileReader) InputStream(java.io.InputStream) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 5 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)

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