org.springframework.cloud.service.common.RedisServiceInfo Java Examples

The following examples show how to use org.springframework.cloud.service.common.RedisServiceInfo. 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: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 6 votes vote down vote up
public RedisServiceInfo createServiceInfo(Map<String,Object> serviceData) {
	String id = getId(serviceData);

	Map<String, Object> credentials = getCredentials(serviceData);
	String uri = getUriFromCredentials(credentials);

	if (uri == null) {
		String host = getStringFromCredentials(credentials, "hostname", "host");
		int port = getIntFromCredentials(credentials, "port");
		String password = (String) credentials.get("password");

		return new RedisServiceInfo(id, host, port, password);
	} else {
		return new RedisServiceInfo(id, uri);
	}
}
 
Example #2
Source File: RedisServiceInfoCreatorTests.java    From spring-cloud-lattice with Apache License 2.0 5 votes vote down vote up
@Test
public void mysqlLatticeWorks() {
	LatticeConnector connector = createConnector();

	RedisServiceInfo serviceInfo = findServiceInfo(connector, RedisServiceInfo.class, "redis-1");
	assertThat(serviceInfo.getUri(), equalTo("redis://192.168.11.11:61001"));
}
 
Example #3
Source File: HerokuConnectorRedisServiceTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void redisServiceCreation() {
	for (String redisEnv : new String[]{"REDISTOGO_URL", "REDISCLOUD_URL", "OPENREDIS_URL", "REDISGREEN_URL", "REDIS_URL"}) {
		Map<String, String> env = new HashMap<String, String>();
		String redisUrl = getRedisServiceUrl();
		env.put(redisEnv, redisUrl);
		when(mockEnvironment.getEnv()).thenReturn(env);

		List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
		ServiceInfo serviceInfo = getServiceInfo(serviceInfos, redisEnv.substring(0, redisEnv.length() - 4));
		assertNotNull(serviceInfo);
		assertTrue(serviceInfo instanceof RedisServiceInfo);
		assertRedisServiceInfo((RedisServiceInfo) serviceInfo);
	}
}
 
Example #4
Source File: LocalConfigConnectorRedisServiceTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void serviceCreation() {
	List<ServiceInfo> services = connector.getServiceInfos();
	ServiceInfo service = getServiceInfo(services, "blue");
	assertNotNull(service);
	assertTrue(service instanceof RedisServiceInfo);
	assertUriParameters((RedisServiceInfo) service);
}
 
Example #5
Source File: CloudFoundryConnectorRedisServiceTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void redisServiceCreationNoLabelNoTags() {
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
			.thenReturn(getServicesPayload(
					getRedisServicePayloadNoLabelNoTags("redis-1", hostname, port, password, "redis-db"),
					getRedisServicePayloadNoLabelNoTags("redis-2", hostname, port, password, "redis-db")));

	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
	assertServiceFoundOfType(serviceInfos, "redis-1", RedisServiceInfo.class);
	assertServiceFoundOfType(serviceInfos, "redis-2", RedisServiceInfo.class);
}
 
Example #6
Source File: CloudFoundryConnectorRedisServiceTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void redisServiceCreation() {
	when(mockEnvironment.getEnvValue("VCAP_SERVICES"))
		.thenReturn(getServicesPayload(
				getRedisServicePayload("redis-1", hostname, port, password, "redis-db"),
				getRedisServicePayload("redis-2", hostname, port, password, "redis-db")));

	List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos();
	assertServiceFoundOfType(serviceInfos, "redis-1", RedisServiceInfo.class);
	assertServiceFoundOfType(serviceInfos, "redis-2", RedisServiceInfo.class);
}
 
Example #7
Source File: RedisServiceConnectorCreatorTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
public RedisServiceInfo createServiceInfo(String scheme) {
	when(mockRedisServiceInfo.getScheme()).thenReturn(scheme);
	when(mockRedisServiceInfo.getHost()).thenReturn(TEST_HOST);
	when(mockRedisServiceInfo.getPort()).thenReturn(TEST_PORT);
	when(mockRedisServiceInfo.getPassword()).thenReturn(TEST_PASSWORD);
	
	return mockRedisServiceInfo;
}
 
Example #8
Source File: RedisServiceConnectorCreatorTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void cloudRedisCreationSecureConnection() {
	RedisServiceInfo serviceInfo = createServiceInfo(RedisServiceInfo.REDISS_SCHEME);

	RedisConnectionFactory dataSource = testCreator.create(serviceInfo, null);

	assertConnectorProperties(serviceInfo, dataSource, true);
}
 
Example #9
Source File: RedisServiceConnectorCreatorTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void cloudRedisCreationNoConfig() {
	RedisServiceInfo serviceInfo = createServiceInfo(RedisServiceInfo.REDIS_SCHEME);

	RedisConnectionFactory dataSource = testCreator.create(serviceInfo, null);

	assertConnectorProperties(serviceInfo, dataSource, false);
}
 
Example #10
Source File: SpringData1RedisServiceConnectorCreatorTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
public RedisServiceInfo createServiceInfo() {
    when(mockRedisServiceInfo.getHost()).thenReturn(TEST_HOST);
    when(mockRedisServiceInfo.getPort()).thenReturn(TEST_PORT);
    when(mockRedisServiceInfo.getPassword()).thenReturn(TEST_PASSWORD);

    return mockRedisServiceInfo;
}
 
Example #11
Source File: SpringData1RedisServiceConnectorCreatorTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void cloudRedisCreationNoConfig() throws Exception {
    RedisServiceInfo serviceInfo = createServiceInfo();

    RedisConnectionFactory dataSource = testCreator.create(serviceInfo, null);

    assertConnectorProperties(serviceInfo, dataSource);
}
 
Example #12
Source File: CloudTest.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void servicePropsRedis() {
	String serviceId = "my-redis";
	RedisServiceInfo redisServiceInfo = createRedisService(serviceId);
	CloudConnector stubCloudConnector = getTestCloudConnector(redisServiceInfo);
	Cloud testCloud = new Cloud(stubCloudConnector, serviceCreators);

	Properties cloudProperties = testCloud.getCloudProperties();
	
	assertBasicProps("cloud.services.my-redis", redisServiceInfo, cloudProperties);
	assertBasicProps("cloud.services.redis", redisServiceInfo, cloudProperties);
}
 
Example #13
Source File: RedisServiceInfoCreator.java    From spring-cloud-lattice with Apache License 2.0 5 votes vote down vote up
@Override
public RedisServiceInfo createServiceInfo(Process process) {
	ActualLRPResponse actual = process.getFirstActual();
	String address = actual.getAddress();
	int port = actual.getPorts()[0].getHostPort();
	String password = null;
	return new RedisServiceInfo(actual.getInstanceGuid(), address, port, password);
}
 
Example #14
Source File: RedisConnectionFactoryFactoryTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public RedisServiceInfo getTestServiceInfo(String id) {
	return new RedisServiceInfo(id, "host", 0, "password");
}
 
Example #15
Source File: SpringData1RedisConnectionFactoryFactoryTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public RedisServiceInfo getTestServiceInfo(String id) {
    return new RedisServiceInfo(id, "host", 0, "password");
}
 
Example #16
Source File: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public RedisServiceInfoCreator() {
	// the literal in the tag is CloudFoundry-specific
	super(new Tags("redis"), RedisServiceInfo.REDIS_SCHEME, RedisServiceInfo.REDISS_SCHEME);
}
 
Example #17
Source File: StubCloudConnectorTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
protected RedisServiceInfo createRedisService(String id) {
	return new RedisServiceInfo(id, "host", 1234, "password");
}
 
Example #18
Source File: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public RedisServiceInfoCreator() {
	super(RedisServiceInfo.REDIS_SCHEME);
}
 
Example #19
Source File: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public RedisServiceInfo createServiceInfo(String id, String uri) {
	return new RedisServiceInfo(id, uri);
}
 
Example #20
Source File: RedisConnectionFactoryCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
private boolean connectionIsSecure(RedisServiceInfo serviceInfo) {
	return RedisServiceInfo.REDISS_SCHEME.equalsIgnoreCase(serviceInfo.getScheme());
}
 
Example #21
Source File: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
public RedisServiceInfoCreator() {
	super(RedisServiceInfo.REDIS_SCHEME);
}
 
Example #22
Source File: RedisServiceInfoCreator.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public RedisServiceInfo createServiceInfo(String id, String uri) {
	return new RedisServiceInfo(HerokuUtil.computeServiceName(id), uri);
}
 
Example #23
Source File: HerokuConnectorRedisServiceTest.java    From spring-cloud-connectors with Apache License 2.0 4 votes vote down vote up
protected void assertRedisServiceInfo(RedisServiceInfo serviceInfo) {
	assertEquals(hostname, serviceInfo.getHost());
	assertEquals(port, serviceInfo.getPort());
	assertEquals(username, serviceInfo.getUserName());
	assertEquals(password, serviceInfo.getPassword());
}