use of cn.taketoday.beans.factory.config.ServiceLocatorFactoryBean in project today-infrastructure by TAKETODAY.
the class ServiceLocatorFactoryBeanTests method testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testWhenServiceLocatorExceptionClassIsNotAnExceptionSubclass() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
assertThatIllegalArgumentException().isThrownBy(() -> factory.setServiceLocatorExceptionClass((Class) getClass()));
// should throw, bad (non-Exception-type) serviceLocatorException class supplied
}
use of cn.taketoday.beans.factory.config.ServiceLocatorFactoryBean in project today-infrastructure by TAKETODAY.
the class ServiceLocatorFactoryBeanTests method testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor.
@Test
public void testWhenServiceLocatorExceptionClassToExceptionTypeWithOnlyNoArgCtor() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
assertThatIllegalArgumentException().isThrownBy(() -> factory.setServiceLocatorExceptionClass(ExceptionClassWithOnlyZeroArgCtor.class));
// should throw, bad (invalid-Exception-type) serviceLocatorException class supplied
}
use of cn.taketoday.beans.factory.config.ServiceLocatorFactoryBean in project today-infrastructure by TAKETODAY.
the class ServiceLocatorFactoryBeanTests method testWhenServiceLocatorMethodCalledWithTooManyParameters.
@Test
public void testWhenServiceLocatorMethodCalledWithTooManyParameters() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorInterface(ServiceLocatorInterfaceWithExtraNonCompliantMethod.class);
factory.afterPropertiesSet();
ServiceLocatorInterfaceWithExtraNonCompliantMethod locator = (ServiceLocatorInterfaceWithExtraNonCompliantMethod) factory.getObject();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> locator.getTestService("not", "allowed"));
}
use of cn.taketoday.beans.factory.config.ServiceLocatorFactoryBean in project today-framework by TAKETODAY.
the class ServiceLocatorFactoryBeanTests method testRequiresListableBeanFactoryAndChokesOnAnythingElse.
@Test
public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception {
BeanFactory beanFactory = mock(BeanFactory.class);
try {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setBeanFactory(beanFactory);
} catch (FatalBeanException ex) {
// expected
}
}
use of cn.taketoday.beans.factory.config.ServiceLocatorFactoryBean in project today-framework by TAKETODAY.
the class ServiceLocatorFactoryBeanTests method testWhenServiceLocatorInterfaceIsNotAnInterfaceType.
@Test
public void testWhenServiceLocatorInterfaceIsNotAnInterfaceType() throws Exception {
ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
factory.setServiceLocatorInterface(getClass());
assertThatIllegalArgumentException().isThrownBy(factory::afterPropertiesSet);
// should throw, bad (non-interface-type) serviceLocator interface supplied
}
Aggregations