use of org.junit.ClassRule in project spring-framework by spring-projects.
the class SpringMethodRule method validateSpringClassRuleConfiguration.
/**
* Throw an {@link IllegalStateException} if the supplied {@code testClass}
* does not declare a {@code public static final SpringClassRule} field
* that is annotated with {@code @ClassRule}.
*/
private static SpringClassRule validateSpringClassRuleConfiguration(Class<?> testClass) {
Field ruleField = findSpringClassRuleField(testClass).orElseThrow(() -> new IllegalStateException(String.format("Failed to find 'public static final SpringClassRule' field in test class [%s]. " + "Consult the javadoc for SpringClassRule for details.", testClass.getName())));
Assert.state(ruleField.isAnnotationPresent(ClassRule.class), () -> String.format("SpringClassRule field [%s] must be annotated with JUnit's @ClassRule annotation. " + "Consult the javadoc for SpringClassRule for details.", ruleField));
return (SpringClassRule) ReflectionUtils.getField(ruleField, null);
}
use of org.junit.ClassRule in project opennms by OpenNMS.
the class TrapIT method getTestEnvironment.
@ClassRule
public static final TestEnvironment getTestEnvironment() {
if (!OpenNMSSeleniumTestCase.isDockerEnabled()) {
return new NullTestEnvironment();
}
try {
final TestEnvironmentBuilder builder = TestEnvironment.builder().all();
builder.withOpenNMSEnvironment().addFile(AbstractSyslogTestCase.class.getResource("/eventconf.xml"), "etc/eventconf.xml").addFile(AbstractSyslogTestCase.class.getResource("/events/Cisco.syslog.events.xml"), "etc/events/Cisco.syslog.events.xml").addFile(AbstractSyslogTestCase.class.getResource("/syslogd-configuration.xml"), "etc/syslogd-configuration.xml").addFile(AbstractSyslogTestCase.class.getResource("/syslog/Cisco.syslog.xml"), "etc/syslog/Cisco.syslog.xml");
OpenNMSSeleniumTestCase.configureTestEnvironment(builder);
minionSystem = builder.build();
return minionSystem;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
}
use of org.junit.ClassRule in project opennms by OpenNMS.
the class DetectorsOnMinionIT method getTestEnvironment.
@ClassRule
public static final TestEnvironment getTestEnvironment() {
if (!OpenNMSSeleniumTestCase.isDockerEnabled()) {
return new NullTestEnvironment();
}
try {
final TestEnvironmentBuilder builder = TestEnvironment.builder().all();
OpenNMSSeleniumTestCase.configureTestEnvironment(builder);
m_testEnvironment = builder.build();
return m_testEnvironment;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
}
use of org.junit.ClassRule in project opennms by OpenNMS.
the class MinionHeartBeatIT method getTestEnvironment.
@ClassRule
public static final TestEnvironment getTestEnvironment() {
if (!OpenNMSSeleniumTestCase.isDockerEnabled()) {
return new NullTestEnvironment();
}
try {
final TestEnvironmentBuilder builder = TestEnvironment.builder().all();
OpenNMSSeleniumTestCase.configureTestEnvironment(builder);
m_testEnvironment = builder.build();
return m_testEnvironment;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
}
use of org.junit.ClassRule in project opennms by OpenNMS.
the class CollectorListIT method getTestEnvironment.
@ClassRule
public static final TestEnvironment getTestEnvironment() {
if (!OpenNMSSeleniumTestCase.isDockerEnabled()) {
return new NullTestEnvironment();
}
try {
final TestEnvironmentBuilder builder = TestEnvironment.builder().all();
OpenNMSSeleniumTestCase.configureTestEnvironment(builder);
m_testEnvironment = builder.build();
return m_testEnvironment;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
}
Aggregations