use of org.junit.runners.model.TestClass in project alchemy-test by SirWellington.
the class TestClassInjectorsTest method testPopulateGeneratedFieldsWithBadList.
@Test
public void testPopulateGeneratedFieldsWithBadList() throws Exception {
System.out.println("testPopulateGeneratedFieldsWithBadList");
TestClass testClass = new TestClass(BadListTest.class);
BadListTest instance = new BadListTest();
assertThrows(() -> TestClassInjectors.populateGeneratedFields(testClass, instance)).isInstanceOf(IllegalArgumentException.class);
}
use of org.junit.runners.model.TestClass in project alchemy-test by SirWellington.
the class AlchemyTestRunner method shouldInitMockitoMocks.
private boolean shouldInitMockitoMocks() {
TestClass testClass = this.getTestClass();
InitMocks initMocks = testClass.getAnnotation(InitMocks.class);
if (initMocks != null) {
return initMocks.value();
}
return true;
}
use of org.junit.runners.model.TestClass in project deltaspike by apache.
the class MyFacesContainerAdapter method boot.
public void boot() {
final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
this.mockedMyFacesTestContainer = new MyFacesContainer(new TestClass(this.testClass)) {
@Override
protected String getWebappResourcePath() {
TestConfig testConfig = testClass.getJavaClass().getAnnotation(TestConfig.class);
if (testConfig == null || DEFAULT_TEST_CONFIG_LITERAL.webappResourcePath().equals(testConfig.webappResourcePath())) {
return MyFacesTestBaseConfig.WEBAPP_RESOURCE_PATH;
}
return testConfig.webappResourcePath();
}
@Override
protected void setUpServletObjects() {
//just needed for MyFaces-Test util v1.0.7
//(to bypass issues with the outdated URLClassLoader used by AbstractJsfTestContainer)
setCurrentClassLoader(originalClassLoader);
super.setUpServletObjects();
}
@Override
protected void setUpWebConfigParams() {
servletContext.addInitParameter("org.apache.myfaces.config.annotation.LifecycleProvider", "org.apache.myfaces.config.annotation.NoInjectionAnnotationLifecycleProvider");
servletContext.addInitParameter("org.apache.myfaces.CHECKED_VIEWID_CACHE_ENABLED", "false");
servletContext.addInitParameter(ExpressionFactory.class.getName(), "org.apache.el.ExpressionFactoryImpl");
super.setUpWebConfigParams();
initContainerConfig();
//add custom values (might replace the default values)
for (Map.Entry<String, String> entry : containerConfig.entrySet()) {
servletContext.addInitParameter(entry.getKey(), entry.getValue());
}
}
};
this.mockedMyFacesTestContainer.setUp(new Object());
}
use of org.junit.runners.model.TestClass in project geode by apache.
the class PerTestClassLoaderRunner method loadClassesWithCustomClassLoader.
/**
* Load classes (TestCase, @Before and @After with custom class loader.
*
* @throws ClassNotFoundException the class not found exception
*/
private void loadClassesWithCustomClassLoader() throws ClassNotFoundException {
String classPath = System.getProperty("java.class.path");
StringTokenizer st = new StringTokenizer(classPath, ":");
List<URL> urls = new ArrayList<URL>();
while (st.hasMoreTokens()) {
String u = st.nextToken();
try {
if (!u.endsWith(".jar")) {
u += "/";
}
URL url = new URL("file://" + u);
urls.add(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
ClassLoader classLoader = new ChildFirstClassLoader(urls.toArray(new URL[] {}), Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(classLoader);
testClassFromClassLoader = new TestClass(classLoader.loadClass(getTestClass().getJavaClass().getName()));
// See withAfters and withBefores for the reason.
beforeFromClassLoader = classLoader.loadClass(Before.class.getName());
afterFromClassLoader = classLoader.loadClass(After.class.getName());
ruleFromClassLoader = classLoader.loadClass(Rule.class.getName());
testRuleFromClassLoader = classLoader.loadClass(TestRule.class.getName());
methodRuleFromClassLoader = classLoader.loadClass(MethodRule.class.getName());
}
use of org.junit.runners.model.TestClass in project ddf by codice.
the class PaxExamRule method finished.
private void finished(Description description) {
LOGGER.info("Finished {} ({}/{})", description.getMethodName(), testsExecuted, testCount);
if (testsExecuted == testCount) {
resetStaticFields();
String testClassName = description.getTestClass().getSimpleName();
try {
runAnnotations(AfterExam.class, new TestClass(description.getTestClass()));
} catch (Throwable throwable) {
failRule(testClassName, throwable, AFTER_EXAM_FAILURE_MESSAGE);
}
LOGGER.info("Finished test(s) for {}", testClassName);
}
}
Aggregations