commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject cvs commit: jakarta-commons-sandbox/pipeline/src/test/resources TestResources.properties log4j_conf.xml test_conf.xml
Date Tue, 30 Nov 2004 22:29:30 GMT
rwinston    2004/11/30 14:29:30

  Added:       pipeline/src/test/org/apache/commons/pipeline/config
                        DigesterPipelineFactoryTest.java
               pipeline/src/test/resources TestResources.properties
                        log4j_conf.xml test_conf.xml
  Log:
  Added missing src/test directory
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/pipeline/src/test/org/apache/commons/pipeline/config/DigesterPipelineFactoryTest.java
  
  Index: DigesterPipelineFactoryTest.java
  ===================================================================
  /*
   * DigesterPipelineFactoryTest.java
   * JUnit based test
   *
   * Created on October 28, 2004, 4:01 PM
   */
  
  package org.apache.commons.pipeline.config;
  
  import junit.framework.TestCase;
  import junit.framework.*;
  import java.io.File;
  import java.io.InputStream;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ResourceBundle;
  import org.apache.commons.digester.Digester;
  import org.apache.commons.digester.RuleSet;
  import org.apache.commons.pipeline.PipelineCreationException;
  import org.apache.commons.pipeline.Pipeline;
  import org.apache.commons.pipeline.Stage;
  import org.apache.commons.pipeline.PipelineFactory;
  import org.apache.log4j.xml.DOMConfigurator;
  import org.w3c.dom.Document;
  import javax.xml.parsers.DocumentBuilderFactory;
  
  /**
   *
   * @author kjn
   */
  public class DigesterPipelineFactoryTest extends TestCase {
      private ResourceBundle testResources = ResourceBundle.getBundle("TestResources");
      private String keyBase = "test.DigesterPipelineFactoryTest";
      
      public DigesterPipelineFactoryTest(String testName) {
          super(testName);
      }
      
      protected void setUp() throws java.lang.Exception {
          //set up logging
          InputStream istream = this.getClass().getClassLoader().getResourceAsStream(testResources.getString(keyBase
+ ".logConfig"));
          try {
              Document document  = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(istream);
              DOMConfigurator.configure(document.getDocumentElement());
          }
          finally {
              if (istream != null) istream.close();
          }
      }
      
      protected void tearDown() throws java.lang.Exception {
      }
      
      public static junit.framework.Test suite() {        
          junit.framework.TestSuite suite = new junit.framework.TestSuite(DigesterPipelineFactoryTest.class);
          
          return suite;
      }
      
      
      public void testCreatePipeline() throws Exception {
          InputStream istream = this.getClass().getClassLoader().getResourceAsStream(testResources.getString(keyBase
+ ".configFile"));
          try {
              PipelineFactory factory = new DigesterPipelineFactory(istream);
              
              Pipeline pipeline = factory.createPipeline();
              Assert.assertNotNull(pipeline);
              
              int i = 0;
              for (Stage stage : pipeline) {
                  Assert.assertNotNull(stage);
                  Assert.assertEquals(stage.getClass(), Class.forName(testResources.getString(keyBase
+ ".stage" + i + ".class")));
                  i++;
              }
              
              pipeline.run();
          }
          finally {
              if (istream != null) istream.close();
          }
      }
      
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/pipeline/src/test/resources/TestResources.properties
  
  Index: TestResources.properties
  ===================================================================
  # Resource bundle for test resources
  
  test.DigesterPipelineFactoryTest.configFile=test_conf.xml
  test.DigesterPipelineFactoryTest.logConfig=log4j_conf.xml
  test.DigesterPipelineFactoryTest.stage0.class=org.apache.commons.pipeline.impl.FileFinderStage
  test.DigesterPipelineFactoryTest.stage1.class=org.apache.commons.pipeline.impl.LogStage
  
  
  1.1                  jakarta-commons-sandbox/pipeline/src/test/resources/log4j_conf.xml
  
  Index: log4j_conf.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8" ?>
  <!--<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">-->
  
  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  
      <appender name="log_app" class="org.apache.log4j.FileAppender">
          <param name="File"   value="target/test-reports/pipeline.log" />
          <param name="Append" value="false" />	    	
          <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
          </layout>	    
      </appender>
  
      <appender name="impl_app" class="org.apache.log4j.FileAppender">
          <param name="File"   value="target/test-reports/impl.log" />
          <param name="Append" value="false" />	    	
          <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
          </layout>	    
      </appender>
  
      <appender name="external_app" class="org.apache.log4j.FileAppender">
          <param name="File"   value="target/test-reports/external.log" />
          <param name="Append" value="false" />	    	
          <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
          </layout>	    
      </appender>
  
      <category name="org.apache.commons.digester" additivity="false">
        <level value="info" />
        <appender-ref ref="external_app" />
      </category>
  
      <category name="org.apache.commons.beanutils" additivity="false">
        <level value="info" />
        <appender-ref ref="external_app" />
      </category>
  
      <category name="org.apache.commons.pipeline.impl" additivity="false">
        <level value="debug" />
        <appender-ref ref="impl_app" />
      </category>
  
      <root>
         <level value="debug" />
         <appender-ref ref="log_app" />
      </root>
  
  </log4j:configuration>
  
  
  
  1.1                  jakarta-commons-sandbox/pipeline/src/test/resources/test_conf.xml
  
  Index: test_conf.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!--
      Document   : acars_conf.xml
      Created on : February 12, 2004, 4:08 PM
      Author     : kjn
      Description:
          Configuration file for acars data import
  -->
  
  <pipeline>
      <stageDriverFactory/> <!-- uses default stage drivers -->
  
      <stage className="org.apache.commons.pipeline.impl.FileFinderStage" filePattern=".*\.java">
          <stageDriver className="org.apache.commons.pipeline.impl.SingleThreadStageDriver"/>
          <enqueue><value>src/java</value></enqueue>
      </stage>
  
      <stage className="org.apache.commons.pipeline.impl.LogStage">
          <stageDriver className="org.apache.commons.pipeline.impl.SingleThreadStageDriver"/>
      </stage>
                     
  </pipeline>
  
  
  

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


Mime
View raw message