commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prick...@apache.org
Subject cvs commit: jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/junit TestWithMavenLogging.java
Date Thu, 24 Oct 2002 05:03:14 GMT
prickett    2002/10/23 22:03:14

  Modified:    periodicity/src/plugins-build/database project.xml
               periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/junit
                        TestWithMavenLogging.java
  Log:
  Added a dependency to log4j version 1.2.6
  
  Filled in the code for the setLogger method in TestWithMavenLogging
  
  Added a getLogger to TestWithMavenLogging
  
  Revision  Changes    Path
  1.10      +4 -0      jakarta-commons-sandbox/periodicity/src/plugins-build/database/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/project.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- project.xml	23 Oct 2002 00:08:54 -0000	1.9
  +++ project.xml	24 Oct 2002 05:03:14 -0000	1.10
  @@ -57,6 +57,10 @@
         <id>commons-configuration</id>
         <version>1.0-dev</version>
       </dependency>  
  +    <dependency>
  +      <id>log4j</id>
  +      <version>1.2.6</version>
  +    </dependency>  
     </dependencies>  
   
     <build>
  
  
  
  1.2       +36 -4     jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/junit/TestWithMavenLogging.java
  
  Index: TestWithMavenLogging.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/junit/TestWithMavenLogging.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestWithMavenLogging.java	24 Oct 2002 03:24:16 -0000	1.1
  +++ TestWithMavenLogging.java	24 Oct 2002 05:03:14 -0000	1.2
  @@ -65,6 +65,9 @@
   
   import java.io.File;
   import junit.framework.TestCase;
  +import org.apache.log4j.FileAppender;
  +import org.apache.log4j.SimpleLayout;
  +import org.apache.log4j.Logger;
   
   public class TestWithMavenLogging extends TestCase
   {
  @@ -78,6 +81,8 @@
   
       public static final String TEST_LOG_EXTENSION = ".log";
   
  +    private Logger logger = null;
  +
       public TestWithMavenLogging(String name)
       {
           super(name);
  @@ -156,8 +161,35 @@
           }    
       }
   
  -    private void setLogger(String logFileName)
  +    protected Logger getLogger()
  +    {
  +        return logger;
  +    }    
  +
  +    private void setLogger(String logFileName) throws Exception
       {
  +        if(logFileName != null)
  +        {
  +            FileAppender logFileAppender = 
  +                   new FileAppender(new SimpleLayout(), logFileName, false);
  +            if(Logger.getRootLogger() != null)
  +            {
  +                logger = Logger.getRootLogger();
  +                logger.addAppender(logFileAppender);
  +            }
  +            else
  +            {
  +                throw new Exception("logger == null");
  +            }
  +        }    
  +        else if(logFileName == null)
  +        {
  +            throw new Exception("logFileName == null");
  +        }
  +        else
  +        {
  +            throw new Exception("UNEXPECTED EXCEPTION");
  +        }    
       }
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message