BeanFactory { public static <T> T createBean(final Class<T> clazz) { final Class<?> bpClass = tryLoadClassForName("org.apache.deltaspike.core.api.provider.BeanProvider"); if (bpClass != null) { try { final Method getContextualReference = bpClass.getMethod("getContextualReference", Class.class, Annotation[].class); return clazz.cast(getContextualReference.invoke(null, clazz, new Annotation[0])); } catch (final Exception e) { } } return createInstance(clazz); } private  BeanFactory(); static T createBean(final Class<T> clazz);  }
@Test public void testBeanCreationWithDefaultConstructorWithoutUsingCDI() { final ClassA bean = BeanFactory.createBean(ClassA.class); assertThat(bean, notNullValue()); }
@Test(expected = JpaUnitException.class) public void testBeanCreationWithoutDefaultConstructorWithoutUsingCDI() { BeanFactory.createBean(ClassB.class); }
@Test(expected = JpaUnitException.class) public void testBeanCreationWithErrorDuringConstructionWithoutUsingCDI() { BeanFactory.createBean(ClassC.class); }