Here are the examples of the java api org.springframework.context.ApplicationContext.getBeansOfType() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
155 Examples
18
View Complete Implementation : TransactionExceptionTranslatorRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
/**
* Registers all {@link TransactionExceptionTranslator TransactionExceptionTranslators} in the
* given application context with the {@link TransactionExceptionTranslatorRegistry}.
*
* @param applicationContext application context
*/
public void register(ApplicationContext applicationContext) {
applicationContext.getBeansOfType(TransactionExceptionTranslator.clreplaced).values().forEach(transactionExceptionTranslatorRegistry::register);
}
18
View Complete Implementation : DefaultEndpointFactory.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
private Map<String, AnnotationConfigParser> getAnnotationParser(ApplicationContext applicationContext) {
return applicationContext.getBeansOfType(AnnotationConfigParser.clreplaced);
}
18
View Complete Implementation : DefaultEndpointFactory.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
private Map<String, EndpointComponent> getEndpointComponents(ApplicationContext applicationContext) {
return applicationContext.getBeansOfType(EndpointComponent.clreplaced);
}
17
View Complete Implementation : TestSuiteTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@BeforeClreplaced
public void setup() {
testSuiteListeners.addTestSuiteListener(testSuiteListener);
when(applicationContextMock.getBean(TestContextFactory.clreplaced)).thenReturn(testContextFactory);
when(applicationContextMock.getBeansOfType(SequenceAfterSuite.clreplaced)).thenReturn(Collections.singletonMap("afterActions", afterActions));
when(applicationContextMock.getBeansOfType(SequenceBeforeSuite.clreplaced)).thenReturn(Collections.singletonMap("beforeActions", beforeActions));
when(applicationContextMock.getBean(TestSuiteListeners.clreplaced)).thenReturn(testSuiteListeners);
when(applicationContextMock.getBean(TestListeners.clreplaced)).thenReturn(new TestListeners());
citrus = Citrus.newInstance(applicationContextMock);
}
17
View Complete Implementation : ConfigurationClassAspectIntegrationTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void withInnerClreplacedAndLambdaExpression() {
ApplicationContext ctx = new AnnotationConfigApplicationContext(Application.clreplaced, CountingAspect.clreplaced);
ctx.getBeansOfType(Runnable.clreplaced).forEach((k, v) -> v.run());
replacedertEquals(2, ctx.getBean(CountingAspect.clreplaced).count);
}
17
View Complete Implementation : ExceptionResponseGeneratorRegistrarTest.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
@Test
void testRegister() {
ExceptionResponseGenerator exceptionResponseGenerator = mock(ExceptionResponseGenerator.clreplaced);
ApplicationContext applicationContext = mock(ApplicationContext.clreplaced);
when(applicationContext.getBeansOfType(ExceptionResponseGenerator.clreplaced)).thenReturn(singletonMap("exceptionResponseGenerator", exceptionResponseGenerator));
exceptionResponseGeneratorRegistrar.register(applicationContext);
verify(exceptionResponseGeneratorRegistry).registerExceptionResponseGenerator(exceptionResponseGenerator);
}
17
View Complete Implementation : DefaultTestRunner.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
protected void initialize() {
testCase.setTestRunner(true);
testCase.setTestActionListeners(applicationContext.getBean(TestActionListeners.clreplaced));
if (!applicationContext.getBeansOfType(SequenceBeforeTest.clreplaced).isEmpty()) {
testCase.setBeforeTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceBeforeTest.clreplaced).values().toArray()));
}
if (!applicationContext.getBeansOfType(SequenceAfterTest.clreplaced).isEmpty()) {
testCase.setAfterTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceAfterTest.clreplaced).values().toArray()));
}
}
17
View Complete Implementation : Jsr330AnnotationsScanKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
private <T> T getService(ApplicationContext context, Clreplaced<T> serviceClreplaced) {
replacedertFalse("Please enable scanning on " + serviceClreplaced.getName() + " with @Named annotation", context.getBeansOfType(serviceClreplaced).isEmpty());
return context.getBean(serviceClreplaced);
}
17
View Complete Implementation : SpringAnnotationsScanKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
private <T> T getService(ApplicationContext context, Clreplaced<T> serviceClreplaced) {
replacedertFalse("Please enable scanning on " + serviceClreplaced.getName() + " with @Service annotation", context.getBeansOfType(serviceClreplaced).isEmpty());
return context.getBean(serviceClreplaced);
}
17
View Complete Implementation : XmlSimplifiedKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testInnerBean() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("inner-beans.xml");
replacedertNotNull("Please inject an instance of EmptyBean into sampleBean", context.getBean("sampleBean", SampleBean.clreplaced).getBeanDependency());
replacedertTrue("Please make the definition of EmptyBean anonymous, so the bean can't be retrieved", context.getBeansOfType(EmptyBean.clreplaced).isEmpty());
}
17
View Complete Implementation : DefaultTestDesigner.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
protected void initialize() {
testCase.setTestActionListeners(applicationContext.getBean(TestActionListeners.clreplaced));
if (!applicationContext.getBeansOfType(SequenceBeforeTest.clreplaced).isEmpty()) {
testCase.setBeforeTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceBeforeTest.clreplaced).values().toArray()));
}
if (!applicationContext.getBeansOfType(SequenceAfterTest.clreplaced).isEmpty()) {
testCase.setAfterTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceAfterTest.clreplaced).values().toArray()));
}
}
17
View Complete Implementation : Jsr330AnnotationsScanKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
private <T> T getService(ApplicationContext context, Clreplaced<T> serviceClreplaced) {
replacedertFalse("Please enable scanning on " + serviceClreplaced.getName() + " with @Named annotation", context.getBeansOfType(serviceClreplaced).isEmpty());
return context.getBean(serviceClreplaced);
}
16
View Complete Implementation : SettingsPopulator.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void initialize(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
ctx.getBeansOfType(DefaultSettingsEnreplacedyType.clreplaced).values().forEach(this::initialize);
}
16
View Complete Implementation : NamespacesKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testListOfBeansWithOneRegularAndOneAnonymous() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("util-namespace.xml");
@SuppressWarnings({ "unchecked" })
List<EmptyBean> listOfBeans = context.getBean("listOfBeans", List.clreplaced);
replacedertEquals("Please make sure only 1 bean of type EmptyBean is declared in the XML as a top-level bean", 1, context.getBeansOfType(EmptyBean.clreplaced).size());
replacedertTrue("Please make sure the first element of 'listOfBeans' is the top-level bean", context.getBean(EmptyBean.clreplaced) == listOfBeans.get(0));
}
16
View Complete Implementation : NamespacesKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testListOfBeansWithOneRegularAndOneAnonymous() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("util-namespace.xml");
@SuppressWarnings({ "unchecked" })
List<EmptyBean> listOfBeans = context.getBean("listOfBeans", List.clreplaced);
replacedertEquals("Please make sure only 1 bean of type EmptyBean is declared in the XML as a top-level bean", 1, context.getBeansOfType(EmptyBean.clreplaced).size());
replacedertTrue("Please make sure the first element of 'listOfBeans' is the top-level bean", context.getBean(EmptyBean.clreplaced) == listOfBeans.get(0));
}
16
View Complete Implementation : NamespacesKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testMapOfBeansWithOneRegularAndOneAnonymous() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("util-namespace.xml");
@SuppressWarnings({ "unchecked" })
Map<Integer, EmptyBean> mapOfBeans = context.getBean("mapOfBeans", Map.clreplaced);
replacedertEquals("Please make sure only 1 bean of type EmptyBean is declared in the XML as a top-level bean", 1, context.getBeansOfType(EmptyBean.clreplaced).size());
replacedertTrue("Please make sure the entry in 'mapOfBeans' under key 1 is the top-level bean", context.getBean(EmptyBean.clreplaced) == mapOfBeans.get(1));
}
16
View Complete Implementation : ApplicationContextKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testKoan6CreateApplicationContextWithTwoQualifyingBeansRetrievedByType() {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("two-bean.xml");
Map<String, Repository> beansRetrievedByType = applicationContext.getBeansOfType(Repository.clreplaced);
replacedertNotNull("Beans retrieved from the ApplicationContext should not be null", beansRetrievedByType);
replacedertTrue("Should have two beans of the Repository type in the ApplicationContext", beansRetrievedByType.size() == 2);
replacedertNotNull("Should have a bean with an id of sampleBean1", beansRetrievedByType.get("sampleBean1"));
replacedertNotNull("Should have a bean with an id of sampleBean2", beansRetrievedByType.get("sampleBean2"));
}
16
View Complete Implementation : NamespacesKoan.java
Copyright Apache License 2.0
Author : opencredo
Copyright Apache License 2.0
Author : opencredo
public void testMapOfBeansWithOneRegularAndOneAnonymous() {
ApplicationContext context = new ClreplacedPathXmlApplicationContext("util-namespace.xml");
@SuppressWarnings({ "unchecked" })
Map<Integer, EmptyBean> mapOfBeans = context.getBean("mapOfBeans", Map.clreplaced);
replacedertEquals("Please make sure only 1 bean of type EmptyBean is declared in the XML as a top-level bean", 1, context.getBeansOfType(EmptyBean.clreplaced).size());
replacedertTrue("Please make sure the entry in 'mapOfBeans' under key 1 is the top-level bean", context.getBean(EmptyBean.clreplaced) == mapOfBeans.get(1));
}
16
View Complete Implementation : DynamicRepositoryDecoratorFactoryRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ApplicationContext context) {
Map<String, DynamicRepositoryDecoratorFactory> repositoryDecoratorFactoryMap = context.getBeansOfType(DynamicRepositoryDecoratorFactory.clreplaced);
repositoryDecoratorFactoryMap.values().forEach(repositoryDecoratorRegistry::addFactory);
}
16
View Complete Implementation : ExceptionResponseGeneratorRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ApplicationContext applicationContext) {
Map<String, ExceptionResponseGenerator> responseGeneratorMap = applicationContext.getBeansOfType(ExceptionResponseGenerator.clreplaced);
responseGeneratorMap.values().forEach(this::registerResponseGenerator);
}
16
View Complete Implementation : DynamicRepositoryDecoratorFactoryRegistrarTest.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
@Test
void testRegister() {
Map<String, DynamicRepositoryDecoratorFactory> map = new HashMap<>();
map.put("decoratorFactory1", decoratorFactory1);
map.put("decoratorFactory2", decoratorFactory2);
when(context.getBeansOfType(DynamicRepositoryDecoratorFactory.clreplaced)).thenReturn(map);
DynamicRepositoryDecoratorFactoryRegistrar dynamicRepositoryDecoratorFactoryRegistrar = new DynamicRepositoryDecoratorFactoryRegistrar(repositoryDecoratorRegistry);
dynamicRepositoryDecoratorFactoryRegistrar.register(context);
verify(repositoryDecoratorRegistry).addFactory(decoratorFactory1);
verify(repositoryDecoratorRegistry).addFactory(decoratorFactory2);
}
15
View Complete Implementation : DefaultEndpointFactoryTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testResolveChannelEndpoint() throws Exception {
reset(applicationContext);
when(applicationContext.getBeansOfType(EndpointComponent.clreplaced)).thenReturn(Collections.<String, EndpointComponent>emptyMap());
TestContext context = new TestContext();
context.setApplicationContext(applicationContext);
DefaultEndpointFactory factory = new DefaultEndpointFactory();
Endpoint endpoint = factory.create("channel:channel.name", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), ChannelEndpoint.clreplaced);
replacedert.replacedertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelName(), "channel.name");
}
15
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void testAnonymousScriptDetected() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.clreplaced);
replacedertEquals(4, beans.size());
replacedertTrue(ctx.getBean(MyBytecodeProcessor.clreplaced).processed.contains("org.springframework.scripting.groovy.GroovyMessenger2"));
}
15
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright Apache License 2.0
Author : spring-projects
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testAnonymousScriptDetected() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.clreplaced);
replacedertThat(beans.size()).isEqualTo(4);
replacedertThat(ctx.getBean(MyBytecodeProcessor.clreplaced).processed.contains("org.springframework.scripting.groovy.GroovyMessenger2")).isTrue();
}
15
View Complete Implementation : DefaultValueGeneratorManager.java
Copyright MIT License
Author : bcvsolutions
Copyright MIT License
Author : bcvsolutions
@SuppressWarnings("unchecked")
private Map<String, ValueGenerator<? extends AbstractDto>> getAllGenerators() {
if (generators == null) {
Map<String, ValueGenerator<? extends AbstractDto>> results = new HashMap<>();
context.getBeansOfType(ValueGenerator.clreplaced).values().forEach(generator -> {
results.put(AopProxyUtils.ultimateTargetClreplaced(generator).getCanonicalName(), generator);
});
//
generators = results;
}
return generators;
}
15
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright MIT License
Author : Vip-Augus
Copyright MIT License
Author : Vip-Augus
@Test
public void testAnonymousScriptDetected() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.clreplaced);
replacedertEquals(4, beans.size());
replacedertTrue(ctx.getBean(MyBytecodeProcessor.clreplaced).processed.contains("org.springframework.scripting.groovy.GroovyMessenger2"));
}
15
View Complete Implementation : DefaultEndpointFactoryTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testOverwriteEndpointComponent() throws Exception {
Map<String, EndpointComponent> components = new HashMap<String, EndpointComponent>();
components.put("jms", new ChannelEndpointComponent());
reset(applicationContext);
when(applicationContext.getBeansOfType(EndpointComponent.clreplaced)).thenReturn(components);
TestContext context = new TestContext();
context.setApplicationContext(applicationContext);
DefaultEndpointFactory factory = new DefaultEndpointFactory();
Endpoint endpoint = factory.create("jms:custom.channel", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), ChannelEndpoint.clreplaced);
replacedert.replacedertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelName(), "custom.channel");
}
15
View Complete Implementation : PermissionPopulator.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
@Transactional
public void populate(ApplicationContext applicationContext) {
Collection<PermissionRegistry> registries = applicationContext.getBeansOfType(PermissionRegistry.clreplaced).values();
registries.forEach(this::populate);
}
15
View Complete Implementation : DefaultEndpointFactoryTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testResolveCustomEndpoint() throws Exception {
Map<String, EndpointComponent> components = new HashMap<String, EndpointComponent>();
components.put("custom", new ChannelEndpointComponent());
reset(applicationContext);
when(applicationContext.getBeansOfType(EndpointComponent.clreplaced)).thenReturn(components);
TestContext context = new TestContext();
context.setApplicationContext(applicationContext);
DefaultEndpointFactory factory = new DefaultEndpointFactory();
Endpoint endpoint = factory.create("custom:custom.channel", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), ChannelEndpoint.clreplaced);
replacedert.replacedertEquals(((ChannelEndpoint) endpoint).getEndpointConfiguration().getChannelName(), "custom.channel");
}
15
View Complete Implementation : PluginPopulator.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
private Map<String, Plugin> getPlugins(ApplicationContext ctx) {
Map<String, PluginController> pluginControllerMap = ctx.getBeansOfType(PluginController.clreplaced);
return pluginControllerMap.values().stream().map(this::createPlugin).collect(toMap(Plugin::getId, Function.idenreplacedy()));
}
15
View Complete Implementation : GroovyScriptFactoryTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void testAnonymousScriptDetected() throws Exception {
ApplicationContext ctx = new ClreplacedPathXmlApplicationContext("groovy-with-xsd.xml", getClreplaced());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.clreplaced);
replacedertEquals(4, beans.size());
}
14
View Complete Implementation : JobFactoryRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, JobFactory> jobFactoryMap = ctx.getBeansOfType(JobFactory.clreplaced);
jobFactoryMap.values().forEach(this::register);
}
14
View Complete Implementation : WebMvcConfigurationSupportTests.java
Copyright Apache License 2.0
Author : spring-projects
Copyright Apache License 2.0
Author : spring-projects
@Test
public void emptyHandlerMappings() {
ApplicationContext context = initContext(WebConfig.clreplaced);
Map<String, HandlerMapping> handlerMappings = context.getBeansOfType(HandlerMapping.clreplaced);
replacedertThat(handlerMappings.containsKey("viewControllerHandlerMapping")).isFalse();
replacedertThat(handlerMappings.containsKey("resourceHandlerMapping")).isFalse();
replacedertThat(handlerMappings.containsKey("defaultServletHandlerMapping")).isFalse();
Object nullBean = context.getBean("viewControllerHandlerMapping");
replacedertThat(nullBean.equals(null)).isTrue();
nullBean = context.getBean("resourceHandlerMapping");
replacedertThat(nullBean.equals(null)).isTrue();
nullBean = context.getBean("defaultServletHandlerMapping");
replacedertThat(nullBean.equals(null)).isTrue();
}
14
View Complete Implementation : ImportServiceRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, ImportService> importServiceMap = ctx.getBeansOfType(ImportService.clreplaced);
importServiceMap.values().forEach(this::register);
}
14
View Complete Implementation : DefaultAuthorizationManager.java
Copyright MIT License
Author : bcvsolutions
Copyright MIT License
Author : bcvsolutions
/**
* {@inheritDoc}
*
* Services authorization policies support can be enabled / disabled dynamically
*/
@Override
public Set<AuthorizableType> getAuthorizableTypes() {
Set<AuthorizableType> authorizableTypes = new HashSet<>();
// types with authorization evaluators support
context.getBeansOfType(AuthorizableService.clreplaced).values().forEach(service -> {
if (service.getAuthorizableType() != null) {
authorizableTypes.add(service.getAuthorizableType());
}
});
// add default - doesn't supports authorization evaluators
moduleService.getAvailablePermissions().forEach(groupPermission -> {
boolean exists = authorizableTypes.stream().anyMatch(authorizableType -> {
// equals by group permission name only - name is identifier, base permission can be added in custom module
return authorizableType.getGroup().getName().equals(groupPermission.getName());
});
if (!exists) {
authorizableTypes.add(new AuthorizableType(groupPermission, null));
}
});
return authorizableTypes;
}
14
View Complete Implementation : EntityFactoryRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, EnreplacedyFactory> enreplacedyFactoryMap = ctx.getBeansOfType(EnreplacedyFactory.clreplaced);
enreplacedyFactoryMap.values().forEach(this::registerStaticEnreplacedyFactory);
}
14
View Complete Implementation : ScriptRunnerRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, ScriptRunner> scriptRunnerMap = ctx.getBeansOfType(ScriptRunner.clreplaced);
scriptRunnerMap.values().forEach(this::register);
}
14
View Complete Implementation : CamelEndpointComponentTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testCreateSyncEndpoint() throws Exception {
CamelEndpointComponent component = new CamelEndpointComponent();
reset(applicationContext);
when(applicationContext.getBeansOfType(CamelContext.clreplaced)).thenReturn(Collections.singletonMap("myCamelContext", camelContext));
when(applicationContext.getBean(CamelContext.clreplaced)).thenReturn(camelContext);
Endpoint endpoint = component.createEndpoint("camel:sync:direct:news", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), CamelSyncEndpoint.clreplaced);
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "direct:news");
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getCamelContext(), camelContext);
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L);
endpoint = component.createEndpoint("camel:sync:seda:news-feed", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), CamelSyncEndpoint.clreplaced);
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "seda:news-feed");
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getCamelContext(), camelContext);
replacedert.replacedertEquals(((CamelSyncEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L);
}
14
View Complete Implementation : SystemEntityTypeRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, SystemEnreplacedyType> systemEnreplacedyTypeMap = ctx.getBeansOfType(SystemEnreplacedyType.clreplaced);
systemEnreplacedyTypeMap.values().forEach(this::register);
}
14
View Complete Implementation : SystemRepositoryDecoratorFactoryRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, SystemRepositoryDecoratorFactory> repositoryDecoratorFactoryMap = ctx.getBeansOfType(SystemRepositoryDecoratorFactory.clreplaced);
repositoryDecoratorFactoryMap.values().forEach(repositoryDecoratorRegistry::addFactory);
}
14
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void propertyPlaceholderLocation() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-location.xml", getClreplaced());
Map<String, PropertyPlaceholderConfigurer> beans = applicationContext.getBeansOfType(PropertyPlaceholderConfigurer.clreplaced);
replacedertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
replacedertEquals("bar", applicationContext.getBean("foo"));
replacedertEquals("foo", applicationContext.getBean("bar"));
replacedertEquals("maps", applicationContext.getBean("spam"));
}
14
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void propertyPlaceholder() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-replace.xml", getClreplaced());
Map<String, PlaceholderConfigurerSupport> beans = applicationContext.getBeansOfType(PlaceholderConfigurerSupport.clreplaced);
replacedertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
replacedertEquals("bar", applicationContext.getBean("string"));
replacedertEquals("null", applicationContext.getBean("nullString"));
}
14
View Complete Implementation : CamelEndpointComponentTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testCreateEndpoint() throws Exception {
CamelEndpointComponent component = new CamelEndpointComponent();
reset(applicationContext);
when(applicationContext.getBeansOfType(CamelContext.clreplaced)).thenReturn(Collections.singletonMap("myCamelContext", camelContext));
when(applicationContext.getBean(CamelContext.clreplaced)).thenReturn(camelContext);
Endpoint endpoint = component.createEndpoint("camel:direct:news", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), CamelEndpoint.clreplaced);
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "direct:news");
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getCamelContext(), camelContext);
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L);
endpoint = component.createEndpoint("camel:seda:news-feed", context);
replacedert.replacedertEquals(endpoint.getClreplaced(), CamelEndpoint.clreplaced);
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "seda:news-feed");
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getCamelContext(), camelContext);
replacedert.replacedertEquals(((CamelEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L);
}
14
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void propertyPlaceholderSystemProperties() throws Exception {
String value = System.setProperty("foo", "spam");
try {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-system.xml", getClreplaced());
Map<String, PropertyPlaceholderConfigurer> beans = applicationContext.getBeansOfType(PropertyPlaceholderConfigurer.clreplaced);
replacedertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
replacedertEquals("spam", applicationContext.getBean("string"));
replacedertEquals("none", applicationContext.getBean("fallback"));
} finally {
if (value != null) {
System.setProperty("foo", value);
}
}
}
14
View Complete Implementation : ContextNamespaceHandlerTests.java
Copyright Apache License 2.0
Author : langtianya
Copyright Apache License 2.0
Author : langtianya
@Test
public void propertyPlaceholderIgnored() throws Exception {
ApplicationContext applicationContext = new ClreplacedPathXmlApplicationContext("contextNamespaceHandlerTests-replace-ignore.xml", getClreplaced());
Map<String, PlaceholderConfigurerSupport> beans = applicationContext.getBeansOfType(PlaceholderConfigurerSupport.clreplaced);
replacedertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
replacedertEquals("${bar}", applicationContext.getBean("string"));
replacedertEquals("null", applicationContext.getBean("nullString"));
}
14
View Complete Implementation : DefaultEndpointFactoryTest.java
Copyright Apache License 2.0
Author : citrusframework
Copyright Apache License 2.0
Author : citrusframework
@Test
public void testResolveUnknownEndpointComponent() throws Exception {
reset(applicationContext);
when(applicationContext.getBeansOfType(EndpointComponent.clreplaced)).thenReturn(Collections.<String, EndpointComponent>emptyMap());
TestContext context = new TestContext();
context.setApplicationContext(applicationContext);
DefaultEndpointFactory factory = new DefaultEndpointFactory();
try {
factory.create("unknown:unknown", context);
replacedert.fail("Missing exception due to unknown endpoint component");
} catch (CitrusRuntimeException e) {
replacedert.replacedertTrue(e.getMessage().startsWith("Unable to create endpoint component"));
}
}
14
View Complete Implementation : SystemPackageRegistrar.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, SystemPackage> systemPackageMap = ctx.getBeansOfType(SystemPackage.clreplaced);
systemPackageMap.values().forEach(this::register);
}
14
View Complete Implementation : WebMvcConfigurationSupportTests.java
Copyright MIT License
Author : Vip-Augus
Copyright MIT License
Author : Vip-Augus
@Test
public void emptyHandlerMappings() {
ApplicationContext context = initContext(WebConfig.clreplaced);
Map<String, HandlerMapping> handlerMappings = context.getBeansOfType(HandlerMapping.clreplaced);
replacedertFalse(handlerMappings.containsKey("viewControllerHandlerMapping"));
replacedertFalse(handlerMappings.containsKey("resourceHandlerMapping"));
replacedertFalse(handlerMappings.containsKey("defaultServletHandlerMapping"));
Object nullBean = context.getBean("viewControllerHandlerMapping");
replacedertTrue(nullBean.equals(null));
nullBean = context.getBean("resourceHandlerMapping");
replacedertTrue(nullBean.equals(null));
nullBean = context.getBean("defaultServletHandlerMapping");
replacedertTrue(nullBean.equals(null));
}
14
View Complete Implementation : WebMvcConfigurationSupportTests.java
Copyright MIT License
Author : codeEngraver
Copyright MIT License
Author : codeEngraver
@Test
public void emptyHandlerMappings() {
ApplicationContext context = initContext(WebConfig.clreplaced);
Map<String, HandlerMapping> handlerMappings = context.getBeansOfType(HandlerMapping.clreplaced);
replacedertFalse(handlerMappings.containsKey("viewControllerHandlerMapping"));
replacedertFalse(handlerMappings.containsKey("resourceHandlerMapping"));
replacedertFalse(handlerMappings.containsKey("defaultServletHandlerMapping"));
Object nullBean = context.getBean("viewControllerHandlerMapping");
replacedertTrue(nullBean.equals(null));
nullBean = context.getBean("resourceHandlerMapping");
replacedertTrue(nullBean.equals(null));
nullBean = context.getBean("defaultServletHandlerMapping");
replacedertTrue(nullBean.equals(null));
}
13
View Complete Implementation : AbstractMolgenisSpringTest.java
Copyright GNU Lesser General Public License v3.0
Author : molgenis
Copyright GNU Lesser General Public License v3.0
Author : molgenis
// long method name, because if a method annotated with @BeforeEach and the
// same method name
// exists in a subclreplaced then this method is ignored.
@BeforeEach
public void abstractMolgenisSpringTestBeforeMethod() {
synchronized (this) {
if (!isBootstrapped) {
// bootstrap meta data
EnreplacedyTypeMetadata enreplacedyTypeMeta = applicationContext.getBean(EnreplacedyTypeMetadata.clreplaced);
enreplacedyTypeMeta.setBackendEnumOptions(newArrayList("test"));
applicationContext.getBean(AttributeMetadata.clreplaced).bootstrap(enreplacedyTypeMeta);
Map<String, SystemEnreplacedyType> systemEnreplacedyTypeMap = applicationContext.getBeansOfType(SystemEnreplacedyType.clreplaced);
new GenericDependencyResolver().resolve(systemEnreplacedyTypeMap.values(), SystemEnreplacedyType::getDependencies).forEach(systemEnreplacedyType -> systemEnreplacedyType.bootstrap(enreplacedyTypeMeta));
new ApplicationContextProvider().setApplicationContext(applicationContext);
isBootstrapped = true;
}
}
config.resetMocks();
}