ActiveMQ example source code file (CombinationTestSupport.java)
This example ActiveMQ source code file (CombinationTestSupport.java) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The ActiveMQ CombinationTestSupport.java source code
/**
* 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.activemq;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Poor mans way of getting JUnit to run a test case through a few different
* combinations of options. Usage: If you have a test case called testFoo what
* you want to run through a few combinations, of of values for the attributes
* age and color, you would something like: <code>
* public void initCombosForTestFoo() {
* addCombinationValues( "age", new Object[]{ new Integer(21), new Integer(30) } );
* addCombinationValues( "color", new Object[]{"blue", "green"} );
* }
* </code>
* The testFoo test case would be run for each possible combination of age and
* color that you setup in the initCombosForTestFoo method. Before each
* combination is run, the age and color fields of the test class are set to one
* of the values defined. This is done before the normal setUp method is called.
* If you want the test combinations to show up as separate test runs in the
* JUnit reports, add a suite method to your test case similar to: <code>
* public static Test suite() {
* return suite(FooTest.class);
* }
* </code>
*
*
*/
public abstract class CombinationTestSupport extends AutoFailTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(CombinationTestSupport.class);
private HashMap<String, ComboOption> comboOptions = new HashMap();
private boolean combosEvaluated;
private Map options;
static class ComboOption {
final String attribute;
final LinkedHashSet<Object> values = new LinkedHashSet