Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. @RunWith(SpringJUnit4ClassRunner.class)
  2. @SpringApplicationConfiguration(classes = {
  3. Application.class,
  4. TrivialIT.PostConfiguration.class
  5. })
  6. @WebAppConfiguration
  7. @IntegrationTest("server.port=0")
  8. @ActiveProfiles({"default", "test"})
  9. @ConfigurationProperties("application.yml")
  10. public class TrivialIT {
  11.  
  12. Logger LOG = LoggerFactory.getLogger(TrivialIT.class);
  13.  
  14. @Autowired
  15. ApplicationContext context;
  16.  
  17. @Test
  18. public void should_load_all_the_beans() throws Exception {
  19. LOG.info("\n\n");
  20. LOG.info("Beans report ****************************************");
  21. for (String beanName : context.getBeanDefinitionNames()) {
  22. LOG.info("Bean: {} -> {}", beanName, context.getBean(beanName).getClass().getName());
  23. };
  24. LOG.info("\n\n");
  25. LOG.info("Profiles report ************************************");
  26. for (String profile : context.getEnvironment().getActiveProfiles()) {
  27. LOG.info("Profile: {}", profile);
  28. }
  29. LOG.info("\n\n");
  30.  
  31. }
  32.  
  33. @Configuration
  34. @Import({
  35. JmsAutoConfiguration.class,
  36. ActiveMQAutoConfiguration.class
  37. })
  38. public static class PostConfiguration {
  39.  
  40. @Bean
  41. RestTemplate restTemplate() {
  42. return new RestTemplate();
  43. }
  44.  
  45. @Bean(name = "connectionFactory")
  46. UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter(ActiveMQConnectionFactory jmsConnectionFactory) throws NamingException {
  47. UserCredentialsConnectionFactoryAdapter factoryAdapter = new UserCredentialsConnectionFactoryAdapter();
  48. factoryAdapter.setTargetConnectionFactory(jmsConnectionFactory);
  49. return factoryAdapter;
  50. }
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement