Skip to content

Commit 989954d

Browse files
committedJan 4, 2017
fixed JavaDoc to comply with Java 8
1 parent 4773b93 commit 989954d

9 files changed

+146
-125
lines changed
 

‎.classpath

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<attribute name="FROM_GRADLE_MODEL" value="true"/>
1616
</attributes>
1717
</classpathentry>
18-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
18+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
1919
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
2020
<classpathentry kind="output" path="bin"/>
2121
</classpath>

‎.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>paramterized-suite</name>
4-
<comment>Project paramterized-suite created by Buildship.</comment>
3+
<name>parameterized-suite</name>
4+
<comment>Project parameterized-suite created by Buildship.</comment>
55
<projects>
66
</projects>
77
<buildSpec>

‎build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'signing'
44

55
group = 'com.github.peterwippermann.junit4'
66
archivesBaseName = 'parameterized-suite'
7-
version = '1.0.0'
7+
version = '1.0.1'
88

99
repositories {
1010
mavenCentral()

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/ParameterContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.lang.reflect.Array;
44

55
/**
6-
* This singleton stores a parameter. This way parameters can be transferred between test classes.<br/>
6+
* This singleton stores a parameter. This way parameters can be transferred between test classes.<br>
77
* The type of the parameter is unbound and can also be an {@link Array}. Null is interpreted as "parameter is not set".
88
* <p>
99
* This implementation is not thread-safe. Concurrent implementations e.g. could use

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/ParameterizedSuite.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* A replacement for {@link Suite} that combines the features of {@link Suite} with
26-
* {@link Parameterized}.<br/>
26+
* {@link Parameterized}.<br>
2727
* Moreover, as an additional feature: If the suite test class is annotated with {@link TestRule},
2828
* {@link ClassRule}, {@link Before} or {@link After}, these will be evaluated as well.
2929
* <p>
@@ -101,8 +101,7 @@ protected Object[] getCurrentlyActiveParameter() {
101101
}
102102

103103
/**
104-
* Builds the {@link Runner}s the same way as in {@link Suite#Suite(RunnerBuilder, Class<?>,
105-
* Class<?>[])}
104+
* Builds the {@link Runner}s the same way as in {@link Suite#Suite(RunnerBuilder, Class[])}
106105
*
107106
* @param suiteTestClass
108107
* @param runnerBuilder
@@ -127,7 +126,7 @@ protected List<Runner> createRunnersForChildTestClasses(Class<?> suiteTestClass,
127126
* @param runnerBuilder
128127
* @param suiteChildClasses
129128
* @param parameters
130-
* @param testClassNamePattern - A pattern that will be used to create a name for the forked
129+
* @param parametersNamePattern - A pattern that will be used to create a name for the forked
131130
* test executions. Placeholders for index and parameters will be replaced.
132131
* @return
133132
* @throws InitializationError

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/util/BlockJUnit4ClassRunnerUtil.java

+43-32
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,56 @@
1212
import org.junit.runners.model.TestClass;
1313

1414
/**
15-
* A collection of useful methods extracted and duplicated from {@link BlockJUnit4ClassRunner}.
15+
* A collection of useful methods extracted and duplicated from
16+
* {@link BlockJUnit4ClassRunner}.
1617
* <p>
1718
* Code is under the license of JUnit: http://junit.org/junit4/license.html
1819
* <p>
1920
*
20-
* Please see the package info of {@link com.github.peterwippermann.junit4.parameterizedsuite.util} for more details.
21+
* Please see the package info of
22+
* {@link com.github.peterwippermann.junit4.parameterizedsuite.util} for more
23+
* details.
2124
*/
2225
public class BlockJUnit4ClassRunnerUtil {
2326

24-
/**
25-
* Returns a {@link Statement}: apply all non-static fields annotated with {@link Rule}.
26-
* <p>
27-
* This method has a slighty changed signature compared to its original, replacing the
28-
* {@link FrameworkMethod} parameter with a {@link Description}.
29-
*
30-
* @param description The description passed to the {@link Rule}
31-
* @param statement The base statement
32-
*
33-
* @return a RunRules statement if any class-level {@link Rule}s are found, or the base
34-
* statement
35-
*
36-
* @see BlockJUnit4ClassRunner#withTestRules(FrameworkMethod, List<TestRule>, Statement)
37-
*/
38-
public static Statement withTestRules(List<TestRule> testRules, Description description, Statement statement) {
39-
return testRules.isEmpty() ? statement : new RunRules(statement, testRules, description);
40-
}
27+
/**
28+
* Returns a {@link Statement}: apply all non-static fields annotated with
29+
* {@link Rule}.
30+
* <p>
31+
* This method has a slighty changed signature compared to the original
32+
* BlockJUnit4ClassRunner#withTestRules(FrameworkMethod, List, Statement),
33+
* replacing the {@link FrameworkMethod} parameter with a
34+
* {@link Description}.
35+
*
36+
* @param description
37+
* The description passed to the {@link Rule}
38+
* @param statement
39+
* The base statement
40+
*
41+
* @return a RunRules statement if any class-level {@link Rule}s are found,
42+
* or the base statement
43+
*
44+
* @see BlockJUnit4ClassRunner
45+
*/
46+
public static Statement withTestRules(List<TestRule> testRules, Description description, Statement statement) {
47+
return testRules.isEmpty() ? statement : new RunRules(statement, testRules, description);
48+
}
4149

42-
/**
43-
* @param target the test case instance
44-
* @param testClass the {@link TestClass} where the {@link TestRule} annotations have been
45-
* defined.
46-
* @return a list of TestRules that should be applied when executing this test
47-
*
48-
* @see BlockJUnit4ClassRunner#getTestRules(Object)
49-
*/
50-
public static List<TestRule> getTestRules(Object target, TestClass testClass) {
51-
List<TestRule> result = testClass.getAnnotatedMethodValues(target, Rule.class, TestRule.class);
52-
result.addAll(testClass.getAnnotatedFieldValues(target, Rule.class, TestRule.class));
53-
return result;
54-
}
50+
/**
51+
* @param target
52+
* the test case instance
53+
* @param testClass
54+
* the {@link TestClass} where the {@link TestRule} annotations
55+
* have been defined.
56+
* @return a list of TestRules that should be applied when executing this
57+
* test
58+
*
59+
* @see BlockJUnit4ClassRunner#getTestRules(Object)
60+
*/
61+
public static List<TestRule> getTestRules(Object target, TestClass testClass) {
62+
List<TestRule> result = testClass.getAnnotatedMethodValues(target, Rule.class, TestRule.class);
63+
result.addAll(testClass.getAnnotatedFieldValues(target, Rule.class, TestRule.class));
64+
return result;
65+
}
5566

5667
}

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/util/BlockJUnit4ClassRunnerWithParametersUtil.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.junit.internal.runners.statements.Fail;
1212
import org.junit.rules.TestRule;
1313
import org.junit.runner.Description;
14+
import org.junit.runners.BlockJUnit4ClassRunner;
1415
import org.junit.runners.Parameterized;
1516
import org.junit.runners.Parameterized.Parameter;
1617
import org.junit.runners.model.FrameworkField;
@@ -116,6 +117,8 @@ private static boolean fieldsAreAnnotated(TestClass testClass) {
116117
* Therefore the test class will be instantiated and parameters will be injected with the same
117118
* mechanism as in {@link Parameterized}.
118119
*
120+
* Implementation has been extracted from BlockJUnit4ClassRunner#methodBlock(FrameworkMethod).
121+
*
119122
* @param baseStatementWithChildren - A {@link Statement} that includes execution of the test's
120123
* children
121124
* @param testClass - The {@link TestClass} of the test.
@@ -124,8 +127,8 @@ private static boolean fieldsAreAnnotated(TestClass testClass) {
124127
* @param parametersToInject - The parameters will be injected in attributes annotated with
125128
* {@link Parameter} or passed to the constructor otherwise.
126129
*
127-
* @see {@link BlockJUnit4ClassRunner#methodBlock(FrameworkMethod)}
128-
* @see {@link BlockJUnit4ClassRunnerWithParameters#createTest()}
130+
* @see BlockJUnit4ClassRunnerWithParameters#createTest()
131+
* @see BlockJUnit4ClassRunner#methodBlock(FrameworkMethod)
129132
*/
130133
public static Statement buildStatementWithTestRules(Statement baseStatementWithChildren, final TestClass testClass, Description description,
131134
final Object[] parametersToInject) {

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/util/ParameterizedUtil.java

+89-81
Original file line numberDiff line numberDiff line change
@@ -10,99 +10,107 @@
1010
import org.junit.runners.model.TestClass;
1111

1212
/**
13-
* A collection of useful methods extracted and duplicated from {@link Parameterized}.
13+
* A collection of useful methods extracted and duplicated from
14+
* {@link Parameterized}.
1415
* <p>
1516
* Code is under the license of JUnit: http://junit.org/junit4/license.html
1617
* <p>
1718
*
18-
* Please see the package info of {@link com.github.peterwippermann.junit4.parameterizedsuite.util} for more details.
19+
* Please see the package info of
20+
* {@link com.github.peterwippermann.junit4.parameterizedsuite.util} for more
21+
* details.
1922
*/
2023
public class ParameterizedUtil {
2124

22-
/**
23-
* @param testClass
24-
* @return the parameters from the method annotated with {@link Parameters}
25-
* @throws Throwable
26-
*
27-
* @see Parameterized#allParameters()
28-
*/
29-
@SuppressWarnings("unchecked")
30-
public static Iterable<Object> getParameters(TestClass testClass) throws Throwable {
31-
Object parameters = getParametersMethod(testClass).invokeExplosively(null);
32-
if (parameters instanceof Iterable) {
33-
return (Iterable<Object>) parameters;
34-
} else if (parameters instanceof Object[]) {
35-
return Arrays.asList((Object[]) parameters);
36-
} else {
37-
throw parametersMethodReturnedWrongType(testClass);
38-
}
39-
}
25+
/**
26+
* @param testClass
27+
* @return the parameters from the method annotated with {@link Parameters}
28+
* @throws Throwable
29+
*
30+
* @see Parameterized#allParameters()
31+
*/
32+
@SuppressWarnings("unchecked")
33+
public static Iterable<Object> getParameters(TestClass testClass) throws Throwable {
34+
Object parameters = getParametersMethod(testClass).invokeExplosively(null);
35+
if (parameters instanceof Iterable) {
36+
return (Iterable<Object>) parameters;
37+
} else if (parameters instanceof Object[]) {
38+
return Arrays.asList((Object[]) parameters);
39+
} else {
40+
throw parametersMethodReturnedWrongType(testClass);
41+
}
42+
}
4043

41-
/**
42-
* @param testClass
43-
* @return the method annotated with {@link Parameters}
44-
* @throws Exception
45-
*
46-
* @see Parameterized#allParameters()
47-
*/
48-
private static FrameworkMethod getParametersMethod(TestClass testClass) throws Exception {
49-
List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
50-
for (FrameworkMethod each : methods) {
51-
if (each.isStatic() && each.isPublic()) {
52-
return each;
53-
}
54-
}
44+
/**
45+
* @param testClass
46+
* @return the method annotated with {@link Parameters}
47+
* @throws Exception
48+
*
49+
* @see Parameterized#allParameters()
50+
*/
51+
private static FrameworkMethod getParametersMethod(TestClass testClass) throws Exception {
52+
List<FrameworkMethod> methods = testClass.getAnnotatedMethods(Parameters.class);
53+
for (FrameworkMethod each : methods) {
54+
if (each.isStatic() && each.isPublic()) {
55+
return each;
56+
}
57+
}
5558

56-
throw new Exception("No public static parameters method on class " + testClass.getName());
57-
}
59+
throw new Exception("No public static parameters method on class " + testClass.getName());
60+
}
5861

59-
/**
60-
* @see Parameterized#parametersMethodReturnedWrongType()
61-
*/
62-
private static Exception parametersMethodReturnedWrongType(TestClass testClass) throws Exception {
63-
String className = testClass.getName();
64-
String methodName = getParametersMethod(testClass).getName();
65-
String message = MessageFormat.format("{0}.{1}() must return an Iterable of arrays.", className, methodName);
66-
return new Exception(message);
67-
}
62+
/**
63+
* @see Parameterized#parametersMethodReturnedWrongType()
64+
*/
65+
private static Exception parametersMethodReturnedWrongType(TestClass testClass) throws Exception {
66+
String className = testClass.getName();
67+
String methodName = getParametersMethod(testClass).getName();
68+
String message = MessageFormat.format("{0}.{1}() must return an Iterable of arrays.", className, methodName);
69+
return new Exception(message);
70+
}
6871

69-
/**
70-
* Parameters of a test can either be 1.) a set of {@link Object}s or 2.) a set of Arrays of
71-
* Objects. This method normalizes both variants to Object[]. Single Objects are therefore
72-
* stored in a new Array.
73-
*
74-
* @param singleParameterAsArrayOrObject
75-
*
76-
* @see {@link Parameterized#createTestWithNotNormalizedParameters(String, int, Object)}
77-
*/
78-
public static Object[] normalizeParameter(Object singleParameterAsArrayOrObject) {
79-
return (singleParameterAsArrayOrObject instanceof Object[]) ? (Object[]) singleParameterAsArrayOrObject : new Object[] {singleParameterAsArrayOrObject};
80-
}
72+
/**
73+
* Parameters of a test can either be 1.) a set of {@link Object}s or 2.) a
74+
* set of Arrays of Objects. This method normalizes both variants to
75+
* Object[]. Single Objects are therefore stored in a new Array.
76+
*
77+
* @param singleParameterAsArrayOrObject
78+
*
79+
* @see Parameterized#createTestWithNotNormalizedParameters(String, int,
80+
* Object)
81+
*/
82+
public static Object[] normalizeParameter(Object singleParameterAsArrayOrObject) {
83+
return (singleParameterAsArrayOrObject instanceof Object[]) ? (Object[]) singleParameterAsArrayOrObject
84+
: new Object[] { singleParameterAsArrayOrObject };
85+
}
8186

82-
/**
83-
* Builds a name for a test from a given name pattern by inserting the current parameter and its index.
84-
*
85-
* @param pattern
86-
* @param index
87-
* @param parameters
88-
*
89-
* @see {@link Parameterized#createTestWithParameters(TestClass, String, int, Object[])}
90-
*/
91-
public static String buildTestName(String pattern, int index, Object[] parameters) {
92-
String finalPattern = pattern.replaceAll("\\{index\\}", Integer.toString(index));
93-
return "[" + MessageFormat.format(finalPattern, parameters) + "]";
94-
}
87+
/**
88+
* Builds a name for a test from a given name pattern by inserting the
89+
* current parameter and its index.
90+
*
91+
* @param pattern
92+
* @param index
93+
* @param parameters
94+
*
95+
* @see Parameterized#createTestWithParameters(TestClass, String, int,
96+
* Object[])
97+
*/
98+
public static String buildTestName(String pattern, int index, Object[] parameters) {
99+
String finalPattern = pattern.replaceAll("\\{index\\}", Integer.toString(index));
100+
return "[" + MessageFormat.format(finalPattern, parameters) + "]";
101+
}
95102

96-
/**
97-
* @param testClass
98-
* @return The name pattern for tests as defined in the {@link Parameters} annotation.
99-
* @throws Exception
100-
*
101-
* @see {@link Parameterized#Parameterized(Class)}
102-
*/
103-
public static String getNamePatternForParameters(TestClass testClass) throws Exception {
104-
Parameters parametersAnnotation = getParametersMethod(testClass).getAnnotation(Parameters.class);
105-
return parametersAnnotation.name();
106-
}
103+
/**
104+
* @param testClass
105+
* @return The name pattern for tests as defined in the {@link Parameters}
106+
* annotation.
107+
* @throws Exception
108+
*
109+
* @see Parameterized#Parameterized(Class)
110+
*/
111+
public static String getNamePatternForParameters(TestClass testClass) throws Exception {
112+
Parameters parametersAnnotation = getParametersMethod(testClass).getAnnotation(Parameters.class);
113+
return parametersAnnotation.name();
114+
}
107115

108116
}

‎src/main/java/com/github/peterwippermann/junit4/parameterizedsuite/util/SuiteUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class SuiteUtil {
1616

1717
/**
18-
* @see Suite#getAnnotatedClasses()
18+
* @see Suite#getAnnotatedClasses(Class)
1919
*/
2020
public static Class<?>[] getSuiteClasses(Class<?> klass) throws InitializationError {
2121
SuiteClasses annotation = klass.getAnnotation(SuiteClasses.class);

0 commit comments

Comments
 (0)
Please sign in to comment.