From 9b4139c8ddb38dfdf702c86e503d59c4a23f46cc Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Fri, 24 Jul 2015 11:13:53 -0500 Subject: [PATCH] Polish SQL Server support and fix unit tests. --- .../SqlServerServiceInfoCreator.java | 7 +++---- .../service/common/SqlServerServiceInfo.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spring-cloud-cloudfoundry-connector/src/main/java/org/springframework/cloud/cloudfoundry/SqlServerServiceInfoCreator.java b/spring-cloud-cloudfoundry-connector/src/main/java/org/springframework/cloud/cloudfoundry/SqlServerServiceInfoCreator.java index 65359261..165e6de6 100644 --- a/spring-cloud-cloudfoundry-connector/src/main/java/org/springframework/cloud/cloudfoundry/SqlServerServiceInfoCreator.java +++ b/spring-cloud-cloudfoundry-connector/src/main/java/org/springframework/cloud/cloudfoundry/SqlServerServiceInfoCreator.java @@ -2,15 +2,14 @@ import org.springframework.cloud.service.common.SqlServerServiceInfo; -public class SqlServerServiceInfoCreator extends - RelationalServiceInfoCreator { +public class SqlServerServiceInfoCreator extends RelationalServiceInfoCreator { public SqlServerServiceInfoCreator() { - super(new Tags(), SqlServerServiceInfo.SQLSERVER_SCHEME); } + super(new Tags(), SqlServerServiceInfo.SQLSERVER_SCHEME); + } @Override public SqlServerServiceInfo createServiceInfo(String id, String url) { return new SqlServerServiceInfo(id, url); } - } diff --git a/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/SqlServerServiceInfo.java b/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/SqlServerServiceInfo.java index 8b599f6c..d6fd8ee4 100644 --- a/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/SqlServerServiceInfo.java +++ b/spring-cloud-core/src/main/java/org/springframework/cloud/service/common/SqlServerServiceInfo.java @@ -11,12 +11,15 @@ public class SqlServerServiceInfo extends RelationalServiceInfo { public SqlServerServiceInfo(String id, String url) { super(id, url, JDBC_URL_TYPE); } - - @Override - public String getJdbcUrl() - { - return String.format("jdbc:%s://%s:%d;database=%s;user=%s;password=%s;", - jdbcUrlDatabaseType, + + @Override + public String getJdbcUrl() { + if (getUriInfo().getUriString().startsWith(JDBC_PREFIX)) { + return getUriInfo().getUriString(); + } + + return String.format("jdbc:%s://%s:%d;database=%s;user=%s;password=%s", + jdbcUrlDatabaseType, getHost(), getPort(), getPath(), getUserName(), getPassword()); - } + } }