From 58ef61296a9b53abf817635ce07d994c1d9485a5 Mon Sep 17 00:00:00 2001 From: Chris Schaefer Date: Mon, 12 Jan 2015 22:18:20 -0500 Subject: [PATCH] Move spring-cloud-pcf-connector to its own repo, modify test jar creation in spring-cloud-cloudfoundry-connector to build a jar with the classes --- publish-maven.gradle | 5 + settings.gradle | 2 +- .../build.gradle | 5 +- spring-cloud-pcf-connector/.gitignore | 2 - spring-cloud-pcf-connector/README.md | 3 - spring-cloud-pcf-connector/build.gradle | 11 - .../publish-maven.gradle | 65 ------ .../ConfigServerServiceConnector.java | 75 ------- .../configserver/ConfigServerServiceInfo.java | 14 -- .../ConfigServerServiceInfoCreator.java | 28 --- .../EurekaClientConfigurationCreator.java | 191 ------------------ .../cloud/pcf/eureka/EurekaServiceInfo.java | 16 -- .../pcf/eureka/EurekaServiceInfoCreator.java | 29 --- .../gemfire/GemfireXDDataSourceCreator.java | 20 -- .../pcf/gemfire/GemfireXDServiceInfo.java | 20 -- .../hadoop/HadoopConfigurationCreator.java | 25 --- .../cloud/pcf/hadoop/HadoopServiceInfo.java | 42 ---- .../cloud/pcf/phd/PhdServiceInfoCreator.java | 79 -------- ...loudfoundry.CloudFoundryServiceInfoCreator | 3 - ...work.cloud.service.ServiceConnectorCreator | 3 - .../main/resources/META-INF/spring.factories | 2 - .../HadoopConfigurationCreatorTest.java | 26 --- .../cloud/pcf/PhdServiceInfoCreatorTest.java | 142 ------------- .../ConfigServerServiceInfoCreatorTest.java | 46 ----- .../EurekaClientConfigurationCreatorTest.java | 42 ---- .../eureka/EurekaServiceInfoCreatorTest.java | 45 ----- .../configserver/test-config-server-info.json | 11 - .../cloud/pcf/eureka/test-eureka-info.json | 11 - .../cloud/pcf/test-phd-info.json | 31 --- 29 files changed, 9 insertions(+), 985 deletions(-) delete mode 100644 spring-cloud-pcf-connector/.gitignore delete mode 100644 spring-cloud-pcf-connector/README.md delete mode 100644 spring-cloud-pcf-connector/build.gradle delete mode 100644 spring-cloud-pcf-connector/publish-maven.gradle delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceConnector.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfo.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfo.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDDataSourceCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDServiceInfo.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopConfigurationCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopServiceInfo.java delete mode 100644 spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/phd/PhdServiceInfoCreator.java delete mode 100644 spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator delete mode 100644 spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator delete mode 100644 spring-cloud-pcf-connector/src/main/resources/META-INF/spring.factories delete mode 100644 spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/hadoop/HadoopConfigurationCreatorTest.java delete mode 100644 spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/PhdServiceInfoCreatorTest.java delete mode 100644 spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreatorTest.java delete mode 100644 spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreatorTest.java delete mode 100644 spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreatorTest.java delete mode 100644 spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/configserver/test-config-server-info.json delete mode 100644 spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/eureka/test-eureka-info.json delete mode 100644 spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/test-phd-info.json diff --git a/publish-maven.gradle b/publish-maven.gradle index 44c6719..2d1ac74 100644 --- a/publish-maven.gradle +++ b/publish-maven.gradle @@ -52,6 +52,11 @@ def customizePom(pom, gradleProject) { name = 'Ramnivas Laddad' email = 'rladdad@gopivotal.com' } + developer { + id = 'cschaefer' + name = 'Chris Schaefer' + email = 'cschaefer@pivotal.io' + } } } } diff --git a/settings.gradle b/settings.gradle index a4a8bc9..1eca68b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,4 +5,4 @@ include "${rootProject.name}-cloudfoundry-connector" include "${rootProject.name}-spring-service-connector" include "${rootProject.name}-heroku-connector" include "${rootProject.name}-localconfig-connector" -include "${rootProject.name}-pcf-connector" + diff --git a/spring-cloud-cloudfoundry-connector/build.gradle b/spring-cloud-cloudfoundry-connector/build.gradle index 7d8d955..c16f64a 100644 --- a/spring-cloud-cloudfoundry-connector/build.gradle +++ b/spring-cloud-cloudfoundry-connector/build.gradle @@ -46,11 +46,12 @@ configurations { task testJar(type: Jar) { classifier = 'tests' - from sourceSets.test.output.classesDir + from sourceSets.test.output } build.dependsOn testJar artifacts { tests testJar -} \ No newline at end of file + archives testJar +} diff --git a/spring-cloud-pcf-connector/.gitignore b/spring-cloud-pcf-connector/.gitignore deleted file mode 100644 index bd39306..0000000 --- a/spring-cloud-pcf-connector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dependency-reduced-pom.xml -/bin diff --git a/spring-cloud-pcf-connector/README.md b/spring-cloud-pcf-connector/README.md deleted file mode 100644 index 6990824..0000000 --- a/spring-cloud-pcf-connector/README.md +++ /dev/null @@ -1,3 +0,0 @@ -#Spring Cloud PCF extension - -Currently supports the Hadoop service on Pivotal Cloud Foundry \ No newline at end of file diff --git a/spring-cloud-pcf-connector/build.gradle b/spring-cloud-pcf-connector/build.gradle deleted file mode 100644 index d2f3536..0000000 --- a/spring-cloud-pcf-connector/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -description = 'Spring-Cloud Support for Pivotal CF' - -dependencies { - compile project(':spring-cloud-core') - compile project(':spring-cloud-cloudfoundry-connector') - compile project(':spring-cloud-spring-service-connector') - optional("org.apache.hadoop:hadoop-common:$hadoopCommonVersion") - optional("com.netflix.eureka:eureka-client:$eurekaClientVersion") - - testCompile project(path: ':spring-cloud-cloudfoundry-connector', configuration: 'tests') -} diff --git a/spring-cloud-pcf-connector/publish-maven.gradle b/spring-cloud-pcf-connector/publish-maven.gradle deleted file mode 100644 index 632359e..0000000 --- a/spring-cloud-pcf-connector/publish-maven.gradle +++ /dev/null @@ -1,65 +0,0 @@ -apply plugin: "maven" - -ext.optionalDeps = [] -ext.providedDeps = [] - -ext.optional = { optionalDeps << it } -ext.provided = { providedDeps << it } - -install { - repositories.mavenInstaller { - customizePom(pom, project) - } -} - -def customizePom(pom, gradleProject) { - pom.whenConfigured { generatedPom -> - // respect "optional" and "provided" dependencies - gradleProject.optionalDeps.each { dep -> - generatedPom.dependencies.findAll { it.artifactId == dep.name }*.optional = true - } - gradleProject.providedDeps.each { dep -> - generatedPom.dependencies.findAll { it.artifactId == dep.name }*.scope = "provided" - } - - // eliminate test-scoped dependencies (no need in maven central poms) - generatedPom.dependencies.removeAll { dep -> - dep.scope == "test" - } - - // Remove jackson dependencies, since we shade them in - generatedPom.dependencies.removeAll { dep -> - dep.groupId == "com.fasterxml.jackson.core" - } - - // add all items necessary for maven central publication - generatedPom.project { - name = gradleProject.description - description = gradleProject.description - url = "https://github.com/spring-projects/spring-cloud" - organization { - name = "Spring IO" - url = "http://projects.spring.io/spring-cloud" - } - licenses { - license { - name "The Apache Software License, Version 2.0" - url "http://www.apache.org/licenses/LICENSE-2.0.txt" - distribution "repo" - } - } - scm { - url = "https://github.com/spring-projects/spring-cloud" - connection = "scm:git:git://github.com/spring-projects/spring-cloud" - developerConnection = "scm:git:git://github.com/spring-projects/spring-cloud" - } - developers { - developer { - id = "ramnivas" - name = "Ramnivas Laddad" - email = "" - } - } - } - } -} \ No newline at end of file diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceConnector.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceConnector.java deleted file mode 100644 index 9f9f1a9..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceConnector.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.springframework.cloud.pcf.configserver; - -import org.springframework.cloud.Cloud; -import org.springframework.cloud.CloudFactory; -import org.springframework.cloud.service.ServiceInfo; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Method; -import java.util.Collections; - -/** - * Connector to Config Server service - * - * @author Chris Schaefer - */ -@Configuration -public class ConfigServerServiceConnector implements ApplicationListener, Ordered { - /** - * TODO: - * Bind ApplicationListener to ApplicationEnvironmentPreparedEvent, remove reflection - * and add test after repo migration in which we will have a direct dependency on boot. - */ - - private static final String PROPERTY_SOURCE_NAME = "vcapConfigServerUri"; - private static final String EVENT_ENVIRONMENT_METHOD_NAME = "getEnvironment"; - private static final String SPRING_CLOUD_CONFIG_URI = "spring.cloud.config.uri"; - private static final String EVENT_CLASS_NAME = "org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent"; - - private Cloud cloud; - - @Override - public void onApplicationEvent(ApplicationEvent event) { - if(!supports(event.getClass().getName()) || cloud != null) { - return; - } - - cloud = new CloudFactory().getCloud(); - - for(ServiceInfo serviceInfo : cloud.getServiceInfos()) { - if(serviceInfo instanceof ConfigServerServiceInfo) { - String uri = ((ConfigServerServiceInfo) serviceInfo).getUri(); - - MapPropertySource mapPropertySource = new MapPropertySource(PROPERTY_SOURCE_NAME, - Collections.singletonMap(SPRING_CLOUD_CONFIG_URI, uri)); - - getEnvironment(event).getPropertySources().addFirst(mapPropertySource); - } - } - } - - private boolean supports(String className) { - return EVENT_CLASS_NAME.equals(className); - } - - private ConfigurableEnvironment getEnvironment(ApplicationEvent event) { - Method method = ReflectionUtils.findMethod(event.getClass(), EVENT_ENVIRONMENT_METHOD_NAME); - - try { - return (ConfigurableEnvironment) method.invoke(event); - } catch (Exception e) { - throw new RuntimeException("Error obtaining Environment from event", e); - } - } - - @Override - public int getOrder() { - return Ordered.HIGHEST_PRECEDENCE + 4; - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfo.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfo.java deleted file mode 100644 index f2c0d2d..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.springframework.cloud.pcf.configserver; - -import org.springframework.cloud.service.UriBasedServiceInfo; - -/** - * Service info to access Config Server services - * - * @author Chris Schaefer - */ -public class ConfigServerServiceInfo extends UriBasedServiceInfo { - public ConfigServerServiceInfo(String id, String uriString) { - super(id, uriString); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreator.java deleted file mode 100644 index 1d8d1f9..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreator.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.springframework.cloud.pcf.configserver; - -import org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator; -import org.springframework.cloud.cloudfoundry.Tags; - -import java.util.Map; - -/** - * Service info creator for Config Server services - * - * @author Chris Schaefer - */ -public class ConfigServerServiceInfoCreator extends CloudFoundryServiceInfoCreator { - private static final String CREDENTIALS_ID_KEY = "name"; - private static final String CONFIG_SERVER_SERVICE_TAG_NAME = "configuration"; - - public ConfigServerServiceInfoCreator() { - super(new Tags(CONFIG_SERVER_SERVICE_TAG_NAME)); - } - - @Override - public ConfigServerServiceInfo createServiceInfo(Map serviceData) { - String id = (String) serviceData.get(CREDENTIALS_ID_KEY); - String uri = getUriFromCredentials(getCredentials(serviceData)); - - return new ConfigServerServiceInfo(id, uri); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreator.java deleted file mode 100644 index d066eea..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreator.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.springframework.cloud.pcf.eureka; - -import com.netflix.discovery.EurekaClientConfig; -import org.springframework.cloud.service.AbstractServiceConnectorCreator; -import org.springframework.cloud.service.ServiceConnectorConfig; - -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.List; - -/** - * - * Connector creator for Eureka client services - * - * @author Chris Schaefer - */ -public class EurekaClientConfigurationCreator extends AbstractServiceConnectorCreator { - @Override - public EurekaClientConfig create(EurekaServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) { - return getEurekaClientConfig(serviceInfo); - } - - protected EurekaClientConfig getEurekaClientConfig(EurekaServiceInfo serviceInfo) { - return new DefaultPcfEurekaClientConfig(serviceInfo.getUri()); - } - - private static final class DefaultPcfEurekaClientConfig implements EurekaClientConfig { - private static final int MINUTES = 60; - private static final String REGION = "default"; - private static final String DEFAULT_ZONE = "defaultZone"; - private static final String EUREKA_API_PREFIX = "/eureka/"; - - private final String uri; - - public DefaultPcfEurekaClientConfig(String uri) { - this.uri = uri + EUREKA_API_PREFIX; - } - - @Override - public int getRegistryFetchIntervalSeconds() { - return 5; - } - - @Override - public int getInstanceInfoReplicationIntervalSeconds() { - return 30; - } - - @Override - public int getInitialInstanceInfoReplicationIntervalSeconds() { - return 40; - } - - @Override - public int getEurekaServiceUrlPollIntervalSeconds() { - return 5 * MINUTES; - } - - @Override - public String getProxyHost() { - return null; - } - - @Override - public String getProxyPort() { - return null; - } - - @Override - public boolean shouldGZipContent() { - return true; - } - - @Override - public int getEurekaServerReadTimeoutSeconds() { - return 8; - } - - @Override - public int getEurekaServerConnectTimeoutSeconds() { - return 5; - } - - @Override - public String getBackupRegistryImpl() { - return null; - } - - @Override - public int getEurekaServerTotalConnections() { - return 200; - } - - @Override - public int getEurekaServerTotalConnectionsPerHost() { - return 50; - } - - @Override - public String getEurekaServerURLContext() { - return null; - } - - @Override - public String getEurekaServerPort() { - return null; - } - - @Override - public String getEurekaServerDNSName() { - return null; - } - - @Override - public boolean shouldUseDnsForFetchingServiceUrls() { - return false; - } - - @Override - public boolean shouldRegisterWithEureka() { - return true; - } - - @Override - public boolean shouldPreferSameZoneEureka() { - return true; - } - - @Override - public boolean shouldLogDeltaDiff() { - return false; - } - - @Override - public boolean shouldDisableDelta() { - return false; - } - - @Nullable - @Override - public String fetchRegistryForRemoteRegions() { - return null; - } - - @Override - public String getRegion() { - return REGION; - } - - @Override - public String[] getAvailabilityZones(String region) { - return new String[] { DEFAULT_ZONE }; - } - - @Override - public List getEurekaServerServiceUrls(String myZone) { - return Arrays.asList(uri); - } - - @Override - public boolean shouldFilterOnlyUpInstances() { - return true; - } - - @Override - public int getEurekaConnectionIdleTimeoutSeconds() { - return 30; - } - - @Override - public boolean shouldFetchRegistry() { - return true; - } - - @Nullable - @Override - public String getRegistryRefreshSingleVipAddress() { - return null; - } - - @Override - public int getHeartbeatExecutorThreadPoolSize() { - return 2; - } - - @Override - public int getCacheRefreshExecutorThreadPoolSize() { - return 2; - } - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfo.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfo.java deleted file mode 100644 index 790c8d5..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.springframework.cloud.pcf.eureka; - -import org.springframework.cloud.service.ServiceInfo; -import org.springframework.cloud.service.UriBasedServiceInfo; - -/** - * Information to access Eureka services - * - * @author Chris Schaefer - */ -@ServiceInfo.ServiceLabel("eureka") -public class EurekaServiceInfo extends UriBasedServiceInfo { - public EurekaServiceInfo(String id, String uriString) { - super(id, uriString); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreator.java deleted file mode 100644 index c9321a6..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreator.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.springframework.cloud.pcf.eureka; - -import org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator; -import org.springframework.cloud.cloudfoundry.Tags; - -import java.util.Map; - -/** - * - * Service info creator for Eureka services - * - * @author Chris Schaefer - */ -public class EurekaServiceInfoCreator extends CloudFoundryServiceInfoCreator { - private static final String CREDENTIALS_ID_KEY = "name"; - private static final String EUREKA_SERVICE_TAG_NAME = "eureka"; - - public EurekaServiceInfoCreator() { - super(new Tags(EUREKA_SERVICE_TAG_NAME)); - } - - @Override - public EurekaServiceInfo createServiceInfo(Map serviceData) { - String id = (String) serviceData.get(CREDENTIALS_ID_KEY); - String uri = getUriFromCredentials(getCredentials(serviceData)); - - return new EurekaServiceInfo(id, uri); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDDataSourceCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDDataSourceCreator.java deleted file mode 100644 index 5116cbb..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDDataSourceCreator.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.springframework.cloud.pcf.gemfire; - -import org.springframework.cloud.service.relational.DataSourceCreator; - - - -/** - * - * @author Ramnivas Laddad - * - */ -public class GemfireXDDataSourceCreator extends DataSourceCreator { - - private static final String[] DRIVERS = new String[]{"com.pivotal.gemfirexd.internal.jdbc.ClientConnectionPoolDataSource"}; - private static final String VALIDATION_QUERY = null; - - public GemfireXDDataSourceCreator() { - super("spring-cloud.gemfirexd.driver", DRIVERS, VALIDATION_QUERY); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDServiceInfo.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDServiceInfo.java deleted file mode 100644 index 02bb1de..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/gemfire/GemfireXDServiceInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.springframework.cloud.pcf.gemfire; - -import org.springframework.cloud.service.ServiceInfo.ServiceLabel; -import org.springframework.cloud.service.common.RelationalServiceInfo; - - -/** - * - * @author Ramnivas Laddad - * - */ -@ServiceLabel("gemfirexd") -public class GemfireXDServiceInfo extends RelationalServiceInfo { - - public static final String JDBC_URL_TYPE = "gemfirexd"; - - public GemfireXDServiceInfo(String id, String url) { - super(id, url, JDBC_URL_TYPE); - } -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopConfigurationCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopConfigurationCreator.java deleted file mode 100644 index 7fe6c30..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopConfigurationCreator.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.springframework.cloud.pcf.hadoop; - -import org.apache.hadoop.conf.Configuration; -import org.springframework.cloud.service.AbstractServiceConnectorCreator; -import org.springframework.cloud.service.ServiceConnectorConfig; - -/** - * - * @author Ramnivas Laddad - * - */ -public class HadoopConfigurationCreator extends AbstractServiceConnectorCreator { - - @Override - public Configuration create(HadoopServiceInfo hadoopServiceInfo, ServiceConnectorConfig serviceConnectorConfig) { - Configuration configuration = new Configuration(); - configuration.set("fs.defaultFS", hadoopServiceInfo.getDefaultFS()); - configuration.set("yarn.resourcemanager.address", hadoopServiceInfo.getYarnResourceManagerAddress()); - configuration.set("yarn.resourcemanager.scheduler.address", hadoopServiceInfo.getYarnResourceManagerSchedulerAddress()); - - return configuration; - } - - -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopServiceInfo.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopServiceInfo.java deleted file mode 100644 index 5db42db..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/hadoop/HadoopServiceInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.springframework.cloud.pcf.hadoop; - -import org.springframework.cloud.service.BaseServiceInfo; -import org.springframework.cloud.service.ServiceInfo; - -/** - * Hadoop service info (also considers yarn properties). - * - * @author Ramnivas Laddad - * - */ -public class HadoopServiceInfo extends BaseServiceInfo { - - private String defaultHdfsUri; - private String yarnResourceManagerAddress; - private String yarnResourceManagerSchedulerAddress; - - public HadoopServiceInfo(String id, String defaultHdfsUri, - String yarnResourceManagerAddress, String yarnResourceManagerSchedulerAddress) { - super(id); - this.defaultHdfsUri = defaultHdfsUri; - this.yarnResourceManagerAddress = yarnResourceManagerAddress; - this.yarnResourceManagerSchedulerAddress = yarnResourceManagerSchedulerAddress; - } - - - @ServiceInfo.ServiceProperty(category = "connection") - public String getDefaultFS() { - return defaultHdfsUri; - } - - @ServiceInfo.ServiceProperty(category = "connection") - public String getYarnResourceManagerAddress() { - return yarnResourceManagerAddress; - } - - @ServiceInfo.ServiceProperty(category = "connection") - public String getYarnResourceManagerSchedulerAddress() { - return yarnResourceManagerSchedulerAddress; - } - -} diff --git a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/phd/PhdServiceInfoCreator.java b/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/phd/PhdServiceInfoCreator.java deleted file mode 100644 index 9672f6d..0000000 --- a/spring-cloud-pcf-connector/src/main/java/org/springframework/cloud/pcf/phd/PhdServiceInfoCreator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.springframework.cloud.pcf.phd; - -import java.util.Map; - -import org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator; -import org.springframework.cloud.cloudfoundry.Tags; -import org.springframework.cloud.pcf.gemfire.GemfireXDServiceInfo; -import org.springframework.cloud.pcf.hadoop.HadoopServiceInfo; -import org.springframework.cloud.service.BaseCompositeServiceInfo; -import org.springframework.cloud.service.ServiceInfo; -import org.springframework.cloud.service.common.PostgresqlServiceInfo; -import org.springframework.cloud.service.common.RelationalServiceInfo; - -/** - * - * @author Ramnivas Laddad - * - */ -public class PhdServiceInfoCreator extends CloudFoundryServiceInfoCreator { - - public PhdServiceInfoCreator() { - super(new Tags("p-hd")); - } - - @SuppressWarnings("unchecked") - public BaseCompositeServiceInfo createServiceInfo(Map serviceData) { - String id = (String) serviceData.get("name"); - - Map credentials = (Map) serviceData.get("credentials"); - - ServiceInfo hadoopServiceInfo = createHadoopServiceInfo(id, credentials); - ServiceInfo hawqServiceInfo = createHawqServiceInfo(id, credentials); - ServiceInfo gemfirexdServiceInfo = createGemfireXDServiceInfo(id, credentials); - - return new BaseCompositeServiceInfo(id, hadoopServiceInfo, hawqServiceInfo, gemfirexdServiceInfo); - } - - @SuppressWarnings("unchecked") - private HadoopServiceInfo createHadoopServiceInfo(String id, Map credentials) { - Map hdfs = (Map) credentials.get("hdfs"); - Map hdfsConfig = (Map) hdfs.get("configuration"); - String defaultHdfsUri = (String) hdfsConfig.get("fs.defaultFS"); - - Map yarn = (Map) credentials.get("yarn"); - Map yarnConfig = (Map) yarn.get("configuration"); - String yarnResourceManagerAddress = (String) yarnConfig.get("yarn.resourcemanager.address"); - String yarnResourceManagerSchedulerAddress = (String) yarnConfig.get("yarn.resourcemanager.scheduler.address"); - - return new HadoopServiceInfo(id + "/hadoop", defaultHdfsUri, - yarnResourceManagerAddress, yarnResourceManagerSchedulerAddress); - } - - private RelationalServiceInfo createHawqServiceInfo(String id, Map credentials) { - String key = "hawq"; - - return new PostgresqlServiceInfo(id + "/" + key, extractDataSourceUri(id, key, credentials)); - } - - private RelationalServiceInfo createGemfireXDServiceInfo(String id, Map credentials) { - String key = "gemfirexd"; - - return new GemfireXDServiceInfo(id + "/" + key, extractDataSourceUri(id, key, credentials)); - } - - private String extractDataSourceUri(String id, String key, Map credentials) { - @SuppressWarnings("unchecked") - Map hawq = (Map) credentials.get(key); - - String uri = (String) hawq.get("uri"); - - String jdbcUriPrefix = "jdbc:"; - - if (uri.startsWith(jdbcUriPrefix)) { - uri.substring(jdbcUriPrefix.length()); - } - - return uri; - } -} diff --git a/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator b/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator deleted file mode 100644 index da1e07c..0000000 --- a/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator +++ /dev/null @@ -1,3 +0,0 @@ -org.springframework.cloud.pcf.phd.PhdServiceInfoCreator -org.springframework.cloud.pcf.eureka.EurekaServiceInfoCreator -org.springframework.cloud.pcf.configserver.ConfigServerServiceInfoCreator diff --git a/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator b/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator deleted file mode 100644 index 3840a00..0000000 --- a/spring-cloud-pcf-connector/src/main/resources/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator +++ /dev/null @@ -1,3 +0,0 @@ -org.springframework.cloud.pcf.hadoop.HadoopConfigurationCreator -org.springframework.cloud.pcf.gemfire.GemfireXDDataSourceCreator -org.springframework.cloud.pcf.eureka.EurekaClientConfigurationCreator diff --git a/spring-cloud-pcf-connector/src/main/resources/META-INF/spring.factories b/spring-cloud-pcf-connector/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 155b64b..0000000 --- a/spring-cloud-pcf-connector/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.context.ApplicationListener=\ -org.springframework.cloud.pcf.configserver.ConfigServerServiceConnector diff --git a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/hadoop/HadoopConfigurationCreatorTest.java b/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/hadoop/HadoopConfigurationCreatorTest.java deleted file mode 100644 index 2a78595..0000000 --- a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/hadoop/HadoopConfigurationCreatorTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.springframework.cloud.hadoop; - -import static org.junit.Assert.*; - -import org.apache.hadoop.conf.Configuration; -import org.junit.Test; -import org.springframework.cloud.pcf.hadoop.HadoopConfigurationCreator; -import org.springframework.cloud.pcf.hadoop.HadoopServiceInfo; - -/** - * - * @author Ramnivas Laddad - * - */ -public class HadoopConfigurationCreatorTest { - private HadoopConfigurationCreator creator = new HadoopConfigurationCreator(); - - @Test - public void hadoopConfigurationCreation() { - HadoopServiceInfo serviceInfo = new HadoopServiceInfo("phd-hadoop", "hdfs://hdfshost:1234", "yrm:2345", "yrsm:3456"); - Configuration configuration = creator.create(serviceInfo, null); - assertEquals("hdfs://hdfshost:1234", configuration.get("fs.defaultFS")); - assertEquals("yrm:2345", configuration.get("yarn.resourcemanager.address")); - assertEquals("yrsm:3456", configuration.get("yarn.resourcemanager.scheduler.address")); - } -} diff --git a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/PhdServiceInfoCreatorTest.java b/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/PhdServiceInfoCreatorTest.java deleted file mode 100644 index 99ed062..0000000 --- a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/PhdServiceInfoCreatorTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.springframework.cloud.pcf; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.junit.Test; -import org.springframework.cloud.cloudfoundry.AbstractCloudFoundryConnectorTest; -import org.springframework.cloud.pcf.gemfire.GemfireXDServiceInfo; -import org.springframework.cloud.pcf.hadoop.HadoopServiceInfo; -import org.springframework.cloud.service.BaseCompositeServiceInfo; -import org.springframework.cloud.service.ServiceInfo; -import org.springframework.cloud.service.common.PostgresqlServiceInfo; - -/** - * - * @author Ramnivas Laddad - * - */ -public class PhdServiceInfoCreatorTest extends AbstractCloudFoundryConnectorTest { - @Test - public void phdServiceCreation() { - String hadoopUsername = "hadoop-user"; - String hadoopHost = "hadoop-host"; - int hadoopPort = 6000; - String hadoopDirectory = "hadoop-dir"; - String yarnResourceHost = "yark-resource-host"; - int yarnResourcePort = 7000; - String yarnResourceSchedulerHost = "yarn-resource-scheduler-host"; - int yarnResourceSchedulerPort = 8000; - String yarnMapReduceDir = "yarn-map-reduce-dir"; - String yarnStagingDir = "yarn-staging-dir"; - String hawkHost = "hawk-host"; - int hawkPort = 9000; - String hawkUsername = "hawk-user"; - String hawkPassword = "hawk-pass"; - String gemHost = "gem-host"; - int gemPort = 10000; - String gemUsername = "gem-user"; - String gemPassword = "gem-pass"; - String gemWorkingDir = "gem-working-dir"; - - when(mockEnvironment.getEnvValue("VCAP_SERVICES")).thenReturn( - getServicesPayload( - getPhdServicePayload("phd-1", hadoopUsername, hadoopHost, hadoopPort, hadoopDirectory, - yarnResourceHost, yarnResourcePort, - yarnResourceSchedulerHost, yarnResourceSchedulerPort, yarnMapReduceDir, yarnStagingDir, - hawkHost, hawkPort, hawkUsername, hawkPassword, - gemHost, gemPort, gemUsername, gemPassword, gemWorkingDir))); - - List serviceInfos = testCloudConnector.getServiceInfos(); - BaseCompositeServiceInfo phdServiceInfo = (BaseCompositeServiceInfo) getServiceInfo(serviceInfos, "phd-1"); - assertNotNull(phdServiceInfo); - assertEquals(3, phdServiceInfo.getServiceInfos().size()); - - HadoopServiceInfo hadoopServiceInfo = extractServiceInfo(phdServiceInfo.getServiceInfos(), HadoopServiceInfo.class); - assertNotNull(hadoopServiceInfo); - assertHadoopServiceInfo("phd-1/hadoop", hadoopHost, hadoopPort, - yarnResourceHost, yarnResourcePort, yarnResourceSchedulerHost, yarnResourceSchedulerPort, hadoopServiceInfo); - - PostgresqlServiceInfo hawqServiceInfo = extractServiceInfo(phdServiceInfo.getServiceInfos(), PostgresqlServiceInfo.class); - assertEquals("phd-1/hawq", hawqServiceInfo.getId()); - assertNotNull(hawqServiceInfo); - - GemfireXDServiceInfo gemfireXDServiceInfo = extractServiceInfo(phdServiceInfo.getServiceInfos(), GemfireXDServiceInfo.class); - assertNotNull(gemfireXDServiceInfo); - assertEquals("phd-1/gemfirexd", gemfireXDServiceInfo.getId()); - } - - private void assertHadoopServiceInfo(String serviceId, String hadoopHost, int hadoopPort, - String yarnResourceHost, int yarnResourcePort, - String yarnResourceSchedulerHost, int yarnResourceSchedulerPort, - HadoopServiceInfo serviceInfo) { - assertEquals(serviceId, serviceInfo.getId()); - assertEquals(String.format("hdfs://%s:%s", hadoopHost, hadoopPort), serviceInfo.getDefaultFS()); - assertEquals(String.format("%s:%s", yarnResourceHost, yarnResourcePort), serviceInfo.getYarnResourceManagerAddress()); - assertEquals(String.format("%s:%s", yarnResourceSchedulerHost, yarnResourceSchedulerPort), serviceInfo.getYarnResourceManagerSchedulerAddress()); - } - - @SuppressWarnings("unchecked") - private T extractServiceInfo(List serviceInfos, Class typeToSearch) { - for (ServiceInfo serviceInfo: serviceInfos) { - if (serviceInfo.getClass().equals(typeToSearch)) { - return (T)serviceInfo; - } - } - return null; - } - - private String getPhdServicePayload(String serviceName, - String hadoopUsername, String hadoopHost, int hadoopPort, String hadoopDirectory, - String yarnResourceHost, int yarnResourcePort, - String yarnResourceSchedulerHost, int yarnResourceSchedulerPort, - String yarnMapReduceDir, String yarnStagingDir, - String hawkHost, int hawkPort, String hawkUsername, String hawkPassword, - String gemHost, int gemPort, String gemUsername, String gemPassword, String gemWorkingDir) { - return getPhdServicePayload("test-phd-info.json", serviceName, hadoopUsername, hadoopHost, hadoopPort, hadoopDirectory, - yarnResourceHost, yarnResourcePort, - yarnResourceSchedulerHost, yarnResourceSchedulerPort, - yarnMapReduceDir, yarnStagingDir, - hawkHost, hawkPort, hawkUsername, hawkPassword, - gemHost, gemPort, gemUsername, gemPassword, gemWorkingDir); - } - - private String getPhdServicePayload(String filename, String serviceName, - String hadoopUsername, String hadoopHost, int hadoopPort, String hadoopDirectory, - String yarnResourceHost, int yarnResourcePort, - String yarnResourceSchedulerHost, int yarnResourceSchedulerPort, - String yarnMapReduceDir, String yarnStagingDir, - String hawkHost, int hawkPort, String hawkUsername, String hawkPassword, - String gemHost, int gemPort, String gemUsername, String gemPassword, String gemWorkingDir) { - String payload = readTestDataFile(filename); - payload = payload.replace("$serviceName", serviceName); - - payload = payload.replace("$hadoop-username", hadoopUsername); - payload = payload.replace("$hdfs-host", hadoopHost); - payload = payload.replace("$hdfs-port", Integer.toString(hadoopPort)); - payload = payload.replace("$hdfs-directory", hadoopDirectory); - - payload = payload.replace("$yarn-resource-host", yarnResourceHost); - payload = payload.replace("$yarn-resource-port", Integer.toString(yarnResourcePort)); - payload = payload.replace("$yarn-resource-scheduler-host", yarnResourceSchedulerHost); - payload = payload.replace("$yarn-resource-scheduler-port", Integer.toString(yarnResourceSchedulerPort)); - payload = payload.replace("$yarn-map-reduce-dir", yarnMapReduceDir); - payload = payload.replace("$yarn-staging-dir", yarnStagingDir); - - payload = payload.replace("$hawk-host", hawkHost); - payload = payload.replace("$hawk-port", Integer.toString(hawkPort)); - payload = payload.replace("$hawk-username", hawkUsername); - payload = payload.replace("$hawk-password", hawkPassword); - - payload = payload.replace("$gem-host", gemHost); - payload = payload.replace("$gem-port", Integer.toString(gemPort)); - payload = payload.replace("$gem-username", gemUsername); - payload = payload.replace("$gem-password", gemPassword); - payload = payload.replace("$gem-working-dir", gemWorkingDir); - - return payload; - } -} diff --git a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreatorTest.java b/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreatorTest.java deleted file mode 100644 index 8ff29d3..0000000 --- a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/configserver/ConfigServerServiceInfoCreatorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.springframework.cloud.pcf.configserver; - -import org.junit.Test; -import org.springframework.cloud.cloudfoundry.AbstractCloudFoundryConnectorTest; -import org.springframework.cloud.service.ServiceInfo; - -import java.util.List; - -import static org.mockito.Mockito.when; - -/** - * Connector tests for Config Server services - * - * @author Chris Schaefer - */ -public class ConfigServerServiceInfoCreatorTest extends AbstractCloudFoundryConnectorTest { - private static final String CONFIG_SERVER_SERVICE_TAG_NAME = "myConfigServerService"; - private static final String VCAP_SERVICES_ENV_KEY = "VCAP_SERVICES"; - private static final String PAYLOAD_FILE_NAME = "test-config-server-info.json"; - private static final String PAYLOAD_TEMPLATE_SERVICE_NAME = "$serviceName"; - private static final String PAYLOAD_TEMPLATE_HOSTNAME = "$hostname"; - private static final String PAYLOAD_TEMPLATE_PORT = "$port"; - private static final String PAYLOAD_TEMPLATE_USER = "$user"; - private static final String PAYLOAD_TEMPLATE_PASS = "$pass"; - - @Test - public void configServerServiceCreationWithTags() { - when(mockEnvironment.getEnvValue(VCAP_SERVICES_ENV_KEY)) - .thenReturn(getServicesPayload(getConfigServerServicePayload(CONFIG_SERVER_SERVICE_TAG_NAME, - hostname, port, username, password))); - - List serviceInfos = testCloudConnector.getServiceInfos(); - assertServiceFoundOfType(serviceInfos, CONFIG_SERVER_SERVICE_TAG_NAME, ConfigServerServiceInfo.class); - } - - private String getConfigServerServicePayload(String serviceName, String hostname, int port, String user, String password) { - String payload = readTestDataFile(PAYLOAD_FILE_NAME); - payload = payload.replace(PAYLOAD_TEMPLATE_SERVICE_NAME, serviceName); - payload = payload.replace(PAYLOAD_TEMPLATE_HOSTNAME, hostname); - payload = payload.replace(PAYLOAD_TEMPLATE_PORT, Integer.toString(port)); - payload = payload.replace(PAYLOAD_TEMPLATE_USER, user); - payload = payload.replace(PAYLOAD_TEMPLATE_PASS, password); - - return payload; - } -} diff --git a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreatorTest.java b/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreatorTest.java deleted file mode 100644 index 2e3a4dd..0000000 --- a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaClientConfigurationCreatorTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.springframework.cloud.pcf.eureka; - -import com.netflix.discovery.EurekaClientConfig; -import org.junit.Test; - -import java.util.List; - -import static org.junit.Assert.assertEquals; - -/** - * Test cases around the Eureka client configuration creator - * - * @author Chris Schaefer - */ -public class EurekaClientConfigurationCreatorTest { - private static final String REGION = "default"; - private static final String SERVICE_INFO_ID = "id"; - private static final int REGISTRY_FETCH_INTERVAL_SECS = 5; - private static final String AVAILABLITY_ZONE = "defaultZone"; - private static final String URI = "http://user:pass@192.168.23.4:1234"; - private static final String EUREKA_API_PREFIX = "/eureka/"; - - private EurekaClientConfigurationCreator eurekaClientConfigurationCreator = new EurekaClientConfigurationCreator(); - - @Test - public void testClientConfiguration() { - EurekaServiceInfo eurekaServiceInfo = new EurekaServiceInfo(SERVICE_INFO_ID, URI); - - EurekaClientConfig eurekaClientConfig = eurekaClientConfigurationCreator.create(eurekaServiceInfo, null); - List serviceUrls = eurekaClientConfig.getEurekaServerServiceUrls(null); - - assertEquals(1, serviceUrls.size()); - assertEquals(URI + EUREKA_API_PREFIX, serviceUrls.get(0)); - assertEquals(REGION, eurekaClientConfig.getRegion()); - assertEquals(REGISTRY_FETCH_INTERVAL_SECS, eurekaClientConfig.getRegistryFetchIntervalSeconds()); - - String[] availablityZones = eurekaClientConfig.getAvailabilityZones(null); - - assertEquals(1, availablityZones.length); - assertEquals(AVAILABLITY_ZONE, availablityZones[0]); - } -} diff --git a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreatorTest.java b/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreatorTest.java deleted file mode 100644 index 43ba2ff..0000000 --- a/spring-cloud-pcf-connector/src/test/java/org/springframework/cloud/pcf/eureka/EurekaServiceInfoCreatorTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.springframework.cloud.pcf.eureka; - -import org.junit.Test; -import org.springframework.cloud.cloudfoundry.AbstractCloudFoundryConnectorTest; -import org.springframework.cloud.service.ServiceInfo; - -import java.util.List; - -import static org.mockito.Mockito.when; - -/** - * Connector tests for Eureka services - * - * @author Chris Schaefer - */ -public class EurekaServiceInfoCreatorTest extends AbstractCloudFoundryConnectorTest { - private static final String EUREKA_SERVICE_TAG_NAME = "myEurekaInstance"; - private static final String VCAP_SERVICES_ENV_KEY = "VCAP_SERVICES"; - private static final String PAYLOAD_FILE_NAME = "test-eureka-info.json"; - private static final String PAYLOAD_TEMPLATE_SERVICE_NAME = "$serviceName"; - private static final String PAYLOAD_TEMPLATE_HOSTNAME = "$hostname"; - private static final String PAYLOAD_TEMPLATE_PORT = "$port"; - private static final String PAYLOAD_TEMPLATE_USER = "$user"; - private static final String PAYLOAD_TEMPLATE_PASS = "$pass"; - - @Test - public void eurekaServiceCreationWithTags() { - when(mockEnvironment.getEnvValue(VCAP_SERVICES_ENV_KEY)) - .thenReturn(getServicesPayload(getEurekaServicePayload(EUREKA_SERVICE_TAG_NAME, hostname, port, username, password))); - - List serviceInfos = testCloudConnector.getServiceInfos(); - assertServiceFoundOfType(serviceInfos, EUREKA_SERVICE_TAG_NAME, EurekaServiceInfo.class); - } - - private String getEurekaServicePayload(String serviceName, String hostname, int port, String user, String password) { - String payload = readTestDataFile(PAYLOAD_FILE_NAME); - payload = payload.replace(PAYLOAD_TEMPLATE_SERVICE_NAME, serviceName); - payload = payload.replace(PAYLOAD_TEMPLATE_HOSTNAME, hostname); - payload = payload.replace(PAYLOAD_TEMPLATE_PORT, Integer.toString(port)); - payload = payload.replace(PAYLOAD_TEMPLATE_USER, user); - payload = payload.replace(PAYLOAD_TEMPLATE_PASS, password); - - return payload; - } -} diff --git a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/configserver/test-config-server-info.json b/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/configserver/test-config-server-info.json deleted file mode 100644 index 44dad0d..0000000 --- a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/configserver/test-config-server-info.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name":"$serviceName", - "label":"p-config", - "plan":"standard", - "tags":[ - "configuration" - ], - "credentials":{ - "uri":"http://$username:$password@$hostname:$port/" - } -} diff --git a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/eureka/test-eureka-info.json b/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/eureka/test-eureka-info.json deleted file mode 100644 index 527deb4..0000000 --- a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/eureka/test-eureka-info.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name":"$serviceName", - "label":"p-eureka", - "plan":"standard", - "tags":[ - "eureka" - ], - "credentials":{ - "uri":"http://$username:$password@$hostname:$port/" - } -} diff --git a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/test-phd-info.json b/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/test-phd-info.json deleted file mode 100644 index a922f08..0000000 --- a/spring-cloud-pcf-connector/src/test/resources/org/springframework/cloud/pcf/test-phd-info.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name":"$serviceName", - "label":"p-hd", - "tags":[], - "plan":"Standard", - "credentials":{ - "hadoop_username":"$hadoop-username", - "hdfs":{ - "configuration":{ - "fs.defaultFS":"hdfs://$hdfs-host:$hdfs-port" - }, - "directory":"$hdfs-directory" - }, - "yarn":{ - "configuration":{ - "yarn.resourcemanager.address":"$yarn-resource-host:$yarn-resource-port", - "mapreduce.framework.name":"yarn", - "yarn.resourcemanager.scheduler.address":"$yarn-resource-scheduler-host:$yarn-resource-scheduler-port", - "mapreduce.job.working.dir":"$yarn-map-reduce-dir", - "yarn.app.mapreduce.am.staging-dir":"$yarn-staging-dir" - } - }, - "hawq":{ - "uri":"jdbc:postgresql://$hawk-host:$hawk-port/postgres?user=$hawk-username&password=$hawk-password" - }, - "gemfirexd":{ - "uri":"jdbc:gemfirexd://$gem-host:$gem-port/;user=$gem-username;password=$gem-password", - "working.dir":"$gem-working-dir" - } - } -} \ No newline at end of file