View Javadoc

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