You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kamal Ahmed <KA...@webMethods.com> on 2006/02/24 02:31:27 UTC

trying to run a modified version of http://svn.apache.org/repos/ asf/logging/log4j/trunk/tests/src/java/org/apache/log4j/rolling/ObsoleteD ailyRollingFileAppenderTest.java

Hi,

I am trying to run a refactored version of the subject test (see below)

In the method, assertTrue(postCount > preCount); fails, whereas I want it to
pass, since the number of files "Rolled" are greater than the initial file
count
Could it be file.length? that is the problem?.

Could anyone give me a clue why?

Thanks,

-Kamal.



public void testBasicRollingFunctionality() {

                   PatternLayout layout = new PatternLayout("%m%n");

                   wmDfa = new WmDailyFileAppender();

                   wmDfa.setName("KEEP_THE_PRICES_ROLLING");

                   wmDfa.setLayout(layout);

                   wmDfa.setAppend(false);

                   wmDfa.setFile("./log/BASICROLLINGAPPTEST.log");

                   wmDfa.setDatePattern("'.'yyyy-MM-dd-HH-mm");

                   logger.addAppender(wmDfa);

                   wmDfa.activateOptions();

                   int preCount = getFileCount("log",
"BASICROLLINGAPPENDERTEST.log.");

                   System.out.println("preCount : " + preCount);



                   for (int i = 0; i < 25; i++) {

                             try {

                                      Thread.sleep(10);

                             } catch (InterruptedException e) {

                                      // TODO Auto-generated catch block

                                      e.printStackTrace();

                             }

                             logger.debug("Hello---" + i);

                   }

                   int postCount = getFileCount("log",
"BASICROLLINGAPPENDERTEST.log.");

                   System.out.println("postCount : " + postCount);

                   assertTrue(postCount > preCount);

          }



          /**

           * Helper Method, getFileCount 

           */

          private int getFileCount(String dir, String initial) {

                   String[] files = new File(dir).list();

                   int count = 0;

                   for (int i = 0; i < files.length; i++) {

                             if (files[i].startsWith(initial)) {

                                      count++;

                             }

                   }

                   return count;

          }



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org