Coverage Report - org.apache.commons.feedparser.test.BaseTestCase
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseTestCase
0%
0/8
N/A
1
 
 1  
 /*
 2  
  * Copyright 1999,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.feedparser.test;
 18  
 
 19  
 import junit.framework.TestCase;
 20  
 
 21  
 import org.apache.commons.feedparser.FeedParser;
 22  
 import org.apache.commons.feedparser.FeedParserFactory;
 23  
 import org.apache.commons.feedparser.FeedParserListener;
 24  
 import org.apache.commons.feedparser.impl.CaptureOutputFeedParserListener;
 25  
 import org.apache.commons.feedparser.network.ResourceRequest;
 26  
 import org.apache.commons.feedparser.network.ResourceRequestFactory;
 27  
 
 28  
 /**
 29  
  *
 30  
  * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
 31  
  * @version $Id: BaseTestCase.java 373622 2006-01-30 22:53:00Z mvdb $
 32  
  */
 33  
 public class BaseTestCase extends TestCase {
 34  
 
 35  
     public BaseTestCase( String name ) throws Exception {
 36  0
         super( name );
 37  0
     }
 38  
 
 39  
     /**
 40  
      * Run a parse on the given feed and then capture the event output as a
 41  
      * string for unit testing.  We can then grep across the string assering
 42  
      * that the correct events are called.
 43  
      *
 44  
      * 
 45  
      */
 46  
     public String captureOutputFromTest( String resource ) throws Exception {
 47  
 
 48  0
         FeedParser parser = FeedParserFactory.newFeedParser();
 49  
 
 50  0
         FeedParserListener listener = new CaptureOutputFeedParserListener();
 51  
         
 52  0
         ResourceRequest request = ResourceRequestFactory.getResourceRequest( resource );
 53  
         
 54  0
         parser.parse( listener, request.getInputStream(), resource );
 55  
 
 56  0
         String output = listener.toString();
 57  
 
 58  0
         return output;
 59  
         
 60  
     }
 61  
 
 62  
 }