View Javadoc

1   package org.apache.maven.plugin.surefire.booterclient.output;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.framework.TestCase;
23  import org.apache.maven.surefire.report.CategorizedReportEntry;
24  import org.apache.maven.surefire.report.ReportEntry;
25  
26  /**
27   * Test for {@link OutputConsumer}
28   *
29   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
30   * @version $Id: AbstractOutputConsumerTestCase.java 1056406 2011-01-07 17:34:39Z krosenvold $
31   */
32  public abstract class AbstractOutputConsumerTestCase
33      extends TestCase
34  {
35      private OutputConsumer outputConsumer;
36  
37      private String line;
38  
39      private ReportEntry reportEntry;
40  
41      protected void setUp()
42          throws Exception
43      {
44          super.setUp();
45          setLine( "line" );
46          setReportEntry( CategorizedReportEntry.nameGroup( "name", "group" ) );
47      }
48  
49      public void setOutputConsumer( OutputConsumer outputConsumer )
50      {
51          this.outputConsumer = outputConsumer;
52      }
53  
54      public OutputConsumer getOutputConsumer()
55      {
56          return outputConsumer;
57      }
58  
59      public void setLine( String line )
60      {
61          this.line = line;
62      }
63  
64      public String getLine()
65      {
66          return line;
67      }
68  
69      public void setReportEntry( ReportEntry reportEntry )
70      {
71          this.reportEntry = reportEntry;
72      }
73  
74      public ReportEntry getReportEntry()
75      {
76          return reportEntry;
77      }
78  
79      public void testConsumeHeaderLine()
80      {
81          getOutputConsumer().testSetStarting( getReportEntry() );
82          getOutputConsumer().consumeHeaderLine( getLine() );
83          getOutputConsumer().testSetCompleted();
84      }
85  
86      public void testConsumeMessageLine()
87      {
88          getOutputConsumer().testSetStarting( getReportEntry() );
89          getOutputConsumer().consumeMessageLine( getLine() );
90          getOutputConsumer().testSetCompleted();
91      }
92  
93      public void testConsumeFooterLine()
94      {
95          getOutputConsumer().testSetStarting( getReportEntry() );
96          getOutputConsumer().consumeFooterLine( getLine() );
97          getOutputConsumer().testSetCompleted();
98      }
99  
100     public void testConsumeOutputLine()
101         throws Exception
102     {
103         getOutputConsumer().testSetStarting( getReportEntry() );
104         getOutputConsumer().consumeOutputLine( getLine() );
105         getOutputConsumer().testSetCompleted();
106     }
107 
108     public void testTestSetStarting()
109     {
110         getOutputConsumer().testSetStarting( getReportEntry() );
111     }
112 
113     public void testTestSetCompleted()
114     {
115         getOutputConsumer().testSetStarting( getReportEntry() );
116         getOutputConsumer().testSetCompleted();
117     }
118 
119 }