コード例 #1
0
  private void doScenarioedTest(int len) {
    LoggerContext lc = new LoggerContext();
    ControlLoggerContext controlContext = new ControlLoggerContext();
    Scenario s = ScenarioMaker.makeRealisticCreationScenario(len);
    List actionList = s.getActionList();
    int size = actionList.size();
    for (int i = 0; i < size; i++) {
      ScenarioAction action = (ScenarioAction) actionList.get(i);
      if (action instanceof CreateLogger) {
        CreateLogger cl = (CreateLogger) action;
        lc.getLogger(cl.getLoggerName());
        controlContext.getLogger(cl.getLoggerName());
      } else if (action instanceof SetLevel) {
        SetLevel sl = (SetLevel) action;
        Logger l = lc.getLogger(sl.getLoggerName());
        ControlLogger controlLogger = controlContext.getLogger(sl.getLoggerName());
        l.setLevel(sl.getLevel());
        controlLogger.setLevel(sl.getLevel());
      }
    }

    compareLoggerContexts(controlContext, lc);
  }
コード例 #2
0
  void compareLoggerContexts(ControlLoggerContext controlLC, LoggerContext lc) {
    Map<String, ControlLogger> controlLoggerMap = controlLC.getLoggerMap();

    assertEquals(controlLoggerMap.size() + 1, lc.size());

    for (String loggerName : controlLoggerMap.keySet()) {

      Logger logger = lc.exists(loggerName);
      ControlLogger controlLogger = (ControlLogger) controlLoggerMap.get(loggerName);
      if (logger == null) {
        throw new IllegalStateException("logger" + loggerName + " should exist");
      }
      assertEquals(loggerName, logger.getName());
      assertEquals(loggerName, controlLogger.getName());

      compareLoggers(controlLogger, logger);
    }
  }