"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

XmlFileAppenderTest.java  (apache-log4j-2.11.1-src):XmlFileAppenderTest.java  (apache-log4j-2.11.2-src)
skipping to change at line 19 skipping to change at line 19
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the license for the specific language governing permissions and * See the license for the specific language governing permissions and
* limitations under the license. * limitations under the license.
*/ */
package org.apache.logging.log4j.core.appender; package org.apache.logging.log4j.core.appender;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.List; import java.util.List;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.categories.Layouts; import org.apache.logging.log4j.categories.Layouts;
import org.apache.logging.log4j.core.CoreLoggerContexts; import org.apache.logging.log4j.core.CoreLoggerContexts;
import org.apache.logging.log4j.core.config.ConfigurationFactory; import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.junit.BeforeClass; import org.junit.BeforeClass;
skipping to change at line 59 skipping to change at line 57
@Test @Test
public void testFlushAtEndOfBatch() throws Exception { public void testFlushAtEndOfBatch() throws Exception {
final File file = new File("target", "XmlFileAppenderTest.log"); final File file = new File("target", "XmlFileAppenderTest.log");
// System.out.println(f.getAbsolutePath()); // System.out.println(f.getAbsolutePath());
file.delete(); file.delete();
final Logger log = LogManager.getLogger("com.foo.Bar"); final Logger log = LogManager.getLogger("com.foo.Bar");
final String logMsg = "Message flushed with immediate flush=false"; final String logMsg = "Message flushed with immediate flush=false";
log.info(logMsg); log.info(logMsg);
CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread
List<String> lines = Files.readAllLines(file.toPath(), Charset.forName(" UTF8")); final List<String> lines = Files.readAllLines(file.toPath(), Charset.for Name("UTF8"));
file.delete(); file.delete();
String[] expect = { final String[] expect = {
"", // ? unsure why initial empty line... "", // ? unsure why initial empty line...
"<Event ", // "<Event ", //
"<Instant epochSecond=", // "<Instant epochSecond=", //
logMsg, // logMsg, //
"</Event>", // "</Event>", //
}; };
for (int i = 0; i < expect.length; i++) { for (int i = 0; i < expect.length; i++) {
assertTrue("Expected line " + i + " to contain " + expect[i] + " but got: " + lines.get(i), assertTrue("Expected line " + i + " to contain " + expect[i] + " but got: " + lines.get(i),
lines.get(i).contains(expect[i])); lines.get(i).contains(expect[i]));
 End of changes. 4 change blocks. 
4 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)