Here are the examples of the java api org.springframework.context.ApplicationContext.getBean() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
155 Examples
19
View Complete Implementation : EnableAspectJAutoProxyTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withJdkProxy() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithJdkProxy.clreplaced);
aspectIsApplied(ctx);
replacedertThat(AopUtils.isJdkDynamicProxy(ctx.getBean(FooService.clreplaced)), is(true));
}
19
View Complete Implementation : Spr15275Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testWithAbstractFactoryBeanAsReturnType() {
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithAbstractFactoryBeanAsReturnType.clreplaced);
replacedertEquals("x", context.getBean(Bar.clreplaced).foo.toString());
replacedertSame(context.getBean(FooInterface.clreplaced), context.getBean(Bar.clreplaced).foo);
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderLocation() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-location.xml", getClreplaced());
replacedertEquals("bar", applicationContext.getBean("foo"));
replacedertEquals("foo", applicationContext.getBean("bar"));
replacedertEquals("maps", applicationContext.getBean("spam"));
}
19
View Complete Implementation : AtBeanLiteModeScopeTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void prototypeLiteBean() {
replacedertNotNull(injectedPrototypeBean);
replacedertTrue(injectedPrototypeBean.isInitialized());
LifecycleBean retrievedPrototypeBean = applicationContext.getBean("prototype", LifecycleBean.clreplaced);
replacedertNotNull(retrievedPrototypeBean);
replacedertTrue(retrievedPrototypeBean.isInitialized());
replacedertNotSame(injectedPrototypeBean, retrievedPrototypeBean);
}
19
View Complete Implementation : Spr11310Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void orderedList() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced);
StringHolder holder = context.getBean(StringHolder.clreplaced);
replacedertEquals("second", holder.itemsList.get(0));
replacedertEquals("first", holder.itemsList.get(1));
replacedertEquals("unknownOrder", holder.itemsList.get(2));
}
19
View Complete Implementation : Spr15275Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testWithFactoryBean() {
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithFactoryBean.clreplaced);
replacedertEquals("x", context.getBean(Bar.clreplaced).foo.toString());
replacedertSame(context.getBean(FooInterface.clreplaced), context.getBean(Bar.clreplaced).foo);
}
19
View Complete Implementation : SpringExtensionTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
void applicationContextInjectedIntoMethod(ApplicationContext applicationContext) {
replacedertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
replacedertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.clreplaced));
}
19
View Complete Implementation : ControllerAdviceTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void modelAttributeAdvice() throws Exception {
ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.clreplaced);
RequestMappingHandlerAdapter adapter = createAdapter(context);
TestController controller = context.getBean(TestController.clreplaced);
Model model = handle(adapter, controller, "handle").getModel();
replacedertEquals(2, model.asMap().size());
replacedertEquals("lAttr1", model.asMap().get("attr1"));
replacedertEquals("gAttr2", model.asMap().get("attr2"));
}
19
View Complete Implementation : AnnotationConfigApplicationContextTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void getBeanByTypeAmbiguityRaisesException() {
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.clreplaced);
try {
context.getBean(TestBean.clreplaced);
} catch (NoSuchBeanDefinitionException ex) {
replacedertThat(ex.getMessage(), allOf(containsString("No qualifying bean of type '" + TestBean.clreplaced.getName() + "'"), containsString("tb1"), containsString("tb2")));
}
}
19
View Complete Implementation : AnnotationConfigApplicationContextTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced);
// attempt to retrieve a bean that does not exist
Clreplaced<?> targetType = Pattern.clreplaced;
try {
context.getBean(targetType);
fail("Should have thrown NoSuchBeanDefinitionException");
} catch (NoSuchBeanDefinitionException ex) {
replacedertThat(ex.getMessage(), containsString(format("No qualifying bean of type '%s'", targetType.getName())));
}
}
19
View Complete Implementation : OxmNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void jaxb2ClreplacedesToBeBoundMarshaller() {
Jaxb2Marshaller jaxb2Marshaller = applicationContext.getBean("jaxb2ClreplacedesMarshaller", Jaxb2Marshaller.clreplaced);
replacedertNotNull(jaxb2Marshaller);
}
19
View Complete Implementation : ScriptingDefaultsTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void defaultProxyTargetClreplaced() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext(PROXY_CONFIG);
Object testBean = context.getBean("testBean");
replacedertTrue(AopUtils.isCglibProxy(testBean));
}
19
View Complete Implementation : RegisterExtensionSpringExtensionTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
void applicationContextInjectedIntoMethod(ApplicationContext applicationContext) {
replacedertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
replacedertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.clreplaced));
}
19
View Complete Implementation : AutoProxyLazyInitTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withNonStaticBeanMethodAndInterface() {
MyBeanImpl.initialized = false;
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithNonStaticAndInterface.clreplaced);
MyBean bean = ctx.getBean("myBean", MyBean.clreplaced);
replacedertFalse(MyBeanImpl.initialized);
bean.doIt();
replacedertTrue(MyBeanImpl.initialized);
}
19
View Complete Implementation : ThreadPoolExecutorFactoryBeanTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void defaultExecutor() throws Exception {
ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.clreplaced);
ExecutorService executor = context.getBean("executor", ExecutorService.clreplaced);
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
@Override
public String call() throws Exception {
return "foo";
}
});
executor.execute(task);
replacedertEquals("foo", task.get());
}
19
View Complete Implementation : EnableAspectJAutoProxyTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withCglibProxy() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithCglibProxy.clreplaced);
aspectIsApplied(ctx);
replacedertThat(AopUtils.isCglibProxy(ctx.getBean(FooService.clreplaced)), is(true));
}
19
View Complete Implementation : SimplePropertyNamespaceHandlerWithExpressionLanguageTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void combineWithExpressionLanguage() {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("simplePropertyNamespaceHandlerWithExpressionLanguageTests.xml", getClreplaced());
ITestBean foo = applicationContext.getBean("foo", ITestBean.clreplaced);
ITestBean bar = applicationContext.getBean("bar", ITestBean.clreplaced);
replacedertEquals("Invalid name", "Baz", foo.getName());
replacedertEquals("Invalid name", "Baz", bar.getName());
}
19
View Complete Implementation : AnnotationDrivenBeanDefinitionParserTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void asyncPostProcessorExecutorReference() {
Object executor = context.getBean("testExecutor");
Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME);
replacedertSame(executor, ((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get());
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderSystemProperties() throws Exception {
String value = System.setProperty("foo", "spam");
try {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-system.xml", getClreplaced());
replacedertEquals("spam", applicationContext.getBean("string"));
replacedertEquals("none", applicationContext.getBean("fallback"));
} finally {
if (value != null) {
System.setProperty("foo", value);
}
}
}
19
View Complete Implementation : AtBeanLiteModeScopeTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void singletonLiteBean() {
replacedertNotNull(injectedSingletonBean);
replacedertTrue(injectedSingletonBean.isInitialized());
LifecycleBean retrievedSingletonBean = applicationContext.getBean("singleton", LifecycleBean.clreplaced);
replacedertNotNull(retrievedSingletonBean);
replacedertTrue(retrievedSingletonBean.isInitialized());
replacedertSame(injectedSingletonBean, retrievedSingletonBean);
}
19
View Complete Implementation : EnableAspectJAutoProxyTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withExposedProxy() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithExposedProxy.clreplaced);
aspectIsApplied(ctx);
replacedertThat(AopUtils.isJdkDynamicProxy(ctx.getBean(FooService.clreplaced)), is(true));
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholder() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-replace.xml", getClreplaced());
replacedertEquals("bar", applicationContext.getBean("string"));
replacedertEquals("null", applicationContext.getBean("nullString"));
}
19
View Complete Implementation : AnnotationDrivenTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void doTestWithMultipleTransactionManagers(ApplicationContext context) {
CallCountingTransactionManager tm1 = context.getBean("transactionManager1", CallCountingTransactionManager.clreplaced);
CallCountingTransactionManager tm2 = context.getBean("transactionManager2", CallCountingTransactionManager.clreplaced);
TransactionalService service = context.getBean("service", TransactionalService.clreplaced);
replacedertTrue(AopUtils.isCglibProxy(service));
service.setSomething("someName");
replacedertEquals(1, tm1.commits);
replacedertEquals(0, tm2.commits);
service.doSomething();
replacedertEquals(1, tm1.commits);
replacedertEquals(1, tm2.commits);
service.setSomething("someName");
replacedertEquals(2, tm1.commits);
replacedertEquals(1, tm2.commits);
service.doSomething();
replacedertEquals(2, tm1.commits);
replacedertEquals(2, tm2.commits);
}
19
View Complete Implementation : ImportedConfigurationClassEnhancementTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void importingNonConfigurationClreplacedCausesBeanDefinitionParsingException() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigThatImportsNonConfigClreplaced.clreplaced);
ConfigThatImportsNonConfigClreplaced config = ctx.getBean(ConfigThatImportsNonConfigClreplaced.clreplaced);
replacedertSame(ctx.getBean(TestBean.clreplaced), config.testBean);
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderLocationWithSystemPropertyForOneLocation() throws Exception {
System.setProperty("properties", "clreplacedpath*:/org/springframework/context/config/test-*.properties");
try {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-location-placeholder.xml", getClreplaced());
replacedertEquals("bar", applicationContext.getBean("foo"));
replacedertEquals("foo", applicationContext.getBean("bar"));
replacedertEquals("maps", applicationContext.getBean("spam"));
} finally {
System.clearProperty("properties");
}
}
19
View Complete Implementation : WebMvcConfigurationSupportTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void defaultPathMatchConfiguration() throws Exception {
ApplicationContext context = initContext(WebConfig.clreplaced);
UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.clreplaced);
PathMatcher pathMatcher = context.getBean(PathMatcher.clreplaced);
replacedertNotNull(urlPathHelper);
replacedertNotNull(pathMatcher);
replacedertEquals(AntPathMatcher.clreplaced, pathMatcher.getClreplaced());
}
19
View Complete Implementation : AutoProxyLazyInitTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withStaticBeanMethodAndInterface() {
MyBeanImpl.initialized = false;
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithStaticAndInterface.clreplaced);
MyBean bean = ctx.getBean("myBean", MyBean.clreplaced);
replacedertFalse(MyBeanImpl.initialized);
bean.doIt();
replacedertTrue(MyBeanImpl.initialized);
}
19
View Complete Implementation : AutoProxyLazyInitTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withNonStaticBeanMethod() {
MyBeanImpl.initialized = false;
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithNonStatic.clreplaced);
MyBean bean = ctx.getBean("myBean", MyBean.clreplaced);
replacedertFalse(MyBeanImpl.initialized);
bean.doIt();
replacedertTrue(MyBeanImpl.initialized);
}
19
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testFactoryBean() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("groovyContext.xml", getClreplaced());
Object factory = context.getBean("&factory");
replacedertTrue(factory instanceof FactoryBean);
Object result = context.getBean("factory");
replacedertTrue(result instanceof String);
replacedertEquals("test", result);
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderLocationWithSystemPropertyMissing() throws Exception {
try {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-location-placeholder.xml", getClreplaced());
replacedertEquals("bar", applicationContext.getBean("foo"));
replacedertEquals("foo", applicationContext.getBean("bar"));
replacedertEquals("maps", applicationContext.getBean("spam"));
} catch (FatalBeanException ex) {
replacedertTrue(ex.getRootCause() instanceof FileNotFoundException);
}
}
19
View Complete Implementation : AnnotationDrivenBeanDefinitionParserTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void scheduledPostProcessorSchedulerReference() {
Object scheduler = context.getBean("testScheduler");
Object postProcessor = context.getBean(TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME);
replacedertSame(scheduler, new DirectFieldAccessor(postProcessor).getPropertyValue("scheduler"));
}
19
View Complete Implementation : SpringExtensionParameterizedTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@ParameterizedTest
@CsvSource("dogbert, Dogbert")
void dogs(String beanName, String dogName, ApplicationContext context) {
replacedertEquals(dogName, context.getBean(beanName, Dog.clreplaced).getName());
}
19
View Complete Implementation : Spr11310Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void orderedArray() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced);
StringHolder holder = context.getBean(StringHolder.clreplaced);
replacedertEquals("second", holder.itemsArray[0]);
replacedertEquals("first", holder.itemsArray[1]);
replacedertEquals("unknownOrder", holder.itemsArray[2]);
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderLocationWithSystemPropertyForMultipleLocations() throws Exception {
System.setProperty("properties", "clreplacedpath*:/org/springframework/context/config/test-*.properties," + "clreplacedpath*:/org/springframework/context/config/empty-*.properties," + "clreplacedpath*:/org/springframework/context/config/missing-*.properties");
try {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-location-placeholder.xml", getClreplaced());
replacedertEquals("bar", applicationContext.getBean("foo"));
replacedertEquals("foo", applicationContext.getBean("bar"));
replacedertEquals("maps", applicationContext.getBean("spam"));
} finally {
System.clearProperty("properties");
}
}
19
View Complete Implementation : DelegatingSmartContextLoaderTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void replacedertApplicationContextLoadsAndContainsFooString(MergedContextConfiguration mergedConfig) throws Exception {
ApplicationContext applicationContext = loader.loadContext(mergedConfig);
replacedertNotNull(applicationContext);
replacedertEquals("foo", applicationContext.getBean(String.clreplaced));
replacedertTrue(applicationContext instanceof ConfigurableApplicationContext);
((ConfigurableApplicationContext) applicationContext).close();
}
19
View Complete Implementation : Spr7816Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void spr7816() {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("spr7816.xml", getClreplaced());
FilterAdapter adapter = ctx.getBean(FilterAdapter.clreplaced);
replacedertEquals(Building.clreplaced, adapter.getSupportedTypes().get("Building"));
replacedertEquals(Entrance.clreplaced, adapter.getSupportedTypes().get("Entrance"));
replacedertEquals(Dwelling.clreplaced, adapter.getSupportedTypes().get("Dwelling"));
}
19
View Complete Implementation : AutoProxyLazyInitTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void withStaticBeanMethod() {
MyBeanImpl.initialized = false;
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithStatic.clreplaced);
MyBean bean = ctx.getBean("myBean", MyBean.clreplaced);
replacedertFalse(MyBeanImpl.initialized);
bean.doIt();
replacedertTrue(MyBeanImpl.initialized);
}
19
View Complete Implementation : Spr6602Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void doreplacedertions(ApplicationContext ctx) throws Exception {
Foo foo = ctx.getBean(Foo.clreplaced);
Bar bar1 = ctx.getBean(Bar.clreplaced);
Bar bar2 = ctx.getBean(Bar.clreplaced);
replacedertThat(bar1, is(bar2));
replacedertThat(bar1, is(foo.bar));
BarFactory barFactory1 = ctx.getBean(BarFactory.clreplaced);
BarFactory barFactory2 = ctx.getBean(BarFactory.clreplaced);
replacedertThat(barFactory1, is(barFactory2));
Bar bar3 = barFactory1.getObject();
Bar bar4 = barFactory1.getObject();
replacedertThat(bar3, is(not(bar4)));
}
19
View Complete Implementation : ImportedConfigurationClassEnhancementTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void autowiredConfigClreplacedIsEnhanced(Clreplaced<?>... configClreplacedes) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClreplacedes);
Config config = ctx.getBean(Config.clreplaced);
replacedertTrue("autowired config clreplaced has not been enhanced", ClreplacedUtils.isCglibProxy(config.autowiredConfig));
}
19
View Complete Implementation : Spr15275Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testWithFinalFactoryBean() {
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithFinalFactoryBean.clreplaced);
replacedertEquals("x", context.getBean(Bar.clreplaced).foo.toString());
replacedertSame(context.getBean(FooInterface.clreplaced), context.getBean(Bar.clreplaced).foo);
}
19
View Complete Implementation : AnnotationConfigApplicationContextTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void getBeanByType() {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced);
TestBean testBean = context.getBean(TestBean.clreplaced);
replacedertNotNull(testBean);
replacedertThat(testBean.name, equalTo("foo"));
}
19
View Complete Implementation : ConvertingEncoderDecoderSupport.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
/**
* Strategy method used to obtain the {@link ConversionService}. By default this
* method expects a bean named {@code 'webSocketConversionService'} in the
* {@link #getApplicationContext() active ApplicationContext}.
* @return the {@link ConversionService} (never null)
*/
protected ConversionService getConversionService() {
ApplicationContext applicationContext = getApplicationContext();
replacedert.state(applicationContext != null, "Unable to locate the Spring ApplicationContext");
try {
return applicationContext.getBean(CONVERSION_SERVICE_BEAN_NAME, ConversionService.clreplaced);
} catch (BeansException ex) {
throw new IllegalStateException("Unable to find ConversionService: please configure a '" + CONVERSION_SERVICE_BEAN_NAME + "' or override the getConversionService() method", ex);
}
}
19
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void propertyPlaceholderIgnored() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-replace-ignore.xml", getClreplaced());
replacedertEquals("${bar}", applicationContext.getBean("string"));
replacedertEquals("null", applicationContext.getBean("nullString"));
}
19
View Complete Implementation : Spr11202Tests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testWithImporter() {
ApplicationContext context = new AnnotationConfigApplicationContext(Wrapper.clreplaced);
replacedertEquals("foo", context.getBean("value"));
}
19
View Complete Implementation : ObjenesisProxyTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void appliesAspectToClreplacedWithComplexConstructor() {
@SuppressWarnings("resource")
ApplicationContext context = new ClreplacedPathXmlApplicationContext("ObjenesisProxyTests-context.xml", getClreplaced());
ClreplacedWithComplexConstructor bean = context.getBean(ClreplacedWithComplexConstructor.clreplaced);
bean.method();
DebugInterceptor interceptor = context.getBean(DebugInterceptor.clreplaced);
replacedertThat(interceptor.getCount(), is(1L));
replacedertThat(bean.getDependency().getValue(), is(1));
}
19
View Complete Implementation : AbstractView.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
/**
* Return the {@link RequestDataValueProcessor} to use.
* <p>The default implementation looks in the {@link #getApplicationContext()
* Spring configuration} for a {@code RequestDataValueProcessor} bean with
* the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}.
* @return the RequestDataValueProcessor, or null if there is none at the
* application context.
*/
@Nullable
protected RequestDataValueProcessor getRequestDataValueProcessor() {
ApplicationContext context = getApplicationContext();
if (context != null && context.containsBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) {
return context.getBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.clreplaced);
}
return null;
}
19
View Complete Implementation : ConversionServiceFactoryBeanTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void doTestConversionServiceInApplicationContext(String fileName, Clreplaced<?> resourceClreplaced) {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext(fileName, getClreplaced());
ResourceTestBean tb = ctx.getBean("resourceTestBean", ResourceTestBean.clreplaced);
replacedertTrue(resourceClreplaced.isInstance(tb.getResource()));
replacedertTrue(tb.getResourceArray().length > 0);
replacedertTrue(resourceClreplaced.isInstance(tb.getResourceArray()[0]));
replacedertTrue(tb.getResourceMap().size() == 1);
replacedertTrue(resourceClreplaced.isInstance(tb.getResourceMap().get("key1")));
replacedertTrue(tb.getResourceArrayMap().size() == 1);
replacedertTrue(tb.getResourceArrayMap().get("key1").length > 0);
replacedertTrue(resourceClreplaced.isInstance(tb.getResourceArrayMap().get("key1")[0]));
}
19
View Complete Implementation : BeanNameViewResolver.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Override
@Nullable
public View resolveViewName(String viewName, Locale locale) throws BeansException {
ApplicationContext context = obtainApplicationContext();
if (!context.containsBean(viewName)) {
// Allow for ViewResolver chaining...
return null;
}
if (!context.isTypeMatch(viewName, View.clreplaced)) {
if (logger.isDebugEnabled()) {
logger.debug("Found bean named '" + viewName + "' but it does not implement View");
}
// Since we're looking into the general ApplicationContext here,
// let's accept this as a non-match and allow for chaining as well...
return null;
}
return context.getBean(viewName, View.clreplaced);
}
19
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testWithTwoClreplacedesDefinedInTheOneGroovyFile_WrongClreplacedFirst() throws Exception {
try {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("twoClreplacedesWrongOneFirst.xml", getClreplaced());
ctx.getBean("messenger", Messenger.clreplaced);
fail("Must have failed: two clreplacedes defined in GroovyScriptFactory source, non-Messenger clreplaced defined first.");
}// just testing for failure here, hence catching Exception...
catch (Exception expected) {
}
}
19
View Complete Implementation : ImportedConfigurationClassEnhancementTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
private void autowiredConfigClreplacedBeanMethodsRespectScoping(Clreplaced<?>... configClreplacedes) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClreplacedes);
Config config = ctx.getBean(Config.clreplaced);
TestBean testBean1 = config.autowiredConfig.testBean();
TestBean testBean2 = config.autowiredConfig.testBean();
replacedertThat("got two distinct instances of testBean when singleton scoping was expected", testBean1, sameInstance(testBean2));
}