"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/test/java/org/apache/logging/log4j/core/CustomLevelsTest.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).

CustomLevelsTest.java  (apache-log4j-2.11.1-src):CustomLevelsTest.java  (apache-log4j-2.11.2-src)
skipping to change at line 24 skipping to change at line 24
* 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; package org.apache.logging.log4j.core;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import java.util.List;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.junit.LoggerContextRule; import org.apache.logging.log4j.junit.LoggerContextRule;
import org.apache.logging.log4j.test.appender.ListAppender; import org.apache.logging.log4j.test.appender.ListAppender;
import org.junit.Before; import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
/**
*
*/
public class CustomLevelsTest { public class CustomLevelsTest {
private static final String CONFIG = "log4j-customLevels.xml"; private static final String CONFIG = "log4j-customLevels.xml";
@ClassRule @ClassRule
public static LoggerContextRule context = new LoggerContextRule(CONFIG); public static LoggerContextRule context = new LoggerContextRule(CONFIG);
private ListAppender listAppender; private ListAppender listAppender;
private Level diagLevel; private Level diagLevel;
private Level noticeLevel; private Level noticeLevel;
skipping to change at line 73 skipping to change at line 68
@Test @Test
public void testCustomLevelPresence() { public void testCustomLevelPresence() {
assertNotNull(diagLevel); assertNotNull(diagLevel);
assertNotNull(noticeLevel); assertNotNull(noticeLevel);
assertNotNull(verboseLevel); assertNotNull(verboseLevel);
} }
@Test @Test
public void testLog() { public void testLog() {
final Logger logger = context.getLogger(); final Logger logger = context.getLogger();
final List<LogEvent> events = listAppender.getEvents(); assertThat(listAppender.getEvents(), hasSize(0));
assertThat(events, hasSize(0));
logger.debug("Hello, {}", "World"); logger.debug("Hello, {}", "World");
assertThat(events, hasSize(1)); assertThat(listAppender.getEvents(), hasSize(1));
logger.log(diagLevel, "Hello DIAG"); logger.log(diagLevel, "Hello DIAG");
assertThat(events, hasSize(2)); assertThat(listAppender.getEvents(), hasSize(2));
assertEquals(events.get(1).getLevel(), diagLevel); assertEquals(listAppender.getEvents().get(1).getLevel(), diagLevel);
} }
} }
 End of changes. 5 change blocks. 
10 lines changed or deleted 4 lines changed or added

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