Search in sources :

Example 1 with BaseServiceInfo

use of org.springframework.cloud.service.BaseServiceInfo 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 2 with BaseServiceInfo

use of org.springframework.cloud.service.BaseServiceInfo in project spring-cloud-connectors by spring-cloud.

the class StubServiceConnectorConfig method getSingletonServiceConnectorNoMatchingServiceConnectorCreator.

@Test(expected = CloudException.class)
public void getSingletonServiceConnectorNoMatchingServiceConnectorCreator() {
    // Think an app bound to a (user) service that doesn't have a corresponding
    // registered ServiceConnectorCreator. When user asks for singleton service connector
    // for another type (with a corresponding creator registered), 
    // getSingletonServiceConnector() should throw a CloudException.
    BaseServiceInfo testServiceInfo = new BaseServiceInfo("user-service");
    StubCloudConnector stubCloudConnector = CloudTestUtil.getTestCloudConnector(testServiceInfo);
    serviceConnectorCreators.add(new StubServiceConnectorCreator());
    Cloud testCloud = new Cloud(stubCloudConnector, serviceConnectorCreators);
    testCloud.getSingletonServiceConnector(StubServiceConnector.class, null);
}
Also used : BaseServiceInfo(org.springframework.cloud.service.BaseServiceInfo) StubCloudConnector(org.springframework.cloud.CloudTestUtil.StubCloudConnector) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 BaseServiceInfo (org.springframework.cloud.service.BaseServiceInfo)2 DataSource (javax.sql.DataSource)1 StubCloudConnector (org.springframework.cloud.CloudTestUtil.StubCloudConnector)1 StubCloudConnectorTest (org.springframework.cloud.StubCloudConnectorTest)1 ApplicationContext (org.springframework.context.ApplicationContext)1