List of usage examples for org.springframework.context ApplicationContext getBeanDefinitionNames
String[] getBeanDefinitionNames();
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-330 public void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent() throws Exception { HidingClassLoader classLoader = HidingClassLoader.hide(Link.class); ApplicationContext context = WebTestUtils.createApplicationContext(classLoader, SampleConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); assertThat(names).contains("pageableResolver", "sortResolver"); assertThat(names).doesNotContain("pagedResourcesAssembler", "pagedResourcesAssemblerArgumentResolver"); }
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-475 public void registersJacksonSpecificBeanDefinitions() throws Exception { ApplicationContext context = WebTestUtils.createApplicationContext(SampleConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); assertThat(names).contains("jacksonGeoModule"); }
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-475 public void doesNotRegisterJacksonSpecificComponentsIfJacksonNotPresent() throws Exception { ApplicationContext context = WebTestUtils .createApplicationContext(HidingClassLoader.hide(ObjectMapper.class), SampleConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); assertThat(names).doesNotContain("jacksonGeoModule"); }
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-660 public void picksUpWebConfigurationMixins() { ApplicationContext context = WebTestUtils.createApplicationContext(SampleConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); assertThat(names).contains("sampleBean"); }
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-822 public void picksUpPageableResolverCustomizer() { ApplicationContext context = WebTestUtils.createApplicationContext(PageableResolverCustomizerConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); PageableHandlerMethodArgumentResolver resolver = context .getBean(PageableHandlerMethodArgumentResolver.class); assertThat(names).contains("testPageableResolverCustomizer"); assertThat((Integer) ReflectionTestUtils.getField(resolver, "maxPageSize")).isEqualTo(100); }
From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java
@Test // DATACMNS-822 public void picksUpSortResolverCustomizer() { ApplicationContext context = WebTestUtils.createApplicationContext(SortResolverCustomizerConfig.class); List<String> names = Arrays.asList(context.getBeanDefinitionNames()); SortHandlerMethodArgumentResolver resolver = context.getBean(SortHandlerMethodArgumentResolver.class); assertThat(names).contains("testSortResolverCustomizer"); assertThat((String) ReflectionTestUtils.getField(resolver, "sortParameter")).isEqualTo("foo"); }
From source file:org.wso2.appserver.integration.common.utils.SpringServiceMaker.java
public SpringBeansData getSpringBeanNames(String springContextFilePath, String springBeanFilePath, ClassLoader bundleClassLoader) throws AxisFault { SpringBeansData data = new SpringBeansData(); File urlFile = new File(springBeanFilePath); ClassLoader prevCl = Thread.currentThread().getContextClassLoader(); ClassLoader urlCl;//from ww w . jav a 2 s .co m try { URL url = urlFile.toURL(); urlCl = URLClassLoader.newInstance(new URL[] { url }, bundleClassLoader); // Save the class loader so that you can restore it later Thread.currentThread().setContextClassLoader(urlCl); ApplicationContext aCtx = GenericApplicationContextUtil .getSpringApplicationContext(springContextFilePath, springBeanFilePath); String[] beanDefintions = aCtx.getBeanDefinitionNames(); data.setBeans(beanDefintions); } catch (Exception e) { String msg = "Spring cannot load spring beans"; handleException(msg, e); } finally { Thread.currentThread().setContextClassLoader(prevCl); } return data; }