mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-29 10:32:08 +01:00
Refactor AbstractSOPTest
This commit is contained in:
parent
a722e98578
commit
0fccf3051c
1 changed files with 23 additions and 17 deletions
|
@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.Arguments;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.testsuite.SOPInstanceFactory;
|
import sop.testsuite.SOPInstanceFactory;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -19,24 +20,29 @@ public abstract class AbstractSOPTest {
|
||||||
private static final List<Arguments> backends = new ArrayList<>();
|
private static final List<Arguments> backends = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// populate instances list via configured test subject factory
|
initBackends();
|
||||||
String factoryName = System.getenv("test.implementation");
|
}
|
||||||
if (factoryName != null) {
|
|
||||||
try {
|
|
||||||
Class testSubjectFactoryClass = Class.forName(factoryName);
|
|
||||||
SOPInstanceFactory factory = (SOPInstanceFactory) testSubjectFactoryClass.newInstance();
|
|
||||||
Map<String, SOP> testSubjects = factory.provideSOPInstances();
|
|
||||||
|
|
||||||
for (String key : testSubjects.keySet()) {
|
// populate instances list via configured test subject factory
|
||||||
backends.add(Arguments.of(Named.of(key, testSubjects.get(key))));
|
private static void initBackends() {
|
||||||
}
|
String factoryName = System.getenv("test.implementation");
|
||||||
} catch (ClassNotFoundException e) {
|
if (factoryName == null) {
|
||||||
throw new RuntimeException(e);
|
return;
|
||||||
} catch (InstantiationException e) {
|
}
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
SOPInstanceFactory factory;
|
||||||
throw new RuntimeException(e);
|
try {
|
||||||
}
|
Class<?> testSubjectFactoryClass = Class.forName(factoryName);
|
||||||
|
factory = (SOPInstanceFactory) testSubjectFactoryClass
|
||||||
|
.getDeclaredConstructor().newInstance();
|
||||||
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
|
||||||
|
InvocationTargetException | NoSuchMethodException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, SOP> testSubjects = factory.provideSOPInstances();
|
||||||
|
for (String key : testSubjects.keySet()) {
|
||||||
|
backends.add(Arguments.of(Named.of(key, testSubjects.get(key))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue