Java Code Examples for io.pivotal.cfenv.core.CfEnv#findServiceByName()

The following examples show how to use io.pivotal.cfenv.core.CfEnv#findServiceByName() . 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 File: AmqpTests.java    From java-cfenv with Apache License 2.0 5 votes vote down vote up
@Test
public void qpidServiceCreationNoLabelNoTags() throws Exception {
	mockVcapServices(getServicesPayload(
			getQpidServicePayloadNoLabelNoTags("qpid-1", hostname, port, username, password, "q-1", "vhost1"),
			getQpidServicePayloadNoLabelNoTags("qpid-2", hostname, port, username, password, "q-2", "vhost2")));
	CfEnv cfEnv = new CfEnv();
	assertThat(cfEnv.findServicesByName("qpid-1","qpid-2")).hasSize(2);
	CfService cfService = cfEnv.findServiceByName("qpid-1");
	assertThat(cfService.getCredentials().getUsername()).isEqualTo(username);
	assertThat(cfService.getCredentials().getPassword()).isEqualTo(password);
	assertThat(cfService.getCredentials().getUriInfo().getUri().getQuery())
		.contains(String.format("tcp://%s:%s", hostname, port));
}
 
Example 2
Source File: DataSourceEnvironmentExtractor.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private CfCredentials extractDatabaseServiceCredentials(String serviceName) {
    CfEnv cfEnv = new CfEnv();
    CfService sourceService = cfEnv.findServiceByName(serviceName);
    return sourceService.getCredentials();
}