private synchronized StagedExamReactor prepareReactor() throws Exception { ConfigurationManager cm = new ConfigurationManager(); String systemType = cm.getProperty(Constants.EXAM_SYSTEM_KEY); if (Constants.EXAM_SYSTEM_DEFAULT.equals(systemType)) { m_system = DefaultExamSystem.create(new Option[0]); } else { m_system = PaxExamRuntime.createTestSystem(); } Class<?> testClass = getTestClass().getJavaClass(); Object testClassInstance = testClass.newInstance(); ExamReactor reactor = getReactor(testClass); addConfigurationsToReactor(reactor, testClass, testClassInstance); addTestsToReactor(reactor, testClass, testClassInstance); return reactor.stage(getFactory(testClass)); }
private void addConfigurationsToReactor( ExamReactor reactor, Class<?> testClass, Object testClassInstance) throws IllegalAccessException, InvocationTargetException, IllegalArgumentException, IOException { Method[] methods = testClass.getMethods(); for (Method m : methods) { Configuration conf = m.getAnnotation(Configuration.class); if (conf != null) { // consider as option, so prepare that one: reactor.addConfiguration(((Option[]) m.invoke(testClassInstance))); } } }
private void addTestsToReactor(ExamReactor reactor, Class<?> testClass, Object testClassInstance) throws IOException, ExamConfigurationException { TestProbeBuilder probe = m_system.createProbe(); probe = overwriteWithUserDefinition(testClass, testClassInstance, probe); // probe.setAnchor( testClass ); for (FrameworkMethod s : super.getChildren()) { // record the method -> adress matching TestAddress address = delegateTest(testClassInstance, probe, s); if (address == null) { address = probe.addTest(testClass, s.getMethod().getName()); } m_map.put(address, s); } reactor.addProbe(probe.build()); }