WeldAnnotatedPathRunner.java

  1. package org.jbehave.core.junit.weld;

  2. import org.jbehave.core.configuration.AnnotationBuilder;
  3. import org.jbehave.core.configuration.weld.WeldAnnotationBuilder;
  4. import org.jbehave.core.configuration.weld.WeldBootstrap;
  5. import org.jbehave.core.junit.AnnotatedPathRunner;
  6. import org.junit.runners.model.InitializationError;

  7. /**
  8.  * AnnotatedPathRunner that uses {@link WeldAnnotationBuilder}.
  9.  *
  10.  * @author Aaron Walker
  11.  */
  12. public class WeldAnnotatedPathRunner extends AnnotatedPathRunner {

  13.     private WeldBootstrap container;

  14.     public WeldAnnotatedPathRunner(Class<?> testClass) throws InitializationError {
  15.         super(testClass);

  16.     }

  17.     @Override
  18.     public AnnotationBuilder annotationBuilder() {
  19.         if (container == null) {
  20.             container = new WeldBootstrap();
  21.             container.initialize();
  22.         }
  23.         return container.findAnnotationBuilder(testClass());
  24.     }
  25. }