org.springframework.test.context.junit4.rules.SpringClassRule Java Examples

The following examples show how to use org.springframework.test.context.junit4.rules.SpringClassRule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringJUnit4ClassRunner.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static void ensureSpringRulesAreNotPresent(Class<?> testClass) {
	for (Field field : testClass.getFields()) {
		Assert.state(!SpringClassRule.class.isAssignableFrom(field.getType()), () -> String.format(
				"Detected SpringClassRule field in test class [%s], " +
				"but SpringClassRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
		Assert.state(!SpringMethodRule.class.isAssignableFrom(field.getType()), () -> String.format(
				"Detected SpringMethodRule field in test class [%s], " +
				"but SpringMethodRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
	}
}
 
Example #2
Source File: SpringJUnit4ClassRunner.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static void ensureSpringRulesAreNotPresent(Class<?> testClass) {
	for (Field field : testClass.getFields()) {
		Assert.state(!SpringClassRule.class.isAssignableFrom(field.getType()), () -> String.format(
				"Detected SpringClassRule field in test class [%s], " +
				"but SpringClassRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
		Assert.state(!SpringMethodRule.class.isAssignableFrom(field.getType()), () -> String.format(
				"Detected SpringMethodRule field in test class [%s], " +
				"but SpringMethodRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
	}
}
 
Example #3
Source File: SpringJUnit4ClassRunner.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static void ensureSpringRulesAreNotPresent(Class<?> testClass) {
	for (Field field : testClass.getFields()) {
		if (SpringClassRule.class.isAssignableFrom(field.getType())) {
			throw new IllegalStateException(String.format("Detected SpringClassRule field in test class [%s], " +
					"but SpringClassRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
		}
		if (SpringMethodRule.class.isAssignableFrom(field.getType())) {
			throw new IllegalStateException(String.format("Detected SpringMethodRule field in test class [%s], " +
					"but SpringMethodRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
		}
	}
}