Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.testing.junit4;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import org.junit.runner.Runner;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.Parameterized;
import org.junit.runners.Suite;
import org.junit.runners.model.FrameworkField;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
/**
* Allows the {@link CustomRunner} features in parameterized tests.
* This is mostly copy-paste from {@link Parameterized} since the methods could not be overridden.
*
* The static {@link org.junit.BeforeClass} and {@link org.junit.AfterClass} methods will be executed
* only once before and after all tests (since these should prepare static members).
* Hibernate-specific {@link org.hibernate.testing.BeforeClassOnce} and {@link org.hibernate.testing.AfterClassOnce}
* will be executed before and after each set of tests with given parameters.
*
* Class can override the parameters list (annotated by {@link org.junit.runners.Parameterized.Parameters}
* by defining static method of the same name in inheriting class (this works although usually static
* methods cannot override each other in Java).
*
* When there are multiple methods providing the parameters list, the used parameters list is a cross product
* of all the options, concatenating the argument list according to {@link Order} values.
*
* Contrary to {@link Parameterized}, non-static parameters methods are allowed, but the test class needs
* to have parameterless constructor, and therefore use {@link org.junit.runners.Parameterized.Parameter}
* for setting these parameters. This allow type-safe overriding of the method; note that only the base
* method needs the {@link org.junit.runners.Parameterized.Parameters} annotation, overriding methods
* are invoked automatically.
*
* @author Radim Vansa <[email protected]>
*/
public class CustomParameterized extends Suite {
private static final List NO_RUNNERS = Collections.emptyList();
private final ArrayList runners = new ArrayList();
/**
* Only called reflectively. Do not use programmatically.
*/
public CustomParameterized(Class> klass) throws Throwable {
super(klass, NO_RUNNERS);
List parametersMethods = getParametersMethods();
createRunnersForParameters(allParameters(parametersMethods), concatNames(parametersMethods));
}
private String concatNames(List parametersMethods) {
StringBuilder sb = new StringBuilder();
for (FrameworkMethod method : parametersMethods) {
Parameterized.Parameters parameters = method.getAnnotation(Parameterized.Parameters.class);
if (sb.length() != 0) {
sb.append(", ");
}
sb.append(parameters.name());
}
return sb.toString();
}
@Override
protected List getChildren() {
return runners;
}
private Iterable