org.springframework.cloud.service.common.PostgresqlServiceInfo Java Examples
The following examples show how to use
org.springframework.cloud.service.common.PostgresqlServiceInfo.
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: CloudFoundryConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Test public void postgresqlServiceCreationWithJdbcUrl() { String name1 = "database-1"; String name2 = "database-2"; when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getPostgresqlServicePayloadWithJdbcUrl("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayloadWithJdbcUrl("postgresql-2", hostname, port, username, password, name2))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1"); ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2"); assertServiceFoundOfType(info1, PostgresqlServiceInfo.class); assertServiceFoundOfType(info2, PostgresqlServiceInfo.class); assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1); assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2); assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1); assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2); }
Example #2
Source File: CloudFoundryConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Test public void postgresqlServiceCreationNoLabelNoTags() { String name1 = "database-1"; String name2 = "database-2"; when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getPostgresqlServicePayloadNoLabelNoTags("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayloadNoLabelNoTags("postgresql-2", hostname, port, username, password, name2))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1"); ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2"); assertServiceFoundOfType(info1, PostgresqlServiceInfo.class); assertServiceFoundOfType(info2, PostgresqlServiceInfo.class); assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1); assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2); assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1); assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2); }
Example #3
Source File: CloudFoundryConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Test public void postgresqlWithSpecialCharsServiceCreation() { String userWithSpecialChars = "u%u:u+"; String passwordWithSpecialChars = "p%p:p+"; String name1 = "database-1"; when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn( getServicesPayload(getPostgresqlServicePayload("postgresql-1", hostname, port, userWithSpecialChars, passwordWithSpecialChars, name1))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1"); assertServiceFoundOfType(info1, PostgresqlServiceInfo.class); assertEquals(getJdbcUrl(hostname, port, userWithSpecialChars, passwordWithSpecialChars, name1), ((RelationalServiceInfo) info1).getJdbcUrl()); assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, userWithSpecialChars, passwordWithSpecialChars, name1); }
Example #4
Source File: CloudFoundryConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Test public void postgresqlServiceCreation() { String name1 = "database-1"; String name2 = "database-2"; when(mockEnvironment.getEnvValue("VCAP_SERVICES")) .thenReturn(getServicesPayload( getPostgresqlServicePayload("postgresql-1", hostname, port, username, password, name1), getPostgresqlServicePayload("postgresql-2", hostname, port, username, password, name2))); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo info1 = getServiceInfo(serviceInfos, "postgresql-1"); ServiceInfo info2 = getServiceInfo(serviceInfos, "postgresql-2"); assertServiceFoundOfType(info1, PostgresqlServiceInfo.class); assertServiceFoundOfType(info2, PostgresqlServiceInfo.class); assertJdbcUrlEqual(info1, POSTGRES_SCHEME, name1); assertJdbcUrlEqual(info2, POSTGRES_SCHEME, name2); assertUriBasedServiceInfoFields(info1, POSTGRES_SCHEME, hostname, port, username, password, name1); assertUriBasedServiceInfoFields(info2, POSTGRES_SCHEME, hostname, port, username, password, name2); }
Example #5
Source File: HerokuConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
private void assertPostgresServiceCreated(String envVarName, String serviceInstanceName) { Map<String, String> env = new HashMap<String, String>(); String postgresUrl = getRelationalServiceUrl("db"); env.put(envVarName, postgresUrl); when(mockEnvironment.getEnv()).thenReturn(env); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo serviceInfo = getServiceInfo(serviceInfos, serviceInstanceName); assertNotNull(serviceInfo); assertTrue(serviceInfo instanceof PostgresqlServiceInfo); assertReleationServiceInfo((PostgresqlServiceInfo) serviceInfo, "db"); }
Example #6
Source File: DatabasesForPostgresqlServiceInfoCreator.java From bluemix-cloud-connectors with Apache License 2.0 | 5 votes |
@Override public PostgresqlServiceInfo createServiceInfo(Map<String, Object> serviceData) { String id = getId(serviceData); Map<String, Object> credentials = getCredentials(serviceData); String uri = getUriFromCredentials(credentials); String cert64 = getRootCaFromCredentials(credentials); if (cert64 != null && uri.contains("sslmode")) { if (!uri.contains("sslfactory")) { try { StringBasedTrustManager.getTrustManager().addCert(Base64.getDecoder().decode(cert64)); if (!uri.contains("?")) { uri += "?sslfactory=" + StringBasedSSLSocketFactory.class.getCanonicalName(); } else { uri += "&sslfactory=" + StringBasedSSLSocketFactory.class.getCanonicalName(); } } catch (Exception e) { LOG.log(Level.SEVERE, "Unable to add certificate to trust manager", e); } } else { LOG.log(Level.WARNING, "sslfactory already present in postgresql, not adding custom handler. Expect truststore issues."); } } return new PostgresqlServiceInfo(id, uri); }
Example #7
Source File: LocalConfigConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void serviceCreation() { List<ServiceInfo> services = connector.getServiceInfos(); ServiceInfo service = getServiceInfo(services, "ingres"); assertNotNull(service); assertTrue(service instanceof PostgresqlServiceInfo); assertUriParameters((PostgresqlServiceInfo) service); }
Example #8
Source File: PostgresqlServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public PostgresqlServiceInfo createServiceInfo(String id, String url, String jdbcUrl) { return new PostgresqlServiceInfo(id, url, jdbcUrl); }
Example #9
Source File: DataSourceJavaConfigPostgesqlTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public PostgresqlServiceInfo createService(String id) { return createPostgresqlService(id); }
Example #10
Source File: PostgresqlServiceCreatorTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public PostgresqlServiceInfo createServiceInfo() { when(mockPostgresqlServiceInfo.getJdbcUrl()).thenReturn("jdbc:postgresql://myuser:[email protected]:5432/database-123"); return mockPostgresqlServiceInfo; }
Example #11
Source File: PostgresqlServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public PostgresqlServiceInfoCreator() { super(PostgresqlServiceInfo.POSTGRES_SCHEME); }
Example #12
Source File: PostgresqlServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public PostgresqlServiceInfo createServiceInfo(String id, String uri) { return new PostgresqlServiceInfo(id, uri); }
Example #13
Source File: PostgresqlDataSourceFactoryTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public PostgresqlServiceInfo getTestServiceInfo(String id) { return new PostgresqlServiceInfo(id, "jdbc:postgres://username:pass@host:port/db"); }
Example #14
Source File: PostgresqlServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public PostgresqlServiceInfoCreator() { super(PostgresqlServiceInfo.POSTGRES_SCHEME); }
Example #15
Source File: PostgresqlServiceInfoCreator.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
@Override public PostgresqlServiceInfo createServiceInfo(String id, String uri) { return new PostgresqlServiceInfo(HerokuUtil.computeServiceName(id), uri); }
Example #16
Source File: HerokuConnectorPostgresqlServiceTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
public HerokuConnectorPostgresqlServiceTest() { super(PostgresqlServiceInfo.POSTGRES_SCHEME); }
Example #17
Source File: StubCloudConnectorTest.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
protected PostgresqlServiceInfo createPostgresqlService(String id) { return new PostgresqlServiceInfo(id, "postgres://username:pass@host:port/db"); }