Search in sources :

Example 96 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-cloud-connectors by spring-cloud.

the class AbstractCloudConfigPropertiesTest method cloudScanWithOneService.

@Test
public void cloudScanWithOneService() {
    ApplicationContext testContext = getPropertiesTestApplicationContext(createMysqlService("db"));
    Properties cloudProperties = testContext.getBean("cloudProperties", Properties.class);
    assertNotNull(cloudProperties);
    assertEquals("db", cloudProperties.get("cloud.services.db.id"));
    assertEquals("db", cloudProperties.get("cloud.services.mysql.id"));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Properties(java.util.Properties) Test(org.junit.Test) StubCloudConnectorTest(org.springframework.cloud.StubCloudConnectorTest)

Example 97 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-cloud-connectors by spring-cloud.

the class AbstractCloudConfigServiceScanTest method skipUnknowServices.

@Test
public void skipUnknowServices() {
    ApplicationContext testContext = getTestApplicationContext(createMysqlService("mysqlDb"), new BaseServiceInfo("newrelic-service"));
    assertNotNull("Getting service by id", testContext.getBean("mysqlDb"));
    assertNotNull("Getting service by id and type", testContext.getBean("mysqlDb", DataSource.class));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) BaseServiceInfo(org.springframework.cloud.service.BaseServiceInfo) DataSource(javax.sql.DataSource) Test(org.junit.Test) StubCloudConnectorTest(org.springframework.cloud.StubCloudConnectorTest)

Example 98 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-cloud-connectors by spring-cloud.

the class AbstractCloudConfigServiceScanTest method cloudScanWithAllTypesOfServices.

@Test
public void cloudScanWithAllTypesOfServices() {
    ApplicationContext testContext = getTestApplicationContext(createMysqlService("mysqlDb"), createPostgresqlService("postDb"), createMongoService("mongoDb"), createRedisService("redisDb"), createRabbitService("rabbit"));
    assertNotNull("Getting service by id", testContext.getBean("mysqlDb"));
    assertNotNull("Getting service by id and type", testContext.getBean("mysqlDb", DataSource.class));
    assertNotNull("Getting service by id", testContext.getBean("postDb"));
    assertNotNull("Getting service by id and type", testContext.getBean("postDb", DataSource.class));
    assertNotNull("Getting service by id", testContext.getBean("mongoDb"));
    assertNotNull("Getting service by id and type", testContext.getBean("mongoDb", MongoDbFactory.class));
    assertNotNull("Getting service by id", testContext.getBean("redisDb"));
    assertNotNull("Getting service by id and type", testContext.getBean("redisDb", RedisConnectionFactory.class));
    assertNotNull("Getting service by id", testContext.getBean("rabbit"));
    assertNotNull("Getting service by id and type", testContext.getBean("rabbit", ConnectionFactory.class));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) ConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) DataSource(javax.sql.DataSource) Test(org.junit.Test) StubCloudConnectorTest(org.springframework.cloud.StubCloudConnectorTest)

Example 99 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-cloud-connectors by spring-cloud.

the class DatasourceConfigWithServiceConfig method cloudDataSourceWithoutServiceNameSpecified_TwoMixedServiceExist_byId.

@Test(expected = BeanCreationException.class)
public void cloudDataSourceWithoutServiceNameSpecified_TwoMixedServiceExist_byId() {
    ApplicationContext testContext = getTestApplicationContextWithoutServiceId(createMysqlService("my-service"), createPostgresqlService("my-service-2"));
    testContext.getBean(getConnectorType());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.Test)

Example 100 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-cloud-connectors by spring-cloud.

the class DatasourceConfigWithServiceConfig method cloudDataSourceWithNoConfig.

@Test
public void cloudDataSourceWithNoConfig() {
    ApplicationContext testContext = getTestApplicationContext(DatasourceConfigWithServiceConfig.class, createService("my-service"));
    DataSource ds = testContext.getBean("dataSourceWithNoConfig", getConnectorType());
    assertConnectionProperties(ds, null);
    assertConnectionProperty(ds, "driverClassName", getDriverClassName());
    assertConnectionProperty(ds, "validationQuery", getValidationQuery());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

ApplicationContext (org.springframework.context.ApplicationContext)532 Test (org.junit.Test)256 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)161 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)38 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)32 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)28 File (java.io.File)24 Messenger (org.springframework.scripting.Messenger)24 DataSource (javax.sql.DataSource)23 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)21 Refreshable (org.springframework.aop.target.dynamic.Refreshable)20 StubCloudConnectorTest (org.springframework.cloud.StubCloudConnectorTest)17 SchedulerException (org.quartz.SchedulerException)16 HashMap (java.util.HashMap)15 Map (java.util.Map)14 WebApplicationContext (org.springframework.web.context.WebApplicationContext)14 MovieMapper (com.mapper.MovieMapper)13 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)13 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)13 ArrayList (java.util.ArrayList)12