[logback-dev] svn commit: r1951 - in logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic: . control

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu Nov 6 19:15:37 CET 2008


Author: ceki
Date: Thu Nov  6 19:15:37 2008
New Revision: 1951

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java
Removed:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/TestScenario.java
Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ScenarioBasedLoggerContextTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java

Log:
Renaming TestScenario as Scenario because it is not a test.


Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ScenarioBasedLoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ScenarioBasedLoggerContextTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ScenarioBasedLoggerContextTest.java	Thu Nov  6 19:15:37 2008
@@ -24,7 +24,7 @@
 import ch.qos.logback.classic.control.ScenarioAction;
 import ch.qos.logback.classic.control.ScenarioMaker;
 import ch.qos.logback.classic.control.SetLevel;
-import ch.qos.logback.classic.control.TestScenario;
+import ch.qos.logback.classic.control.Scenario;
 
 
 public class ScenarioBasedLoggerContextTest  {
@@ -55,7 +55,7 @@
   private void doScenarioedTest(int len) {
     LoggerContext lc = new LoggerContext();
     ControlLoggerContext controlContext = new ControlLoggerContext();
-    TestScenario s = ScenarioMaker.makeRealisticCreationScenario(len);
+    Scenario s = ScenarioMaker.makeRealisticCreationScenario(len);
     List actionList = s.getActionList();
     int size = actionList.size();
     for (int i = 0; i < size; i++) {

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java	Thu Nov  6 19:15:37 2008
@@ -0,0 +1,35 @@
+/** 
+ * LOGBack: the reliable, fast and flexible logging library for Java.
+ *
+ * Copyright (C) 1999-2005, QOS.ch, LOGBack.com
+ *
+ * This library is free software, you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.classic.control;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+
+public class Scenario {
+
+  private List<ScenarioAction> actionList = new Vector<ScenarioAction>();
+
+  public void add(ScenarioAction action) {
+    actionList.add(action);
+  }
+
+  public List<ScenarioAction> getActionList() {
+    return new ArrayList<ScenarioAction>(actionList);
+  }
+
+  public int size() {
+    return actionList.size();
+  }
+
+  public ScenarioAction get(int i) {
+    return (ScenarioAction) actionList.get(i);
+  }
+}

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMaker.java	Thu Nov  6 19:15:37 2008
@@ -21,8 +21,9 @@
   // the frequency of a set levelInt event for every create logger event
   private final static int CREATE_LOGGER_TO_SET_LEVEL_FREQUENCY = 5;
   private final static int SECOND_SET_LEVEL_FREQUENCY = 3;
-  
-  
+
+  private static long count = 0;
+
   /**
    * Makes a scenario with len logger creations. Logger names are generated
    * independently such that the overwhelming majority of logger names will be
@@ -32,19 +33,19 @@
    * @param len
    * @return
    */
-  static public TestScenario makeTypeAScenario(int len) {
-    TestScenario scenario = new TestScenario();
+  static public Scenario makeTypeAScenario(int len) {
+    Scenario scenario = new Scenario();
     ;
     for (int i = 0; i < len; i++) {
-      String loggerName = ScenarioRandomUtil.randomLoggerName(AVERAGE_LOGGER_DEPTH,
-          LOGGER_DEPT_DEV);
+      String loggerName = ScenarioRandomUtil.randomLoggerName(
+          AVERAGE_LOGGER_DEPTH, LOGGER_DEPT_DEV);
       scenario.add(new CreateLogger(loggerName));
     }
     return scenario;
   }
 
-  static public TestScenario makeRealisticCreationScenario(int len) {
-    TestScenario scenario = new TestScenario();
+  static public Scenario makeRealisticCreationScenario(int len) {
+    Scenario scenario = new Scenario();
     LinkedList<String> queue = new LinkedList<String>();
     int loggerCreationCount = 0;
 
@@ -52,9 +53,14 @@
     queue.add("");
 
     while (loggerCreationCount < len) {
+      if ((count % 100) == 0) {
+        System.out.println("count=" + count);
+      }
+
       String loggerName = (String) queue.removeFirst();
-      int randomChildrenCount = ScenarioRandomUtil.randomChildrenCount(loggerName);
-     
+      int randomChildrenCount = ScenarioRandomUtil
+          .randomChildrenCount(loggerName);
+
       if (randomChildrenCount == 0) {
         scenario.add(new CreateLogger(loggerName));
         addSetLevelSubScenario(scenario, loggerName);
@@ -64,9 +70,11 @@
           String childName;
           if (loggerName.equals("")) {
             childName = ScenarioRandomUtil.randomId();
+            count += childName.length();
           } else {
             childName = loggerName + ClassicGlobal.LOGGER_SEPARATOR
                 + ScenarioRandomUtil.randomId();
+            count += childName.length();
           }
           queue.add(childName);
           addSetLevelSubScenario(scenario, loggerName);
@@ -76,17 +84,16 @@
     }
     return scenario;
   }
-  
-  static void addSetLevelSubScenario(TestScenario scenario, String loggerName) {
-    if(ScenarioRandomUtil.oneInFreq(CREATE_LOGGER_TO_SET_LEVEL_FREQUENCY)) {
+
+  static void addSetLevelSubScenario(Scenario scenario, String loggerName) {
+    if (ScenarioRandomUtil.oneInFreq(CREATE_LOGGER_TO_SET_LEVEL_FREQUENCY)) {
       Level l = ScenarioRandomUtil.randomLevel();
       scenario.add(new SetLevel(l, loggerName));
-      if(ScenarioRandomUtil.oneInFreq(SECOND_SET_LEVEL_FREQUENCY)) {
+      if (ScenarioRandomUtil.oneInFreq(SECOND_SET_LEVEL_FREQUENCY)) {
         l = ScenarioRandomUtil.randomLevel();
         scenario.add(new SetLevel(l, loggerName));
       }
     }
   }
-  
-  
+
 }
\ No newline at end of file


More information about the logback-dev mailing list