@Handler(value = "Timers", scope = Scope.FEATURE) @SuppressWarnings("UnusedDeclaration") public class TimersHandler {
public void createFeatureScopedHandlers() throws Exception { for (Class handlerClass : orderedHandlerClasses) { //create a new SCENARIO scoped handler Handler handlerAnnotation = (Handler) handlerClass.getAnnotation(Handler.class); if (handlerAnnotation.scope() != Scope.SCENARIO) { //feature or unmanaged Object handler = createAndInitHandlerInstance(handlerClass); featureScopedHandlers.put(handlerClass, handler); log.debug("Created new feature scoped handler: " + handlerAnnotation.value()); } } }
/** * Create a StepInvoker from an instance of a class annotated with @Handler * @param handlerInstance */ public HandlerClassInvokerFactory(Object handlerInstance) { Objects.requireNonNull(handlerInstance, "Handler instance cannot be null"); this.handlerInstance = handlerInstance; Class<?> handlerClazz = handlerInstance.getClass(); Handler handlerAnnotation = handlerClazz.getAnnotation(Handler.class); this.handlerName = handlerAnnotation == null ? handlerClazz.getName() : handlerAnnotation.value(); }
/** * Scope is starting, perform the required processing on the supplied handlers. */ public void processStartOfScope(Scope scopeStarting, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope handlerScope = handlerAnnotation.scope(); injectResourceFieldsForScope(scopeStarting, handler, handlerScope, handlerInstances); runLifecycleMethods(handler, handlerScope, scopeStarting, false); } }
private Object getHandlerResource(String resourceName, Iterable<Object> handlerInstances) { Object o = null; String handlerName = resourceName.substring(ChorusResource.handlerPrefix.length()); for ( Object handlerInstance : handlerInstances) { Handler h = handlerInstance.getClass().getAnnotation(Handler.class); if ( handlerName.trim().toLowerCase().equals(h.value().trim().toLowerCase())) { o = handlerInstance; break; } } if ( o == null) { log.warn("Could not find a handler named " + handlerName + " to inject field annotated @ChorusResource(\"handler." + handlerName + "\", missing Uses: statement?"); } return o; }
/** * Scope is ending, perform the required processing on the supplied handlers. */ public void processEndOfScope(Scope scopeEnding, Iterable<Object> handlerInstances) throws Exception { for (Object handler : handlerInstances) { Handler handlerAnnotation = handler.getClass().getAnnotation(Handler.class); Scope scope = handlerAnnotation.scope(); runLifecycleMethods(handler, scope, scopeEnding, true); //dispose handler instances with a scope which matches the scopeEnding if (scope == scopeEnding) { disposeSpringResources(handler, scopeEnding); } } }
@Handler("Web Agent Self Test") public class WebAgentSelfTestHandler {
for (Class handlerClass : classes) { Handler f = (Handler) handlerClass.getAnnotation(Handler.class); String handlerName = f.value(); if (handlerNameToHandlerClass.containsKey(handlerName)) { String currentHandler = handlerNameToHandlerClass.get(handlerName).getName();
public List<Object> getOrCreateHandlersForScenario() throws Exception { List<Object> handlerInstances = new ArrayList<>(); for ( Class handlerClass : orderedHandlerClasses ) { Handler handlerAnnotation = (Handler) handlerClass.getAnnotation(Handler.class); if ( handlerAnnotation.scope() != Scope.SCENARIO ) { Object handler = featureScopedHandlers.get(handlerClass); assert(handler != null); //must have been created during createFeatureScopedHandlers log.debug("Adding feature scoped handler " + handler + " class " + handlerClass); handlerInstances.add(handler); } else { log.debug("Creating scenario scoped handler " + handlerClass); Object handler = createAndInitHandlerInstance(handlerClass); handlerInstances.add(handler); } } return handlerInstances; }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Start A Process With Classpath") public class ProcessWithClasspathHandler extends ChorusAssert { @Step("Chorus is working properly") public void isWorkingProperly() { } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Process With Configurations") public class ProcessWithConfigurationsHandler extends ChorusAssert { @Step("Chorus is working properly") public void isWorkingProperly() { } }
@Handler("Test Step Publisher Handler") public static class MockHandler { @Step(value = "call a test step", id = "step1") public void callATestStep() { System.out.println("Hello!"); stepCalled.set(true); } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Feature Parsing") public class FeatureParsingHandler { @Step("Chorus is working properly") public void isWorkingProperly() { } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Start A Process Without Logging") public class StartAProcessHandler extends ChorusAssert { @Step("Chorus is working properly") public void isWorkingProperly() { } }
@Handler("DynamicProcessHandler") public static class DynamicProcessHandler { @Step(".*call an exported method") public String callMethod() { return "dumbledore"; } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Default Properties") public class DefaultPropertiesHandler extends ChorusAssert { @Step("call a remote method") public String callARemoteMethod() { return "true"; } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("JMX With Configurations") public class JmxWithConfigurationsHandler extends ChorusAssert { @Step("I can call a step method exported by the handler") public void canCallAMethod() { } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Feature Scoped Process") public class FeatureScopedProcessHandler extends ChorusAssert { @Step(".*say hello") public void isWorkingProperly() { } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Check Running") public class CheckRunningHandler extends ChorusAssert { @Step("Chorus is working properly") public void isWorkingProperly() { } }
/** * Created by IntelliJ IDEA. * User: Nick Ebbutt * Date: 14/06/12 * Time: 09:21 */ @Handler("Remoting Handler For Export") public class RemotingHandlerForExport extends ChorusAssert { @Step("I can call a step method exported by the handler") public void canCallAMethod() { } }