Java Code Examples for org.springframework.cloud.service.BaseServiceInfo

The following examples show how to use org.springframework.cloud.service.BaseServiceInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-lattice   Source File: LatticeConnector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected FallbackServiceInfoCreator<BaseServiceInfo, Process> getFallbackServiceInfoCreator() {
	return new FallbackServiceInfoCreator<BaseServiceInfo, Process>() {
		@Override
		public BaseServiceInfo createServiceInfo(Process process) {
			return new BaseServiceInfo(process.getProcessGuid());
		}
	};
}
 
Example 2
Source Project: spring-cloud-connectors   Source File: CloudTest.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
@Test 
public void fallbacksCorrectly() {
	TestServiceData acceptableServiceData = new TestServiceData("my-service1", "test-tag");
	TestServiceData unAcceptableServiceData = new TestServiceData("my-service2", "unknown-tag");
	
	CloudConnector testCloudConnector = new TestCloudConnector(acceptableServiceData, unAcceptableServiceData);
	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
	assertNotNull(serviceInfos);
	assertEquals(2, serviceInfos.size());
	assertThat(serviceInfos.get(0), is(instanceOf(TestServiceInfo.class)));
	assertThat(serviceInfos.get(0), is(instanceOf(BaseServiceInfo.class)));
}
 
Example 4
@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));      
}
 
Example 5
@Override
protected FallbackServiceInfoCreator<BaseServiceInfo,TestServiceData> getFallbackServiceInfoCreator() {
	return new TestFallbackServiceInfoCreator();
}
 
Example 6
@Override
public BaseServiceInfo createServiceInfo(TestServiceData serviceData) {
	return new BaseServiceInfo(serviceData.getId());
}
 
Example 7
@Override
protected FallbackServiceInfoCreator<BaseServiceInfo,Map<String,Object>> getFallbackServiceInfoCreator() {
	return new CloudFoundryFallbackServiceInfoCreator();
}
 
Example 8
@Override
public BaseServiceInfo createServiceInfo(Map<String,Object> serviceData) {
	String id = (String) serviceData.get("name");
	return new BaseServiceInfo(id);
}
 
Example 9
@Override
protected FallbackServiceInfoCreator<BaseServiceInfo, UriBasedServiceData> getFallbackServiceInfoCreator() {
	return new FallbackBaseServiceInfoCreator();
}
 
Example 10
Source Project: spring-cloud-connectors   Source File: HerokuConnector.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected FallbackServiceInfoCreator<BaseServiceInfo, UriBasedServiceData> getFallbackServiceInfoCreator() {
	return new FallbackBaseServiceInfoCreator();
}