Merge pull request #5875 from amit2103/BAEL-9643
[BAEL-9643] - Added missing code in the properties article
This commit is contained in:
commit
5aff05828b
@ -7,6 +7,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -143,4 +144,28 @@ public class PropertiesUnitTest {
|
|||||||
assertEquals("TestApp", appName);
|
assertEquals("TestApp", appName);
|
||||||
assertEquals("www.google.com", defaultSite);
|
assertEquals("www.google.com", defaultSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenPropertiesSize_whenPropertyFileLoaded_thenCorrect() throws IOException {
|
||||||
|
|
||||||
|
String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
|
||||||
|
String appPropsPath = rootPath + "app.properties";
|
||||||
|
Properties appProps = new Properties();
|
||||||
|
appProps.load(new FileInputStream(appPropsPath));
|
||||||
|
|
||||||
|
appProps.list(System.out); // list all key-value pairs
|
||||||
|
|
||||||
|
Enumeration<Object> valueEnumeration = appProps.elements();
|
||||||
|
while (valueEnumeration.hasMoreElements()) {
|
||||||
|
System.out.println(valueEnumeration.nextElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
Enumeration<Object> keyEnumeration = appProps.keys();
|
||||||
|
while (keyEnumeration.hasMoreElements()) {
|
||||||
|
System.out.println(keyEnumeration.nextElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = appProps.size();
|
||||||
|
assertEquals(3, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user