/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache license, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the license for the specific language governing permissions and
 * limitations under the license.
 */

package org.apache.logging.log4j.test;

import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;

/**
 * Builds JUnit {@link RuleChain}s.
 */
public class RuleChainFactory {

    /**
     * Creates a {@link RuleChain} where the rules are evaluated in the order you pass in.
     * 
     * @param testRules
     *            test rules to evaluate
     * @return a new rule chain.
     */
    public static RuleChain create(final TestRule... testRules) {
        RuleChain ruleChain = RuleChain.outerRule(testRules[0]);
        for (int idx = 1; idx < testRules.length; idx++) {
            if (ruleChain != null) {
                ruleChain = ruleChain.around(testRules[idx]);
            }
        }
        return ruleChain;
    }
}

@@ -1255,24 +1255,139 @@
 estRules) %7B%0A
+        if (testRules == null %7C%7C testRules.length == 0) %7B%0A            return RuleChain.emptyRuleChain();%0A        %7D%0A
         Rule
@@ -1461,19 +1461,15 @@
 nt i
-dx
  = 1; i
-dx
  %3C t
@@ -1490,57 +1490,14 @@
 h; i
-dx
 ++) %7B%0A
-            if (ruleChain != null) %7B%0A    
     
@@ -1548,28 +1548,12 @@
 es%5Bi
-dx
 %5D);%0A
-            %7D%0A
     

Allow for empty rule chains.