@Override protected void doEvaluation(TestRunnerFacade facade, TestRunnerContext context) throws Throwable { facade.runTestMethodInEjbContext(new TestRunnerAnnotationHandler(method, description, context)); // facade.runTestMethodInEjbContext(method.getDeclaringClass().getName(), method.getName(), context); } }
UUID getUuid() { return this.getContext() != null ? this.getContext().getUuid() : null; }
/** * Runs the actual test method. * <p> * This is intended to be used by remote tests that need to run the test method in another VM as the JUnit test runs. * @throws Exception */ public final void executeTestMethod(TxHandler txHandler) throws Exception { // Get an instance of the test method so we can invoke it Class<?> clazz = Class.forName(this.testClassName); Object instance = clazz.newInstance(); Method method = clazz.getMethod(this.testMethodName); this.initTestClass(instance, txHandler); // Invoke the method try { method.invoke(instance); } catch (Exception ex) { this.handleServerThrowable(ex); } } }
@Override protected void doEvaluation(TestRunnerFacade facade, TestRunnerContext context) throws Throwable { TestRunnerAnnotationHandler handler = new TestRunnerAnnotationHandler(method, description, context); // Run the pre actions SystemPropertyTempSetter tempSetter = facade.runPreTestActionsInEjbContext(handler); try { // Run the test statement first. We'll only run the verifiers if the test statement succeeds testStatement.evaluate(); // Run the verifiers now facade.runPostTestActionsInEjbContext(handler); } finally { logger.debug("Cleaning up test run for context: " + handler.getUuid()); facade.cleanupTestRun(handler, tempSetter); } } }
@Override public void runPostTestActionsInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { // Run post server annotations in an own annotation so any changed made there is available in the export / verifying phase try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePostServerCode(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } // Run post test annotations (export, verify) try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePostTestAnnotations(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } } }
@Override public SystemPropertyTempSetter runPreTestActionsInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { SystemPropertyTempSetter tempSetter = handler.initContainerTestEnv(); try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePreTestAnnotations(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } catch (Exception ex) { // Reset properties in case of an exception tempSetter.close(); throw ex; } return tempSetter; } }
@Override public void runTestMethodInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { try (TxHandler txHandler = new TxHandler(this.tx, true)) { logger.debug(String.format("Running Test %s", handler)); // this.dateProvider.resetProvider(); // Run the test method handler.executeTestMethod(txHandler); txHandler.commit(); // Perform a commit after the execution of the test method } } }
@Override protected void doEvaluation(TestRunnerFacade facade, TestRunnerContext context) throws Throwable { TestRunnerAnnotationHandler handler = new TestRunnerAnnotationHandler(method, description, context); // Run the pre actions SystemPropertyTempSetter tempSetter = facade.runPreTestActionsInEjbContext(handler); try { // Run the test statement first. We'll only run the verifiers if the test statement succeeds testStatement.evaluate(); // Run the verifiers now facade.runPostTestActionsInEjbContext(handler); } finally { logger.debug("Cleaning up test run for context: " + handler.getUuid()); facade.cleanupTestRun(handler, tempSetter); } } }
@Override public void runPostTestActionsInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { // Run post server annotations in an own annotation so any changed made there is available in the export / verifying phase try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePostServerCode(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } // Run post test annotations (export, verify) try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePostTestAnnotations(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } } }
@Override public SystemPropertyTempSetter runPreTestActionsInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { SystemPropertyTempSetter tempSetter = handler.initContainerTestEnv(); try (TxHandler txHandler = new TxHandler(this.tx, true)) { // Execute post test annotations (dataset exporting, data verifying) handler.executePreTestAnnotations(new JuEmUtil(this.em)); txHandler.commit(); // Commit after data verifying / exporting } catch (Exception ex) { // Reset properties in case of an exception tempSetter.close(); throw ex; } return tempSetter; } }
@Override public void runTestMethodInEjbContext(TestRunnerAnnotationHandler handler) throws Exception { try (ContainerTestContextSetter s = handler.new ContainerTestContextSetter()) { try (TxHandler txHandler = new TxHandler(this.tx, true)) { logger.debug(String.format("Running Test %s", handler)); // this.dateProvider.resetProvider(); // Run the test method handler.executeTestMethod(txHandler); txHandler.commit(); // Perform a commit after the execution of the test method } } }
UUID getUuid() { return this.getContext() != null ? this.getContext().getUuid() : null; }
/** * Runs the actual test method. * <p> * This is intended to be used by remote tests that need to run the test method in another VM as the JUnit test runs. * @throws Exception */ public final void executeTestMethod(TxHandler txHandler) throws Exception { // Get an instance of the test method so we can invoke it Class<?> clazz = Class.forName(this.testClassName); Object instance = clazz.newInstance(); Method method = clazz.getMethod(this.testMethodName); this.initTestClass(instance, txHandler); // Invoke the method try { method.invoke(instance); } catch (Exception ex) { this.handleServerThrowable(ex); } } }
@Override protected void doEvaluation(TestRunnerFacade facade, TestRunnerContext context) throws Throwable { facade.runTestMethodInEjbContext(new TestRunnerAnnotationHandler(method, description, context)); // facade.runTestMethodInEjbContext(method.getDeclaringClass().getName(), method.getName(), context); } }
public ContainerTestContextSetter() { ContainerTestContext.startContext(getContext() != null ? getContext().getUuid() : null); }
public ContainerTestContextSetter() { ContainerTestContext.startContext(getContext() != null ? getContext().getUuid() : null); }
@Override protected String getLocalRoot() { return this.getContext().getLocalRoot(); }
@Override protected String getLocalRoot() { return this.getContext().getLocalRoot(); }
private void initTestClass(Object instance, TxHandler txHandler) { // Try to set the context (if the class is ContextAware) if (ContextAware.class.isAssignableFrom(instance.getClass())) { ((ContextAware) instance).setContext(this.getContext()); } if (TransactionAware.class.isAssignableFrom(instance.getClass())) { ((TransactionAware) instance).setTxHandler(txHandler); } // Try to call the init method (if the class implements Initializable) if (Initializable.class.isAssignableFrom(instance.getClass())) { ((Initializable) instance).init(); } }
private void initTestClass(Object instance, TxHandler txHandler) { // Try to set the context (if the class is ContextAware) if (ContextAware.class.isAssignableFrom(instance.getClass())) { ((ContextAware) instance).setContext(this.getContext()); } if (TransactionAware.class.isAssignableFrom(instance.getClass())) { ((TransactionAware) instance).setTxHandler(txHandler); } // Try to call the init method (if the class implements Initializable) if (Initializable.class.isAssignableFrom(instance.getClass())) { ((Initializable) instance).init(); } }