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 org.jmock.Mock;
23  import org.jmock.core.constraint.IsEqual;
24  import org.jmock.core.matcher.InvokeOnceMatcher;
25  
26  /**
27   * Test for {@link OutputConsumerProxy}
28   *
29   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
30   * @version $Id: OutputConsumerProxyTest.java 1039320 2010-11-26 11:48:24Z krosenvold $
31   */
32  public class OutputConsumerProxyTest
33      extends AbstractOutputConsumerTestCase
34  {
35      private Mock outputConsumerMock;
36  
37      protected void setUp()
38          throws Exception
39      {
40          super.setUp();
41          setOutputConsumerMock( new Mock( OutputConsumer.class ) );
42          setOutputConsumer( new OutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
43      }
44  
45      public void setOutputConsumerMock( Mock outputConsumerMock )
46      {
47          this.outputConsumerMock = outputConsumerMock;
48      }
49  
50      public Mock getOutputConsumerMock()
51      {
52          return outputConsumerMock;
53      }
54  
55      public void testConsumeFooterLine()
56      {
57          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
58              .with( new IsEqual( getReportEntry() ) );
59          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeFooterLine" )
60              .with( new IsEqual( getLine() ) );
61          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
62          super.testConsumeFooterLine();
63          getOutputConsumerMock().verify();
64      }
65  
66      public void testConsumeHeaderLine()
67      {
68          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
69              .with( new IsEqual( getReportEntry() ) );
70          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeHeaderLine" )
71              .with( new IsEqual( getLine() ) );
72          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
73          super.testConsumeHeaderLine();
74          getOutputConsumerMock().verify();
75      }
76  
77      public void testConsumeMessageLine()
78      {
79          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
80              .with( new IsEqual( getReportEntry() ) );
81          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeMessageLine" )
82              .with( new IsEqual( getLine() ) );
83          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
84          super.testConsumeMessageLine();
85          getOutputConsumerMock().verify();
86      }
87  
88      public void testConsumeOutputLine()
89          throws Exception
90      {
91          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
92              .with( new IsEqual( getReportEntry() ) );
93          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeOutputLine" )
94              .with( new IsEqual( getLine() ) );
95          getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
96          super.testConsumeOutputLine();
97          getOutputConsumerMock().verify();
98      }
99  
100     public void testTestSetStarting()
101     {
102         getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
103             .with( new IsEqual( getReportEntry() ) );
104         super.testTestSetStarting();
105         getOutputConsumerMock().verify();
106     }
107 
108     public void testTestSetCompleted()
109     {
110         getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
111             .with( new IsEqual( getReportEntry() ) );
112         getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
113         super.testTestSetCompleted();
114         getOutputConsumerMock().verify();
115     }
116 
117 }