()
| 133 | } |
| 134 | |
| 135 | @Test |
| 136 | public void testlog4jConf() throws Exception { |
| 137 | Properties properties = Main.log4jConfAsProperties(null); |
| 138 | assertTrue(properties.isEmpty()); |
| 139 | properties = Main.log4jConfAsProperties(""); |
| 140 | assertTrue(properties.isEmpty()); |
| 141 | // Test for non-existent file |
| 142 | properties = Main.log4jConfAsProperties("non-existing-" + System.currentTimeMillis()); |
| 143 | assertTrue(properties.isEmpty()); |
| 144 | |
| 145 | // Create tmp file in under build/test/classes |
| 146 | File tmpFile = File.createTempFile("pig-log4jconf", ".properties", new File("build/test/classes")); |
| 147 | tmpFile.deleteOnExit(); |
| 148 | Files.write("A=B", tmpFile, Charset.forName("UTF-8")); |
| 149 | // Read it as a resource |
| 150 | properties = Main.log4jConfAsProperties(tmpFile.getName()); |
| 151 | assertEquals("B", properties.getProperty("A")); |
| 152 | // Read it as a file |
| 153 | properties = Main.log4jConfAsProperties(tmpFile.getAbsolutePath()); |
| 154 | assertEquals("B", properties.getProperty("A")); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | @Test |
nothing calls this directly
no test coverage detected