View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck.junit4.rule;
8   
9   import org.junit.rules.TestRule;
10  import org.junit.runner.Description;
11  import org.junit.runners.model.Statement;
12  
13  /**
14   * Defines a {@link TestRule} that checks for timeouts in the execution
15   * of the tests, but differently from the JUnit's {@link org.junit.rules.Timeout}
16   * class, just prints a warning in the log and the test still pass.
17   * <p>
18   * This was implemented in order to maintain the old "failOnTimeout=false"
19   * feature from {@link org.mule.tck.junit4.AbstractMuleTestCase}
20   */
21  public class WarningTimeout implements TestRule
22  {
23  
24      private final int milliseconds;
25  
26      public WarningTimeout(int milliseconds)
27      {
28          this.milliseconds = milliseconds;
29      }
30  
31      public Statement apply(Statement statement, Description description)
32      {
33          return new WarnOnTimeout(statement, milliseconds);
34      }
35  }