Coverage Report - org.apache.maven.plugin.surefire.booterclient.MockReporter
 
Classes in this File Line Coverage Branch Coverage Complexity
MockReporter
100%
46/46
50%
1/2
1,067
 
 1  
 package org.apache.maven.plugin.surefire.booterclient;
 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 java.util.ArrayList;
 23  
 import java.util.List;
 24  
 import java.util.concurrent.atomic.AtomicInteger;
 25  
 import org.apache.maven.surefire.report.ConsoleLogger;
 26  
 import org.apache.maven.surefire.report.ConsoleOutputReceiver;
 27  
 import org.apache.maven.surefire.report.ReportEntry;
 28  
 import org.apache.maven.surefire.report.RunListener;
 29  
 
 30  
 /**
 31  
  * Internal use only
 32  
  */
 33  
 public class MockReporter
 34  
     implements RunListener, ConsoleLogger, ConsoleOutputReceiver
 35  
 {
 36  15
     private final List<String> events = new ArrayList<String>();
 37  
 
 38  15
     private final List<Object> data = new ArrayList<Object>();
 39  
 
 40  
     public static final String SET_STARTING = "SET_STARTED";
 41  
 
 42  
     public static final String SET_COMPLETED = "SET_COMPLETED";
 43  
 
 44  
     public static final String TEST_STARTING = "TEST_STARTED";
 45  
 
 46  
     public static final String TEST_SUCCEEDED = "TEST_COMPLETED";
 47  
 
 48  
     public static final String TEST_FAILED = "TEST_FAILED";
 49  
 
 50  
     public static final String TEST_ERROR = "TEST_ERROR";
 51  
 
 52  
     public static final String TEST_SKIPPED = "TEST_SKIPPED";
 53  
 
 54  
     public static final String TEST_ASSUMPTION_FAIL = "TEST_ASSUMPTION_SKIPPED";
 55  
 
 56  
     public static final String CONSOLE_OUTPUT = "CONSOLE_OUTPUT";
 57  
 
 58  
     public static final String STDOUT = "STDOUT";
 59  
 
 60  
     public static final String STDERR = "STDERR";
 61  
 
 62  15
     private final AtomicInteger testSucceeded = new AtomicInteger();
 63  
 
 64  15
     private final AtomicInteger testIgnored = new AtomicInteger();
 65  
 
 66  15
     private final AtomicInteger testFailed = new AtomicInteger();
 67  
 
 68  
     public MockReporter()
 69  15
     {
 70  15
     }
 71  
 
 72  
     public void testSetStarting( ReportEntry report )
 73  
     {
 74  2
         events.add( SET_STARTING );
 75  2
         data.add( report );
 76  2
     }
 77  
 
 78  
     public void testSetCompleted( ReportEntry report )
 79  
     {
 80  2
         events.add( SET_COMPLETED );
 81  2
         data.add( report );
 82  2
     }
 83  
 
 84  
     public void testStarting( ReportEntry report )
 85  
     {
 86  3
         events.add( TEST_STARTING );
 87  3
         data.add( report );
 88  3
     }
 89  
 
 90  
     public void testSucceeded( ReportEntry report )
 91  
     {
 92  2
         events.add( TEST_SUCCEEDED );
 93  2
         testSucceeded.incrementAndGet();
 94  2
         data.add( report );
 95  2
     }
 96  
 
 97  
     public void testError( ReportEntry report )
 98  
     {
 99  1
         events.add( TEST_ERROR );
 100  1
         data.add( report );
 101  1
         testFailed.incrementAndGet();
 102  1
     }
 103  
 
 104  
     public void testFailed( ReportEntry report )
 105  
     {
 106  3
         events.add( TEST_FAILED );
 107  3
         data.add( report );
 108  3
         testFailed.incrementAndGet();
 109  3
     }
 110  
 
 111  
 
 112  
     public void testSkipped( ReportEntry report )
 113  
     {
 114  2
         events.add( TEST_SKIPPED );
 115  2
         data.add( report );
 116  2
         testIgnored.incrementAndGet();
 117  2
     }
 118  
 
 119  
 
 120  
     public List<String> getEvents()
 121  
     {
 122  15
         return events;
 123  
     }
 124  
 
 125  
     public List getData()
 126  
     {
 127  12
         return data;
 128  
     }
 129  
 
 130  
     public String getFirstEvent()
 131  
     {
 132  2
         return events.get( 0 );
 133  
     }
 134  
 
 135  
     public ReportEntry getFirstData()
 136  
     {
 137  2
         return (ReportEntry) data.get( 0 );
 138  
     }
 139  
 
 140  
 
 141  
     public void testAssumptionFailure( ReportEntry report )
 142  
     {
 143  1
         events.add( TEST_ASSUMPTION_FAIL );
 144  1
         data.add( report );
 145  1
         testIgnored.incrementAndGet();
 146  
 
 147  1
     }
 148  
 
 149  
     public void info( String message )
 150  
     {
 151  1
         events.add( CONSOLE_OUTPUT );
 152  1
         data.add( message );
 153  1
     }
 154  
 
 155  
     public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
 156  
     {
 157  1
         events.add( stdout ? STDOUT : STDERR );
 158  1
         data.add( new String( buf, off, len ) );
 159  1
     }
 160  
 }