CdiInstantiator extends AbstractCdiInstantiator { @Override public <T extends Component> T createComponent(Class<T> componentClass) { Unmanaged<T> unmanagedClass = new Unmanaged<T>(componentClass); Unmanaged.UnmanagedInstance<T> instance = unmanagedClass.newInstance(); instance.produce().inject().postConstruct(); return instance.get(); }  @Override BeanManager getBeanManager(); @Override Class<? extends VaadinService> getServiceClass(); @Override T createComponent(Class<T> componentClass);  }
@Test public void createComponent_componentIsCreated() { SingletonComponent component = instantiator .createComponent(SingletonComponent.class); Assert.assertNotNull(component); Assert.assertNotNull(component.beanManager); }
@Test public void createComponent_componentIsCreatedOnEveryCall() throws ServletException { SingletonComponent component = instantiator .createComponent(SingletonComponent.class); Assert.assertNotNull(component); SingletonComponent anotherComponent = instantiator .createComponent(SingletonComponent.class); Assert.assertNotEquals(component, anotherComponent); }