package de.superx.util; import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.junit.Assert; import org.junit.Test; public class TrashMapTest { private static String KEY = "MAN_DEFAULT_REPORT"; /** * @author Witt * this test tests the 'TrashMap' class, which is a child of 'HashMap', that writes manipulations of the entry defined in 'KEY' to the log; * originally written for error analysis of the 'sx_repository' server cache in 'SxPool' */ @Test public void testTrashMapLog() { Logger logger = Logger.getLogger(TrashMap.class); logger.setAdditivity(false); logger.removeAllAppenders(); UnittestAppender ta = new UnittestAppender(); logger.addAppender(ta); Map ht = new HashMap(); ht.put("hallo", "welt"); TrashMap tm = new TrashMap(ht); tm.put("bla", "blub"); tm.put(KEY, "INTERN"); tm.put(KEY, "INTERN"); tm.put(KEY, "INTERN1"); tm.clear(); tm.put(KEY, null); tm.remove(KEY); tm.clear(); Assert.assertEquals("unexpected count of log events", 10, ta.loggingEventList.size()); } }