commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/junit JUnitEventReporter.java
Date Sun, 20 Jan 2002 00:23:45 GMT
dion        02/01/19 16:23:45

  Modified:    latka/src/java/org/apache/commons/latka/junit
                        JUnitEventReporter.java
  Log:
  Changed formatting to jakarta standard
  
  Revision  Changes    Path
  1.4       +131 -124  jakarta-commons/latka/src/java/org/apache/commons/latka/junit/JUnitEventReporter.java
  
  Index: JUnitEventReporter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/junit/JUnitEventReporter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JUnitEventReporter.java	25 Oct 2001 20:31:00 -0000	1.3
  +++ JUnitEventReporter.java	20 Jan 2002 00:23:44 -0000	1.4
  @@ -81,136 +81,143 @@
    * succeeded events
    *
    * @author Chuck Burdick
  - * @version $Id: JUnitEventReporter.java,v 1.3 2001/10/25 20:31:00 morgand Exp $
  + * @version $Id: JUnitEventReporter.java,v 1.4 2002/01/20 00:23:44 dion Exp $
    */
   public class JUnitEventReporter extends AbstractReporter {
  -   private static final Category _log = Category.getInstance(JUnitEventReporter.class);
  +    private static final Category _log = Category.getInstance(JUnitEventReporter.class);
   
  -   private TestResult _testResult = null;
  +    private TestResult _testResult = null;
   
  -   /** 
  -    * Create a JUnitEventReporter, storing the
  -    * JUnit Test results in the provided object
  -    * @param result the JUnit TestResult to add failures and errors to
  -    */   
  -   protected JUnitEventReporter(TestResult result) {
  -      _testResult = result;
  -   }
  -
  -   private class EventTestAdapter implements Test {
  -      private AssertionFailedError _failed = null;
  -      private Throwable _error = null;
  -
  -      /** 
  -       * A JUnit Test class accumulates test results when run
  -       * based on the constructor that was called
  -       */      
  -      public EventTestAdapter() { }
  +    /** 
  +     * Create a JUnitEventReporter, storing the
  +     * JUnit Test results in the provided object
  +     * @param result the JUnit TestResult to add failures and errors to
  +     */   
  +    protected JUnitEventReporter(TestResult result) {
  +        _testResult = result;
  +    }
  +
  +    private class EventTestAdapter implements Test {
  +        private AssertionFailedError _failed = null;
  +        private Throwable _error = null;
  +
  +        /** 
  +         * A JUnit Test class accumulates test results when run
  +         * based on the constructor that was called
  +         */      
  +        public EventTestAdapter() {
  +        }
         
  -      /** 
  -       * Create an instance with a JUnit
  -       * {@link junit.framework.AssertionFailedError AssertionFailedError} 
  -       * that can be added to the results in the
  -       * {@link #run(junit.framework.TestResult) run} method
  -       *
  -       * @param t The AssertionFailedError that will be stored for
  -       * later addition to results
  -       */      
  -      public EventTestAdapter(AssertionFailedError t) { _failed = t; }
  +        /** 
  +         * Create an instance with a JUnit
  +         * {@link junit.framework.AssertionFailedError AssertionFailedError} 
  +         * that can be added to the results in the
  +         * {@link #run(junit.framework.TestResult) run} method
  +         *
  +         * @param t The AssertionFailedError that will be stored for
  +         * later addition to results
  +         */      
  +        public EventTestAdapter(AssertionFailedError t) {
  +            _failed = t;
  +        }
         
  -      /**
  -       * Create an instance with a JUnit {@link java.lang.Throwable Throble} that
  -       * can be added to the results in the 
  -       * {@link #run(junit.framework.TestResult) run} method
  -       * 
  -       * @param t The Throwable that will be stored for later addition to results
  -       */      
  -      public EventTestAdapter(Throwable t) { _error = t; }
  +        /**
  +         * Create an instance with a JUnit {@link java.lang.Throwable Throble} that
  +         * can be added to the results in the 
  +         * {@link #run(junit.framework.TestResult) run} method
  +         * 
  +         * @param t The Throwable that will be stored for later addition to results
  +         */      
  +        public EventTestAdapter(Throwable t) {
  +            _error = t;
  +        }
         
  -      /**
  -       * The number of test cases this test contains
  -       * 
  -       * @return Currently hard coded to one test cases
  -       */      
  -      public int countTestCases() { return 1; }
  +        /**
  +         * The number of test cases this test contains
  +         * 
  +         * @return Currently hard coded to one test cases
  +         */      
  +        public int countTestCases() {
  +            return 1;
  +        }
         
  -      /**
  -       * Run this test.
  -       * Since Latka has already executed the request we simply check if there 
  -       * has been a failure or error stored and add it to the test results
  -       *
  -       * @param result The {@link junit.framework.TestResult TestResult} to 
  -       * store failures or errors in
  -       */      
  -      public void run(TestResult result) {
  -         result.startTest(this);
  -         if (_error != null) {
  -            result.addError(this, _error);
  -         } else if (_failed != null) {
  -            result.addFailure(this, _failed);
  -         }
  -         result.endTest(this);
  -      }
  -   }
  -
  -   /**
  -    * Process a Latka request error
  -    * @param event the latka request event that is in error
  -    */
  -   public void requestError(RequestEvent event) {
  -      _log.debug("Received latka RequestErrorEvent");
  -      super.requestError(event);
  -      Throwable error = ((RequestErrorEvent)event).getError();
  -      Test test = new EventTestAdapter(error);
  -      test.run(_testResult);
  -   }
  -
  -   /**
  -    * Process a Latka request failure
  -    * @param event The event describing the request that has failed
  -    */   
  -   public  void requestFailed(RequestEvent event) {
  -      _log.debug("Received latka RequestFailedEvent");
  -      super.requestFailed(event);
  -      RequestFailedEvent fe = (RequestFailedEvent)event;
  -      ValidationException ve = (ValidationException)fe.getValidationException();
  -      String requestUrl = event.getRequest().getURL().toString();
  -      String requestLabel = event.getRequest().getLabel();
  -      String message = requestUrl + " -- " + requestLabel + ": " +
  -         ve.getReason();
  -      AssertionFailedError failure = new AssertionFailedError(message);
  -      Test test = new EventTestAdapter(failure);
  -      test.run(_testResult);
  -   }
  -
  -   /**
  -    * Process a Latka event being skipped
  -    * @param event The event describing the request that has been skipped
  -    */   
  -   public void requestSkipped(RequestEvent event) {
  -      _log.debug("Received latka RequestSkippedEvent");
  -      super.requestSkipped(event);
  -      AssertionFailedError failure = new AssertionFailedError(
  -         "Skipped due to earlier error");
  -      Test test = new EventTestAdapter(failure);
  -      test.run(_testResult);
  -   }
  -
  -   /**
  -    * Process a Latka request success event
  -    * @param event The event describing the request that has succeeded
  -    */   
  -   public void requestSucceeded(RequestEvent event) {
  -      _log.debug("Received latka RequestSucceededEvent");
  -      super.requestSucceeded(event);
  -      Test test = new EventTestAdapter();
  -      test.run(_testResult);
  -   }
  -
  -   /**
  -    * Process a Latka suite completion event
  -    * @param event The event describing the suite that has completed
  -    */      
  -   public void suiteCompleted(SuiteEvent event) {
  -   }
  +        /**
  +         * Run this test.
  +         * Since Latka has already executed the request we simply check if there 
  +         * has been a failure or error stored and add it to the test results
  +         *
  +         * @param result The {@link junit.framework.TestResult TestResult} to 
  +         * store failures or errors in
  +         */      
  +        public void run(TestResult result) {
  +            result.startTest(this);
  +            if (_error != null) {
  +                result.addError(this, _error);
  +            } else if (_failed != null) {
  +                result.addFailure(this, _failed);
  +            }
  +            result.endTest(this);
  +        }
  +    }
  +
  +    /**
  +     * Process a Latka request error
  +     * @param event the latka request event that is in error
  +     */
  +    public void requestError(RequestEvent event) {
  +        _log.debug("Received latka RequestErrorEvent");
  +        super.requestError(event);
  +        Throwable error = ((RequestErrorEvent)event).getError();
  +        Test test = new EventTestAdapter(error);
  +        test.run(_testResult);
  +    }
  +
  +    /**
  +     * Process a Latka request failure
  +     * @param event The event describing the request that has failed
  +     */   
  +    public  void requestFailed(RequestEvent event) {
  +        _log.debug("Received latka RequestFailedEvent");
  +        super.requestFailed(event);
  +        RequestFailedEvent fe = (RequestFailedEvent)event;
  +        ValidationException ve = (ValidationException)fe.getValidationException();
  +        String requestUrl = event.getRequest().getURL().toString();
  +        String requestLabel = event.getRequest().getLabel();
  +        String message = requestUrl + " -- " + requestLabel + ": " +
  +                         ve.getReason();
  +        AssertionFailedError failure = new AssertionFailedError(message);
  +        Test test = new EventTestAdapter(failure);
  +        test.run(_testResult);
  +    }
  +
  +    /**
  +     * Process a Latka event being skipped
  +     * @param event The event describing the request that has been skipped
  +     */   
  +    public void requestSkipped(RequestEvent event) {
  +        _log.debug("Received latka RequestSkippedEvent");
  +        super.requestSkipped(event);
  +        AssertionFailedError failure = new AssertionFailedError(
  +                                        "Skipped due to earlier error");
  +        Test test = new EventTestAdapter(failure);
  +        test.run(_testResult);
  +    }
  +
  +    /**
  +     * Process a Latka request success event
  +     * @param event The event describing the request that has succeeded
  +     */   
  +    public void requestSucceeded(RequestEvent event) {
  +        _log.debug("Received latka RequestSucceededEvent");
  +        super.requestSucceeded(event);
  +        Test test = new EventTestAdapter();
  +        test.run(_testResult);
  +    }
  +
  +    /**
  +     * Process a Latka suite completion event
  +     * @param event The event describing the suite that has completed
  +     */      
  +    public void suiteCompleted(SuiteEvent event) {
  +    }
   }
  
  
  

--
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