1 22 package org.objectweb.petals.util; 23 24 import junit.framework.TestCase; 25 26 import org.easymock.classextension.EasyMock; 27 import org.objectweb.util.monolog.api.BasicLevel; 28 import org.objectweb.util.monolog.api.Logger; 29 30 34 public class LoggingUtilTest extends TestCase { 35 36 public void testError() { 37 RuntimeException runtimeException = new RuntimeException (); 38 Logger logger = EasyMock.createMock(Logger.class); 39 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 40 logger.log(BasicLevel.LEVEL_ERROR, "test logger", runtimeException); 41 42 EasyMock.replay(logger); 43 44 LoggingUtil loggingUtil = new LoggingUtil(logger); 45 loggingUtil.logger = logger; 46 loggingUtil.error("test logger", runtimeException); 47 } 48 49 public void testError1() { 50 Logger logger = EasyMock.createMock(Logger.class); 51 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 52 logger.log(BasicLevel.LEVEL_ERROR, "test logger"); 53 54 EasyMock.replay(logger); 55 56 LoggingUtil loggingUtil = new LoggingUtil(logger); 57 loggingUtil.error("test logger"); 58 } 59 60 public void testWarning() { 61 RuntimeException runtimeException = new RuntimeException (); 62 Logger logger = EasyMock.createMock(Logger.class); 63 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 64 logger.log(BasicLevel.LEVEL_WARN, "test logger", runtimeException); 65 66 EasyMock.replay(logger); 67 68 LoggingUtil loggingUtil = new LoggingUtil(logger); 69 loggingUtil.warning("test logger", runtimeException); 70 } 71 72 public void testWarning1() { 73 Logger logger = EasyMock.createMock(Logger.class); 74 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 75 logger.log(BasicLevel.LEVEL_WARN, "test logger"); 76 77 EasyMock.replay(logger); 78 79 LoggingUtil loggingUtil = new LoggingUtil(logger); 80 loggingUtil.warning("test logger"); 81 } 82 83 public void testInfo() { 84 RuntimeException runtimeException = new RuntimeException (); 85 Logger logger = EasyMock.createMock(Logger.class); 86 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 87 logger.log(BasicLevel.LEVEL_INFO, 88 "LoggingUtilTest.testInfo() test logger", runtimeException); 89 90 EasyMock.replay(logger); 91 92 LoggingUtil loggingUtil = new LoggingUtil(logger); 93 loggingUtil.info("test logger", runtimeException); 94 } 95 96 public void testInfo1() { 97 Logger logger = EasyMock.createMock(Logger.class); 98 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 99 logger.log(BasicLevel.LEVEL_INFO, 100 "LoggingUtilTest.testInfo1() test logger"); 101 102 EasyMock.replay(logger); 103 104 LoggingUtil loggingUtil = new LoggingUtil(logger); 105 loggingUtil.info("test logger"); 106 } 107 108 public void testDebug() { 109 Logger logger = EasyMock.createMock(Logger.class); 110 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 111 logger.log(BasicLevel.LEVEL_DEBUG, 112 "LoggingUtilTest.testDebug() test logger"); 113 114 EasyMock.replay(logger); 115 116 LoggingUtil loggingUtil = new LoggingUtil(logger); 117 loggingUtil.debug("test logger"); 118 } 119 120 public void testStart() { 121 Logger logger = EasyMock.createMock(Logger.class); 122 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 123 logger.log(BasicLevel.LEVEL_DEBUG, 124 "-START- LoggingUtilTest.testStart() test logger"); 125 126 EasyMock.replay(logger); 127 128 LoggingUtil loggingUtil = new LoggingUtil(logger); 129 loggingUtil.start("test logger"); 130 } 131 132 public void testStart1() { 133 Logger logger = EasyMock.createMock(Logger.class); 134 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 135 logger.log(BasicLevel.LEVEL_DEBUG, 136 "-START- LoggingUtilTest.testStart1()"); 137 138 EasyMock.replay(logger); 139 140 LoggingUtil loggingUtil = new LoggingUtil(logger); 141 loggingUtil.start(); 142 } 143 144 public void testEnd() { 145 Logger logger = EasyMock.createMock(Logger.class); 146 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 147 logger.log(BasicLevel.LEVEL_DEBUG, 148 "- END - LoggingUtilTest.testEnd() test logger"); 149 150 EasyMock.replay(logger); 151 152 LoggingUtil loggingUtil = new LoggingUtil(logger); 153 loggingUtil.end("test logger"); 154 } 155 156 public void testEnd1() { 157 Logger logger = EasyMock.createMock(Logger.class); 158 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 159 logger 160 .log(BasicLevel.LEVEL_DEBUG, "- END - LoggingUtilTest.testEnd1()"); 161 162 EasyMock.replay(logger); 163 164 LoggingUtil loggingUtil = new LoggingUtil(logger); 165 loggingUtil.end(); 166 } 167 168 public void testCall() { 169 Logger logger = EasyMock.createMock(Logger.class); 170 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 171 logger 172 .log(BasicLevel.LEVEL_DEBUG, "-CALL - LoggingUtilTest.testCall()"); 173 174 EasyMock.replay(logger); 175 176 LoggingUtil loggingUtil = new LoggingUtil(logger); 177 loggingUtil.call(); 178 } 179 180 public void testCall1() { 181 Logger logger = EasyMock.createMock(Logger.class); 182 EasyMock.expect(logger.isOn()).andReturn(true).anyTimes(); 183 logger.log(BasicLevel.LEVEL_DEBUG, 184 "-CALL - LoggingUtilTest.testCall1() test logger"); 185 186 EasyMock.replay(logger); 187 188 LoggingUtil loggingUtil = new LoggingUtil(logger); 189 loggingUtil.call("test logger"); 190 } 191 192 public void testGetName() { 193 Logger logger = EasyMock.createMock(Logger.class); 194 195 EasyMock.expect(logger.getName()).andReturn("name"); 196 197 EasyMock.replay(logger); 198 LoggingUtil loggingUtil = new LoggingUtil(logger); 199 assertEquals(loggingUtil.getName(), "name"); 200 } 201 202 } 203 | Popular Tags |