@Test public void testIsEnabled() throws Exception { JSchSlf4JLogger logger = new JSchSlf4JLogger(); assertFalse(logger.isEnabled(Logger.DEBUG)); assertFalse(logger.isEnabled(Logger.INFO)); assertTrue(logger.isEnabled(Logger.WARN)); assertTrue(logger.isEnabled(Logger.ERROR)); assertTrue(logger.isEnabled(Logger.FATAL)); try { logger.isEnabled(100); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertEquals("Unknown log level: 100", e.getMessage()); } }
@Test public void testLog() throws Exception { JSchSlf4JLogger logger = new JSchSlf4JLogger(); logger.log(Logger.DEBUG, "some debug message"); logger.log(Logger.INFO, "some info message"); logger.log(Logger.WARN, "some warning message"); logger.log(Logger.ERROR, "some error message"); logger.log(Logger.FATAL, "some fatal message"); try { logger.log(100, "some message"); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertEquals("Unknown log level: 100", e.getMessage()); } }
public static WebArchive webArchive() { return ShrinkWrap.create(WebArchive.class, "hs.war") .addPackage(User.class.getPackage()) .addPackage(Setup.class.getPackage()) .addPackage(OperatingSystem.class.getPackage()) .addPackage(VerificationStatus.class.getPackage()) .addPackage(Database.class.getPackage()) .addPackage(StartupTasks.class.getPackage()) .addPackage(Logger.class.getPackage()) .addPackage(VerificationEndpoint.class.getPackage()) .addClasses(Repository.class, DataBaseRepository.class, JaxRSConfig.class, Commands.class, DateUtilsImpl.class, VerificationExecutor.class, ThreadFactoryBuilder.class, DateUtils.class, Channel.class, Email.class, HrstatusSystem.class, RequestResponse.class, AbstractCommandExecutor.class, AbstractSystemImpl.class, AllowedCommands.class) .addAsResource("test-persistence.xml", "META-INF/persistence.xml") .addAsResource("test-version.properties", "version.properties") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); }
public void log(int level, String msg){ switch (level) { case Logger.INFO: vlog.info(msg); break; case Logger.ERROR: vlog.error(msg); break; default: vlog.debug(msg); } }