Ejemplo n.º 1
0
  StandardProcessorTestRunner(final Processor processor) {
    this.processor = processor;
    this.idGenerator = new AtomicLong(0L);
    this.sharedState = new SharedSessionState(processor, idGenerator);
    this.flowFileQueue = sharedState.getFlowFileQueue();
    this.sessionFactory = new MockSessionFactory(sharedState, processor);
    this.processorStateManager = new MockStateManager(processor);
    this.context = new MockProcessContext(processor, processorStateManager);

    detectDeprecatedAnnotations(processor);

    final MockProcessorInitializationContext mockInitContext =
        new MockProcessorInitializationContext(processor, context);
    processor.initialize(mockInitContext);
    logger = mockInitContext.getLogger();

    try {
      ReflectionUtils.invokeMethodsWithAnnotation(OnAdded.class, processor);
    } catch (final Exception e) {
      Assert.fail("Could not invoke methods annotated with @OnAdded annotation due to: " + e);
    }

    triggerSerially = null != processor.getClass().getAnnotation(TriggerSerially.class);

    ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnConfigurationRestored.class, processor);
  }