001
014
015 package com.liferay.portal.kernel.test;
016
017 import org.junit.rules.TestRule;
018 import org.junit.runner.Description;
019 import org.junit.runners.model.Statement;
020
021
024 public class AggregateTestRule implements TestRule {
025
026 public AggregateTestRule(TestRule... testRules) {
027 if (testRules == null) {
028 throw new NullPointerException("Test rules is null");
029 }
030
031 if (testRules.length < 2) {
032 throw new IllegalArgumentException(
033 "Rule number " + testRules.length + " is less than 2");
034 }
035
036 _testRules = testRules;
037 }
038
039 @Override
040 public Statement apply(Statement statement, Description description) {
041 for (int i = _testRules.length - 1; i >= 0; i--) {
042 statement = _testRules[i].apply(statement, description);
043 }
044
045 return statement;
046 }
047
048 private final TestRule[] _testRules;
049
050 }