Added checkstyle

This commit is contained in:
Marcin Grzejszczak
2019-02-05 10:38:16 +01:00
parent cc9ad3a56c
commit b1546c59ca
357 changed files with 8332 additions and 6406 deletions

14
.editorconfig Normal file
View File

@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
[*.yml]
indent_style = space
indent_size = 2

View File

@@ -1,66 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>repo.spring.io</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<!--
N.B. this profile is only here to support users and IDEs that do not use Maven 3.3.
It isn't needed on the command line if you use the wrapper script (mvnw) or if you use
a native Maven with the right version. Eclipse users should points their Maven tooling to
this settings file, or copy the profile into their ~/.m2/settings.xml.
-->
<id>spring</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<servers>
<server>
<id>repo.spring.io</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<!--
N.B. this profile is only here to support users and IDEs that do not use Maven 3.3.
It isn't needed on the command line if you use the wrapper script (mvnw) or if you use
a native Maven with the right version. Eclipse users should points their Maven tooling to
this settings file, or copy the profile into their ~/.m2/settings.xml.
-->
<id>spring</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>

0
.springformat Normal file
View File

View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-docs</artifactId>
@@ -18,14 +20,14 @@
<main.basedir>${basedir}/..</main.basedir>
<docs.whitelisted.branches>1.3.x,1.4.x</docs.whitelisted.branches>
</properties>
<build>
<build>
<plugins>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
@@ -33,31 +35,31 @@
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<inherited>false</inherited>
</plugin>
</plugins>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<inherited>false</inherited>
</plugin>
</plugins>
</build>
</profile>
</profiles>

56
pom.xml
View File

@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config</artifactId>
@@ -16,14 +18,23 @@
</parent>
<scm>
<url>https://github.com/spring-cloud/spring-cloud-config</url>
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-config.git</connection>
<developerConnection>scm:git:ssh://git@github.com/spring-cloud/spring-cloud-config.git</developerConnection>
<connection>scm:git:git://github.com/spring-cloud/spring-cloud-config.git
</connection>
<developerConnection>
scm:git:ssh://git@github.com/spring-cloud/spring-cloud-config.git
</developerConnection>
<tag>HEAD</tag>
</scm>
<properties>
<bintray.package>config</bintray.package>
<properties>
<bintray.package>config</bintray.package>
<spring-cloud-commons.version>2.1.1.BUILD-SNAPSHOT</spring-cloud-commons.version>
</properties>
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
<maven-checkstyle-plugin.failsOnViolation>true
</maven-checkstyle-plugin.failsOnViolation>
<maven-checkstyle-plugin.includeTestSourceDirectory>true
</maven-checkstyle-plugin.includeTestSourceDirectory>
</properties>
<modules>
<module>spring-cloud-config-dependencies</module>
<module>spring-cloud-config-client</module>
@@ -33,7 +44,7 @@
<module>spring-cloud-starter-config</module>
<module>docs</module>
</modules>
<dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
@@ -61,7 +72,7 @@
<version>1.11.52</version>
</dependency>
</dependencies>
</dependencyManagement>
</dependencyManagement>
<profiles>
<profile>
<id>spring</id>
@@ -139,7 +150,8 @@
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<destFile>${project.build.directory}/jacoco.exec
</destFile>
</configuration>
</execution>
<execution>
@@ -150,7 +162,8 @@
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<dataFile>${project.build.directory}/jacoco.exec
</dataFile>
</configuration>
</execution>
</executions>
@@ -167,4 +180,27 @@
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>

View File

@@ -3,8 +3,8 @@ package demo
@Grab('spring-cloud-starter')
@RestController
class Application {
@RequestMapping("/")
String home() {
"Hello World"
}
}
@RequestMapping("/")
String home() {
"Hello World"
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-config-client</artifactId>
<packaging>jar</packaging>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import org.springframework.beans.factory.BeanFactoryUtils;
@@ -20,7 +21,6 @@ import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -70,18 +70,20 @@ public class ConfigClientAutoConfiguration {
ConfigClientHealthProperties properties, Environment environment) {
return new ConfigServerHealthIndicator(locator, environment, properties);
}
}
@Configuration
@ConditionalOnClass(ContextRefresher.class)
@ConditionalOnBean(ContextRefresher.class)
@ConditionalOnProperty(value = "spring.cloud.config.watch.enabled")
@ConditionalOnProperty("spring.cloud.config.watch.enabled")
protected static class ConfigClientWatchConfiguration {
@Bean
public ConfigClientWatch configClientWatch(ContextRefresher contextRefresher) {
return new ConfigClientWatch(contextRefresher);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.config.client;
@@ -24,6 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*/
@ConfigurationProperties("health.config")
public class ConfigClientHealthProperties {
/**
* Flag to indicate that the config server health indicator should be installed.
*/
@@ -43,10 +43,11 @@ public class ConfigClientHealthProperties {
}
public long getTimeToLive() {
return timeToLive;
return this.timeToLive;
}
public void setTimeToLive(long timeToLive) {
this.timeToLive = timeToLive;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ import java.util.Map;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
@@ -37,9 +36,24 @@ import org.springframework.web.util.UriComponentsBuilder;
@ConfigurationProperties(ConfigClientProperties.PREFIX)
public class ConfigClientProperties {
/**
* Prefix for Spring Cloud Config properties.
*/
public static final String PREFIX = "spring.cloud.config";
/**
* Token header name.
*/
public static final String TOKEN_HEADER = "X-Config-Token";
/**
* State header name.
*/
public static final String STATE_HEADER = "X-Config-State";
/**
* Authorization header name.
*/
public static final String AUTHORIZATION = "authorization";
/**
@@ -162,7 +176,7 @@ public class ConfigClientProperties {
}
public String getUsername() {
return username;
return this.username;
}
public void setUsername(String username) {
@@ -170,7 +184,7 @@ public class ConfigClientProperties {
}
public String getPassword() {
return password;
return this.password;
}
public void setPassword(String password) {
@@ -206,7 +220,7 @@ public class ConfigClientProperties {
}
public int getRequestReadTimeout() {
return requestReadTimeout;
return this.requestReadTimeout;
}
public void setRequestReadTimeout(int requestReadTimeout) {
@@ -214,7 +228,7 @@ public class ConfigClientProperties {
}
public boolean isSendState() {
return sendState;
return this.sendState;
}
public void setSendState(boolean sendState) {
@@ -222,7 +236,7 @@ public class ConfigClientProperties {
}
public Map<String, String> getHeaders() {
return headers;
return this.headers;
}
public void setHeaders(Map<String, String> headers) {
@@ -294,26 +308,68 @@ public class ConfigClientProperties {
return credentials;
}
public ConfigClientProperties override(
org.springframework.core.env.Environment environment) {
ConfigClientProperties override = new ConfigClientProperties();
BeanUtils.copyProperties(this, override);
override.setName(
environment.resolvePlaceholders("${" + ConfigClientProperties.PREFIX
+ ".name:${spring.application.name:application}}"));
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) {
override.setProfile(
environment.getProperty(ConfigClientProperties.PREFIX + ".profile"));
}
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) {
override.setLabel(
environment.getProperty(ConfigClientProperties.PREFIX + ".label"));
}
return override;
}
@Override
public String toString() {
return "ConfigClientProperties [enabled=" + this.enabled + ", profile="
+ this.profile + ", name=" + this.name + ", label=" + this.label
+ ", username=" + this.username + ", password=" + this.password + ", uri="
+ Arrays.toString(this.uri) + ", discovery=" + this.discovery
+ ", failFast=" + this.failFast + ", token=" + this.token
+ ", requestReadTimeout=" + this.requestReadTimeout + ", sendState="
+ this.sendState + ", headers=" + this.headers + "]";
}
/**
* Credentials properties.
*/
public static class Credentials {
private String username;
private String password;
private String uri;
public String getUsername() {
return username;
return this.username;
}
public String getPassword() {
return password;
return this.password;
}
public String getUri() {
return uri;
return this.uri;
}
}
/**
* Discovery properties.
*/
public static class Discovery {
/**
* Default config server service id name.
*/
public static final String DEFAULT_CONFIG_SERVER = "configserver";
/**
@@ -321,6 +377,7 @@ public class ConfigClientProperties {
* will be looked up via discovery).
*/
private boolean enabled;
/**
* Service id to locate config server.
*/
@@ -344,34 +401,4 @@ public class ConfigClientProperties {
}
public ConfigClientProperties override(
org.springframework.core.env.Environment environment) {
ConfigClientProperties override = new ConfigClientProperties();
BeanUtils.copyProperties(this, override);
override.setName(
environment.resolvePlaceholders("${" + ConfigClientProperties.PREFIX
+ ".name:${spring.application.name:application}}"));
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".profile")) {
override.setProfile(
environment.getProperty(ConfigClientProperties.PREFIX + ".profile"));
}
if (environment.containsProperty(ConfigClientProperties.PREFIX + ".label")) {
override.setLabel(
environment.getProperty(ConfigClientProperties.PREFIX + ".label"));
}
return override;
}
@Override
public String toString() {
return "ConfigClientProperties [enabled=" + enabled + ", profile=" + profile
+ ", name=" + name + ", label=" + label + ", username=" + username
+ ", password=" + password + ", uri=" + Arrays.toString(uri)
+ ", discovery=" + discovery + ", failFast=" + failFast + ", token="
+ token + ", requestReadTimeout=" + requestReadTimeout + ", sendState="
+ sendState + ", headers=" + headers + "]";
}
}

View File

@@ -1,15 +1,40 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
/**
* @author Spencer Gibb
*/
public class ConfigClientStateHolder {
public final class ConfigClientStateHolder {
private ConfigClientStateHolder() {
throw new IllegalStateException("Can't instantiate a utility class");
}
private static ThreadLocal<String> state = new ThreadLocal<>();
public static void resetState() {
state.remove();
}
public static String getState() {
return state.get();
}
public static void setState(String newState) {
if (newState == null) {
resetState();
@@ -18,7 +43,4 @@ public class ConfigClientStateHolder {
state.set(newState);
}
public static String getState() {
return state.get();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,10 +18,12 @@ package org.springframework.cloud.config.client;
import java.io.Closeable;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.PostConstruct;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
@@ -34,11 +36,12 @@ import static org.springframework.util.StringUtils.hasText;
*/
public class ConfigClientWatch implements Closeable, EnvironmentAware {
private static Log log = LogFactory
.getLog(ConfigServicePropertySourceLocator.class);
private static Log log = LogFactory.getLog(ConfigServicePropertySourceLocator.class);
private final AtomicBoolean running = new AtomicBoolean(false);
private final ContextRefresher refresher;
private Environment environment;
public ConfigClientWatch(ContextRefresher refresher) {
@@ -59,7 +62,7 @@ public class ConfigClientWatch implements Closeable, EnvironmentAware {
public void watchConfigServer() {
if (this.running.get()) {
String newState = this.environment.getProperty("config.client.state");
String oldState = ConfigClientStateHolder.getState();
String oldState = ConfigClientStateHolder.getState();
// only refresh if state has changed
if (stateChanged(oldState, newState)) {
@@ -71,7 +74,7 @@ public class ConfigClientWatch implements Closeable, EnvironmentAware {
/* for testing */ boolean stateChanged(String oldState, String newState) {
return (!hasText(oldState) && hasText(newState))
|| (hasText(oldState) && !oldState.equals(newState));
|| (hasText(oldState) && !oldState.equals(newState));
}
@Override

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import java.util.ArrayList;
@@ -16,7 +32,9 @@ import org.springframework.core.env.PropertySource;
public class ConfigServerHealthIndicator extends AbstractHealthIndicator {
private ConfigServicePropertySourceLocator locator;
private ConfigClientHealthProperties properties;
private Environment environment;
private long lastAccess = 0;
@@ -30,28 +48,31 @@ public class ConfigServerHealthIndicator extends AbstractHealthIndicator {
this.properties = properties;
}
@Override
protected void doHealthCheck(Builder builder) throws Exception {
@Override
protected void doHealthCheck(Builder builder) throws Exception {
PropertySource<?> propertySource = getPropertySource();
builder.up();
if (propertySource instanceof CompositePropertySource) {
List<String> sources = new ArrayList<>();
for (PropertySource<?> ps : ((CompositePropertySource) propertySource).getPropertySources()) {
for (PropertySource<?> ps : ((CompositePropertySource) propertySource)
.getPropertySources()) {
sources.add(ps.getName());
}
builder.withDetail("propertySources", sources);
} else if (propertySource!=null) {
}
else if (propertySource != null) {
builder.withDetail("propertySources", propertySource.toString());
} else {
}
else {
builder.unknown().withDetail("error", "no property sources located");
}
}
}
private PropertySource<?> getPropertySource() {
long accessTime = System.currentTimeMillis();
if (isCacheStale(accessTime)) {
this.lastAccess = accessTime;
this.cached = locator.locate(this.environment);
this.cached = this.locator.locate(this.environment);
}
return this.cached;
}

View File

@@ -1,16 +1,39 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.retry.annotation.Retryable;
import java.util.List;
/**
* Fetches config server instances.
*
* @author Nastya Smirnova
*/
public class ConfigServerInstanceProvider {
private static Log logger = LogFactory.getLog(ConfigServerInstanceProvider.class);
private final DiscoveryClient client;
public ConfigServerInstanceProvider(DiscoveryClient client) {
@@ -29,4 +52,5 @@ public class ConfigServerInstanceProvider {
+ ") via discovery. No of instances found: " + instances.size());
return instances;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.cloud.config.client;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -53,13 +54,14 @@ public class ConfigServiceBootstrapConfiguration {
@Bean
@ConditionalOnMissingBean(ConfigServicePropertySourceLocator.class)
@ConditionalOnProperty(value = "spring.cloud.config.enabled", matchIfMissing = true)
public ConfigServicePropertySourceLocator configServicePropertySource(ConfigClientProperties properties) {
public ConfigServicePropertySourceLocator configServicePropertySource(
ConfigClientProperties properties) {
ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(
properties);
return locator;
}
@ConditionalOnProperty(value = "spring.cloud.config.fail-fast")
@ConditionalOnProperty("spring.cloud.config.fail-fast")
@ConditionalOnClass({ Retryable.class, Aspect.class, AopAutoConfiguration.class })
@Configuration
@EnableRetry(proxyTargetClass = true)
@@ -71,12 +73,12 @@ public class ConfigServiceBootstrapConfiguration {
@ConditionalOnMissingBean(name = "configServerRetryInterceptor")
public RetryOperationsInterceptor configServerRetryInterceptor(
RetryProperties properties) {
return RetryInterceptorBuilder
.stateless()
return RetryInterceptorBuilder.stateless()
.backOffOptions(properties.getInitialInterval(),
properties.getMultiplier(), properties.getMaxInterval())
.maxAttempts(properties.getMaxAttempts()).build();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
import org.springframework.cloud.config.environment.Environment;
@@ -51,9 +52,9 @@ import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import static org.springframework.cloud.config.client.ConfigClientProperties.AUTHORIZATION;
import static org.springframework.cloud.config.client.ConfigClientProperties.STATE_HEADER;
import static org.springframework.cloud.config.client.ConfigClientProperties.TOKEN_HEADER;
import static org.springframework.cloud.config.client.ConfigClientProperties.AUTHORIZATION;
/**
* @author Dave Syer
@@ -67,6 +68,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
.getLog(ConfigServicePropertySourceLocator.class);
private RestTemplate restTemplate;
private ConfigClientProperties defaultProperties;
public ConfigServicePropertySourceLocator(ConfigClientProperties defaultProperties) {
@@ -80,8 +82,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
ConfigClientProperties properties = this.defaultProperties.override(environment);
CompositePropertySource composite = new CompositePropertySource("configService");
RestTemplate restTemplate = this.restTemplate == null
? getSecureRestTemplate(properties)
: this.restTemplate;
? getSecureRestTemplate(properties) : this.restTemplate;
Exception error = null;
String errorBody = null;
try {
@@ -134,12 +135,12 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
}
if (properties.isFailFast()) {
throw new IllegalStateException(
"Could not locate PropertySource and the fail fast property is set, failing" +
(errorBody == null ? "" : ": " + errorBody), error);
"Could not locate PropertySource and the fail fast property is set, failing"
+ (errorBody == null ? "" : ": " + errorBody),
error);
}
logger.warn("Could not locate PropertySource: " + (errorBody == null
? error == null ? "label not found" : error.getMessage()
: errorBody));
? error == null ? "label not found" : error.getMessage() : errorBody));
return null;
}
@@ -226,10 +227,12 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
catch (ResourceAccessException e) {
logger.info("Connect Timeout Exception on Url - " + uri
+ ". Will be trying the next url if available");
if (i == noOfUrls - 1)
if (i == noOfUrls - 1) {
throw e;
else
}
else {
continue;
}
}
if (response == null || response.getStatusCode() != HttpStatus.OK) {
@@ -259,7 +262,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
headers.remove(AUTHORIZATION); // To avoid redundant addition of header
}
if (!headers.isEmpty()) {
template.setInterceptors(Arrays.<ClientHttpRequestInterceptor> asList(
template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList(
new GenericRequestHeaderInterceptor(headers)));
}
@@ -285,6 +288,9 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
}
/**
* Adds the provided headers to the request.
*/
public static class GenericRequestHeaderInterceptor
implements ClientHttpRequestInterceptor {
@@ -297,15 +303,16 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException {
for (Entry<String, String> header : headers.entrySet()) {
for (Entry<String, String> header : this.headers.entrySet()) {
request.getHeaders().add(header.getKey(), header.getValue());
}
return execution.execute(request, body);
}
protected Map<String, String> getHeaders() {
return headers;
return this.headers;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,8 @@ import org.springframework.context.event.SmartApplicationListener;
@Configuration
@Import({ UtilAutoConfiguration.class })
@EnableDiscoveryClient
public class DiscoveryClientConfigServiceBootstrapConfiguration implements SmartApplicationListener {
public class DiscoveryClientConfigServiceBootstrapConfiguration
implements SmartApplicationListener {
private static Log logger = LogFactory
.getLog(DiscoveryClientConfigServiceBootstrapConfiguration.class);
@@ -76,7 +77,8 @@ public class DiscoveryClientConfigServiceBootstrapConfiguration implements Smart
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
startup((ContextRefreshedEvent) event);
} else if (event instanceof HeartbeatEvent) {
}
else if (event instanceof HeartbeatEvent) {
heartbeat((HeartbeatEvent) event);
}
}
@@ -86,7 +88,7 @@ public class DiscoveryClientConfigServiceBootstrapConfiguration implements Smart
}
public void heartbeat(HeartbeatEvent event) {
if (monitor.update(event.getValue())) {
if (this.monitor.update(event.getValue())) {
refresh();
}
}
@@ -128,7 +130,7 @@ public class DiscoveryClientConfigServiceBootstrapConfiguration implements Smart
}
catch (Exception ex) {
if (config.isFailFast()) {
if (this.config.isFailFast()) {
throw ex;
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +29,17 @@ public class RetryProperties {
* Initial retry interval in milliseconds.
*/
long initialInterval = 1000;
/**
* Multiplier for next interval.
*/
double multiplier = 1.1;
/**
* Maximum interval for backoff.
*/
long maxInterval = 2000;
/**
* Maximum number of attempts.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,18 +51,18 @@ public class Environment {
}
/**
* Copies all fields except propertySources
* @param env
* Copies all fields except propertySources.
* @param env Spring Environment
*/
public Environment(Environment env) {
this(env.getName(), env.getProfiles(), env.getLabel(), env.getVersion(), env.getState());
this(env.getName(), env.getProfiles(), env.getLabel(), env.getVersion(),
env.getState());
}
@JsonCreator
public Environment(@JsonProperty("name") String name,
@JsonProperty("profiles") String[] profiles,
@JsonProperty("label") String label,
@JsonProperty("version") String version,
@JsonProperty("label") String label, @JsonProperty("version") String version,
@JsonProperty("state") String state) {
super();
this.name = name;
@@ -85,11 +85,11 @@ public class Environment {
}
public List<PropertySource> getPropertySources() {
return propertySources;
return this.propertySources;
}
public String getName() {
return name;
return this.name;
}
public void setName(String name) {
@@ -97,7 +97,7 @@ public class Environment {
}
public String getLabel() {
return label;
return this.label;
}
public void setLabel(String label) {
@@ -105,7 +105,7 @@ public class Environment {
}
public String[] getProfiles() {
return profiles;
return this.profiles;
}
public void setProfiles(String[] profiles) {
@@ -113,7 +113,7 @@ public class Environment {
}
public String getVersion() {
return version;
return this.version;
}
public void setVersion(String version) {
@@ -121,7 +121,7 @@ public class Environment {
}
public String getState() {
return state;
return this.state;
}
public void setState(String state) {
@@ -130,10 +130,10 @@ public class Environment {
@Override
public String toString() {
return "Environment [name=" + name + ", profiles=" + Arrays.asList(profiles)
+ ", label=" + label + ", propertySources=" + propertySources
+ ", version=" + version
+ ", state=" + state + "]";
return "Environment [name=" + this.name + ", profiles="
+ Arrays.asList(this.profiles) + ", label=" + this.label
+ ", propertySources=" + this.propertySources + ", version="
+ this.version + ", state=" + this.state + "]";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,9 +25,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* Simple plain text serializable encapsulation of a named source of key-value pairs.
* Basically a DTO for {@link PropertySource}, but also applicable outside the domain of a
* Spring application.
*
* @author Dave Syer
*
* @author Dave Syer
*/
public class PropertySource {
@@ -43,16 +42,16 @@ public class PropertySource {
}
public String getName() {
return name;
return this.name;
}
public Map<?, ?> getSource() {
return source;
return this.source;
}
@Override
public String toString() {
return "PropertySource [name=" + name + "]";
return "PropertySource [name=" + this.name + "]";
}
}

View File

@@ -1,8 +1,7 @@
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.config.client.ConfigClientAutoConfiguration
# Bootstrap components
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration,\
org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration
org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import java.util.Arrays;
@@ -17,7 +33,7 @@ import org.springframework.cloud.commons.util.UtilAutoConfiguration;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -44,7 +60,7 @@ public abstract class BaseDiscoveryClientConfigServiceBootstrapConfigurationTest
void givenDiscoveryClientReturnsNoInfo() {
given(this.client.getInstances(DEFAULT_CONFIG_SERVER))
.willReturn(Collections.<ServiceInstance> emptyList());
.willReturn(Collections.<ServiceInstance>emptyList());
}
void givenDiscoveryClientReturnsInfo() {
@@ -60,20 +76,21 @@ public abstract class BaseDiscoveryClientConfigServiceBootstrapConfigurationTest
void givenDiscoveryClientReturnsInfoOnThirdTry() {
given(this.client.getInstances(DEFAULT_CONFIG_SERVER))
.willReturn(Collections.<ServiceInstance> emptyList())
.willReturn(Collections.<ServiceInstance> emptyList())
.willReturn(Collections.<ServiceInstance>emptyList())
.willReturn(Collections.<ServiceInstance>emptyList())
.willReturn(Arrays.asList(this.info));
}
void expectNoInstancesOfConfigServerException() {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(
this.expectedException.expect(IllegalStateException.class);
this.expectedException.expectMessage(
"No instances found of configserver (" + DEFAULT_CONFIG_SERVER + ")");
}
void expectDiscoveryClientConfigServiceBootstrapConfigurationIsSetup() {
assertEquals(1, this.context.getBeanNamesForType(
DiscoveryClientConfigServiceBootstrapConfiguration.class).length);
assertThat(this.context.getBeanNamesForType(
DiscoveryClientConfigServiceBootstrapConfiguration.class).length)
.isEqualTo(1);
}
void expectConfigClientPropertiesHasDefaultConfiguration() {
@@ -88,18 +105,18 @@ public abstract class BaseDiscoveryClientConfigServiceBootstrapConfigurationTest
ConfigClientProperties properties = this.context
.getBean(ConfigClientProperties.class);
Credentials credentials = properties.getCredentials(0);
assertEquals(expectedUri, credentials.getUri());
assertThat(credentials.getUri()).isEqualTo(expectedUri);
}
void expectConfigClientPropertiesHasMultipleUris(final String expectedUri1,
final String expectedUri2) {
ConfigClientProperties properties = this.context
.getBean(ConfigClientProperties.class);
assertEquals(2, properties.getUri().length);
assertThat(properties.getUri().length).isEqualTo(2);
Credentials credentials1 = properties.getCredentials(0);
Credentials credentials2 = properties.getCredentials(1);
assertEquals(expectedUri1, credentials1.getUri());
assertEquals(expectedUri2, credentials2.getUri());
assertThat(credentials1.getUri()).isEqualTo(expectedUri1);
assertThat(credentials2.getUri()).isEqualTo(expectedUri2);
}
void verifyDiscoveryClientCalledThreeTimes() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
public class ConfigClientAutoConfigurationTests {
@@ -32,17 +32,18 @@ public class ConfigClientAutoConfigurationTests {
public void sunnyDay() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
ConfigClientAutoConfiguration.class);
assertEquals(1, BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length);
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length).isEqualTo(1);
context.close();
}
@Test
public void withParent() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
ConfigClientAutoConfiguration.class).child(Object.class).web(WebApplicationType.NONE).run();
assertEquals(1, BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length);
ConfigClientAutoConfiguration.class).child(Object.class)
.web(WebApplicationType.NONE).run();
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length).isEqualTo(1);
context.close();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.mock.env.MockEnvironment;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import org.junit.Rule;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -35,96 +34,96 @@ import org.junit.Rule;
*/
public class ConfigClientPropertiesTests {
private ConfigClientProperties locator = new ConfigClientProperties(
new StandardEnvironment());
@Rule
public ExpectedException expected = ExpectedException.none();
private ConfigClientProperties locator = new ConfigClientProperties(
new StandardEnvironment());
@Test
public void vanilla() {
locator.setUri(new String[] { "http://localhost:9999" });
locator.setPassword("secret");
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("user", credentials.getUsername());
assertEquals("secret", credentials.getPassword());
this.locator.setUri(new String[] { "http://localhost:9999" });
this.locator.setPassword("secret");
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("user");
assertThat(credentials.getPassword()).isEqualTo("secret");
}
@Test
public void uriCreds() {
locator.setUri(new String[] { "http://foo:bar@localhost:9999" });
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("foo", credentials.getUsername());
assertEquals("bar", credentials.getPassword());
this.locator.setUri(new String[] { "http://foo:bar@localhost:9999" });
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("foo");
assertThat(credentials.getPassword()).isEqualTo("bar");
}
@Test
public void explicitPassword() {
locator.setUri(new String[] { "http://foo:bar@localhost:9999" });
locator.setPassword("secret");
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("foo", credentials.getUsername());
assertEquals("secret", credentials.getPassword());
this.locator.setUri(new String[] { "http://foo:bar@localhost:9999" });
this.locator.setPassword("secret");
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("foo");
assertThat(credentials.getPassword()).isEqualTo("secret");
}
@Test
public void testIfNoColonPresentInUriCreds() {
locator.setUri(new String[] { "http://foobar@localhost:9999" });
locator.setPassword("secret");
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("foobar", credentials.getUsername());
assertEquals("secret", credentials.getPassword());
this.locator.setUri(new String[] { "http://foobar@localhost:9999" });
this.locator.setPassword("secret");
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("foobar");
assertThat(credentials.getPassword()).isEqualTo("secret");
}
@Test
public void testIfColonPresentAtTheEndInUriCreds() {
locator.setUri(new String[] { "http://foobar:@localhost:9999" });
locator.setPassword("secret");
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("foobar", credentials.getUsername());
assertEquals("secret", credentials.getPassword());
this.locator.setUri(new String[] { "http://foobar:@localhost:9999" });
this.locator.setPassword("secret");
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("foobar");
assertThat(credentials.getPassword()).isEqualTo("secret");
}
@Test
public void testIfColonPresentAtTheStartInUriCreds() {
locator.setUri(new String[] { "http://:foobar@localhost:9999" });
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("", credentials.getUsername());
assertEquals("foobar", credentials.getPassword());
this.locator.setUri(new String[] { "http://:foobar@localhost:9999" });
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("");
assertThat(credentials.getPassword()).isEqualTo("foobar");
}
@Test
public void testIfColonPresentAtTheStartAndEndInUriCreds() {
locator.setUri(new String[] { "http://:foobar:@localhost:9999" });
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals("", credentials.getUsername());
assertEquals("foobar:", credentials.getPassword());
this.locator.setUri(new String[] { "http://:foobar:@localhost:9999" });
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo("");
assertThat(credentials.getPassword()).isEqualTo("foobar:");
}
@Test
public void testIfSpacePresentAsUriCreds() {
locator.setUri(new String[] { "http:// @localhost:9999" });
locator.setPassword("secret");
Credentials credentials = locator.getCredentials(0);
assertEquals("http://localhost:9999", credentials.getUri());
assertEquals(" ", credentials.getUsername());
assertEquals("secret", credentials.getPassword());
this.locator.setUri(new String[] { "http:// @localhost:9999" });
this.locator.setPassword("secret");
Credentials credentials = this.locator.getCredentials(0);
assertThat(credentials.getUri()).isEqualTo("http://localhost:9999");
assertThat(credentials.getUsername()).isEqualTo(" ");
assertThat(credentials.getPassword()).isEqualTo("secret");
}
@Test
public void changeNameInOverride() {
locator.setName("one");
this.locator.setName("one");
ConfigurableEnvironment environment = new StandardEnvironment();
TestPropertyValues.of("spring.application.name:two").applyTo(environment);
ConfigClientProperties override = locator.override(environment);
assertEquals("two", override.getName());
ConfigClientProperties override = this.locator.override(environment);
assertThat(override.getName()).isEqualTo("two");
}
@Test
@@ -137,32 +136,35 @@ public class ConfigClientPropertiesTests {
properties.setUsername("explicitName");
properties.setPassword("explicitPW");
Credentials credentials = properties.getCredentials(0);
assertThat(credentials.getPassword(), equalTo("explicitPW"));
assertThat(credentials.getUsername(), equalTo("explicitName"));
assertThat(credentials.getPassword()).isEqualTo("explicitPW");
assertThat(credentials.getUsername()).isEqualTo("explicitName");
}
@Test
public void checkIfExceptionThrownForNegativeIndex() {
locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
expected.expect(IllegalStateException.class);
expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = locator.getCredentials(-1);
this.locator.setUri(
new String[] { "http://localhost:8888", "http://localhost:8889" });
this.expected.expect(IllegalStateException.class);
this.expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = this.locator.getCredentials(-1);
}
@Test
public void checkIfExceptionThrownForPositiveInvalidIndex() {
locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
expected.expect(IllegalStateException.class);
expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = locator.getCredentials(3);
this.locator.setUri(
new String[] { "http://localhost:8888", "http://localhost:8889" });
this.expected.expect(IllegalStateException.class);
this.expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = this.locator.getCredentials(3);
}
@Test
public void checkIfExceptionThrownForIndexEqualToLength() {
locator.setUri(new String[] { "http://localhost:8888", "http://localhost:8889" });
expected.expect(IllegalStateException.class);
expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = locator.getCredentials(2);
this.locator.setUri(
new String[] { "http://localhost:8888", "http://localhost:8889" });
this.expected.expect(IllegalStateException.class);
this.expected.expectMessage("Trying to access an invalid array index");
Credentials credentials = this.locator.getCredentials(2);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,28 +12,27 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.config.client;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Spencer Gibb
*/
public class ConfigClientWatchTests {
@Test
public void stateChangedWorks() {
ConfigClientWatch watch = new ConfigClientWatch(null);
assertThat(watch.stateChanged(null, "1"), is(true));
assertThat(watch.stateChanged("1", "2"), is(true));
assertThat(watch.stateChanged("1", null), is(true));
assertThat(watch.stateChanged("1", "1"), is(false));
watch.close();
}
@Test
public void stateChangedWorks() {
ConfigClientWatch watch = new ConfigClientWatch(null);
assertThat(watch.stateChanged(null, "1")).isTrue();
assertThat(watch.stateChanged("1", "2")).isTrue();
assertThat(watch.stateChanged("1", null)).isTrue();
assertThat(watch.stateChanged("1", "1")).isFalse();
watch.close();
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import org.junit.Test;
@@ -8,19 +24,21 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
public class ConfigServerBootstrapConfigurationTests {
@Test
public void withHealthIndicator() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
PropertySourceBootstrapConfiguration.class, ConfigServiceBootstrapConfiguration.class)
.child(ConfigClientAutoConfiguration.class).web(WebApplicationType.NONE).run();
assertEquals(1, BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length);
assertEquals(1, BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigServerHealthIndicator.class).length);
PropertySourceBootstrapConfiguration.class,
ConfigServiceBootstrapConfiguration.class)
.child(ConfigClientAutoConfiguration.class)
.web(WebApplicationType.NONE).run();
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigClientProperties.class).length).isEqualTo(1);
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context,
ConfigServerHealthIndicator.class).length).isEqualTo(1);
context.close();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,16 @@
package org.springframework.cloud.config.client;
import static org.junit.Assert.assertEquals;
import java.util.Collections;
import org.junit.Test;
import org.springframework.boot.actuate.health.Status;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -24,14 +33,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.Collections;
import org.junit.Test;
import org.springframework.boot.actuate.health.Status;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
/**
* @author Dave Syer
* @author Marcos Barbero
@@ -39,46 +40,50 @@ import org.springframework.core.env.PropertySource;
*/
public class ConfigServerHealthIndicatorTests {
private ConfigServicePropertySourceLocator locator =
mock(ConfigServicePropertySourceLocator.class);
private ConfigServicePropertySourceLocator locator = mock(
ConfigServicePropertySourceLocator.class);
private Environment environment = mock(Environment.class);
private ConfigServerHealthIndicator indicator = new ConfigServerHealthIndicator(
locator, environment, new ConfigClientHealthProperties());
this.locator, this.environment, new ConfigClientHealthProperties());
@Test
public void testDefaultStatus() {
// UNKNOWN is better than DOWN since it doesn't stop the app from working
assertEquals(Status.UNKNOWN, indicator.health().getStatus());
assertThat(this.indicator.health().getStatus()).isEqualTo(Status.UNKNOWN);
}
@Test
public void testExceptionStatus() {
doThrow(new IllegalStateException()).when(locator).locate(any(Environment.class));
assertEquals(Status.DOWN, indicator.health().getStatus());
verify(locator, times(1)).locate(any(Environment.class));
doThrow(new IllegalStateException()).when(this.locator)
.locate(any(Environment.class));
assertThat(this.indicator.health().getStatus()).isEqualTo(Status.DOWN);
verify(this.locator, times(1)).locate(any(Environment.class));
}
@Test
public void testServerUp() {
PropertySource<?> source = new MapPropertySource("foo", Collections.<String,Object>emptyMap());
doReturn(source).when(locator).locate(any(Environment.class));
assertEquals(Status.UP, indicator.health().getStatus());
verify(locator, times(1)).locate(any(Environment.class));
PropertySource<?> source = new MapPropertySource("foo",
Collections.<String, Object>emptyMap());
doReturn(source).when(this.locator).locate(any(Environment.class));
assertThat(this.indicator.health().getStatus()).isEqualTo(Status.UP);
verify(this.locator, times(1)).locate(any(Environment.class));
}
@Test
public void healthIsCached() {
PropertySource<?> source = new MapPropertySource("foo", Collections.<String,Object>emptyMap());
doReturn(source).when(locator).locate(any(Environment.class));
PropertySource<?> source = new MapPropertySource("foo",
Collections.<String, Object>emptyMap());
doReturn(source).when(this.locator).locate(any(Environment.class));
// not cached
assertEquals(Status.UP, indicator.health().getStatus());
assertThat(this.indicator.health().getStatus()).isEqualTo(Status.UP);
// cached
assertEquals(Status.UP, indicator.health().getStatus());
assertThat(this.indicator.health().getStatus()).isEqualTo(Status.UP);
verify(locator, times(1)).locate(any(Environment.class));
verify(this.locator, times(1)).locate(any(Environment.class));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
package org.springframework.cloud.config.client;
import java.lang.reflect.Field;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -28,8 +31,6 @@ import org.springframework.core.env.Environment;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.client.RestTemplate;
import java.lang.reflect.Field;
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -38,50 +39,54 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class ConfigServiceBootstrapConfigurationTest {
private AnnotationConfigApplicationContext context;
private AnnotationConfigApplicationContext context;
@Before
public void setUp() throws Exception {
this.context = new AnnotationConfigApplicationContext();
}
@Before
public void setUp() throws Exception {
this.context = new AnnotationConfigApplicationContext();
}
@After
public void tearDown() throws Exception {
if (this.context != null) {
this.context.close();
}
}
@After
public void tearDown() throws Exception {
if (this.context != null) {
this.context.close();
}
}
@Test
public void overrideConfigServicePropertySourceLocatorWhenBeanIsProvided() {
TestPropertyValues.of("spring.cloud.config.enabled=true").applyTo(this.context);
this.context.register(ConfigServicePropertySourceLocatorOverrideConfig.class);
this.context.register(ConfigServiceBootstrapConfiguration.class);
this.context.refresh();
@Test
public void overrideConfigServicePropertySourceLocatorWhenBeanIsProvided() {
TestPropertyValues.of("spring.cloud.config.enabled=true").applyTo(this.context);
this.context.register(ConfigServicePropertySourceLocatorOverrideConfig.class);
this.context.register(ConfigServiceBootstrapConfiguration.class);
this.context.refresh();
ConfigServicePropertySourceLocator locator = this.context.getBean(ConfigServicePropertySourceLocator.class);
ConfigServicePropertySourceLocator locator = this.context
.getBean(ConfigServicePropertySourceLocator.class);
Field restTemplateField = ReflectionUtils.findField(ConfigServicePropertySourceLocator.class, "restTemplate");
restTemplateField.setAccessible(true);
Field restTemplateField = ReflectionUtils
.findField(ConfigServicePropertySourceLocator.class, "restTemplate");
restTemplateField.setAccessible(true);
RestTemplate restTemplate = (RestTemplate) ReflectionUtils.getField(restTemplateField, locator);
RestTemplate restTemplate = (RestTemplate) ReflectionUtils
.getField(restTemplateField, locator);
assertThat(restTemplate).isNotNull();
}
assertThat(restTemplate).isNotNull();
}
@Configuration
protected static class ConfigServicePropertySourceLocatorOverrideConfig {
@Configuration
protected static class ConfigServicePropertySourceLocatorOverrideConfig {
@Autowired
private Environment environment;
@Autowired
private Environment environment;
@Bean
public ConfigServicePropertySourceLocator locator() {
ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(new ConfigClientProperties(environment));
locator.setRestTemplate(new RestTemplate());
return locator;
}
@Bean
public ConfigServicePropertySourceLocator locator() {
ConfigServicePropertySourceLocator locator = new ConfigServicePropertySourceLocator(
new ConfigClientProperties(this.environment));
locator.setRestTemplate(new RestTemplate());
return locator;
}
}
}
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import java.io.ByteArrayInputStream;
@@ -34,9 +50,6 @@ import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.client.RestTemplate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.springframework.cloud.config.client.ConfigClientProperties.AUTHORIZATION;
public class ConfigServicePropertySourceLocatorTests {
@@ -56,7 +69,7 @@ public class ConfigServicePropertySourceLocatorTests {
Environment body = new Environment("app", "master");
mockRequestResponseWithoutLabel(new ResponseEntity<>(body, HttpStatus.OK));
this.locator.setRestTemplate(this.restTemplate);
assertNotNull(this.locator.locate(this.environment));
assertThat(this.locator.locate(this.environment)).isNotNull();
}
@Test
@@ -66,7 +79,7 @@ public class ConfigServicePropertySourceLocatorTests {
this.locator.setRestTemplate(this.restTemplate);
TestPropertyValues.of("spring.cloud.config.label:v1.0.0")
.applyTo(this.environment);
assertNotNull(this.locator.locate(this.environment));
assertThat(this.locator.locate(this.environment)).isNotNull();
}
@Test
@@ -77,7 +90,7 @@ public class ConfigServicePropertySourceLocatorTests {
this.locator.setRestTemplate(this.restTemplate);
TestPropertyValues.of("spring.cloud.config.label:release/v1.0.0")
.applyTo(this.environment);
assertNotNull(this.locator.locate(this.environment));
assertThat(this.locator.locate(this.environment)).isNotNull();
}
@Test
@@ -86,7 +99,7 @@ public class ConfigServicePropertySourceLocatorTests {
new ResponseEntity<Void>((Void) null, HttpStatus.NOT_FOUND),
"nosuchlabel");
this.locator.setRestTemplate(this.restTemplate);
assertNull(this.locator.locate(this.environment));
assertThat(this.locator.locate(this.environment)).isNull();
}
@Test
@@ -94,7 +107,7 @@ public class ConfigServicePropertySourceLocatorTests {
mockRequestResponseWithoutLabel(
new ResponseEntity<>("Wah!", HttpStatus.INTERNAL_SERVER_ERROR));
this.locator.setRestTemplate(this.restTemplate);
assertNull(this.locator.locate(this.environment));
assertThat(this.locator.locate(this.environment)).isNull();
}
@Test
@@ -247,8 +260,8 @@ public class ConfigServicePropertySourceLocatorTests {
while (iterator.hasNext()) {
GenericRequestHeaderInterceptor genericRequestHeaderInterceptor = (GenericRequestHeaderInterceptor) iterator
.next();
assertEquals(null,
genericRequestHeaderInterceptor.getHeaders().get(AUTHORIZATION));
assertThat(genericRequestHeaderInterceptor.getHeaders().get(AUTHORIZATION))
.isEqualTo(null);
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.client;
import org.junit.Test;
@@ -48,4 +64,4 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationNoSpringRetryTest
verifyDiscoveryClientCalledOnce();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.cloud.config.client.ConfigClientProperties.Credentials;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -38,9 +38,11 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests
this.context = new AnnotationConfigApplicationContext(
DiscoveryClientConfigServiceBootstrapConfiguration.class);
assertEquals(0, this.context.getBeanNamesForType(DiscoveryClient.class).length);
assertEquals(0, this.context.getBeanNamesForType(
DiscoveryClientConfigServiceBootstrapConfiguration.class).length);
assertThat(this.context.getBeanNamesForType(DiscoveryClient.class).length)
.isEqualTo(0);
assertThat(this.context.getBeanNamesForType(
DiscoveryClientConfigServiceBootstrapConfiguration.class).length)
.isEqualTo(0);
}
@Test
@@ -63,7 +65,7 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests
givenDiscoveryClientReturnsInfo();
verifyDiscoveryClientCalledOnce();
context.publishEvent(new HeartbeatEvent(context, "new"));
this.context.publishEvent(new HeartbeatEvent(this.context, "new"));
expectConfigClientPropertiesHasConfigurationFromEureka();
}
@@ -109,9 +111,9 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests
ConfigClientProperties locator = this.context
.getBean(ConfigClientProperties.class);
Credentials credentials = locator.getCredentials(0);
assertEquals("http://foo:8877/", credentials.getUri());
assertEquals("bar", credentials.getPassword());
assertEquals("user", credentials.getUsername());
assertThat(credentials.getUri()).isEqualTo("http://foo:8877/");
assertThat(credentials.getPassword()).isEqualTo("bar");
assertThat(credentials.getUsername()).isEqualTo("user");
}
@Test
@@ -148,7 +150,7 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests
expectDiscoveryClientConfigServiceBootstrapConfigurationIsSetup();
verifyDiscoveryClientCalledThreeTimes();
context.publishEvent(new HeartbeatEvent(context, "new"));
this.context.publishEvent(new HeartbeatEvent(this.context, "new"));
expectConfigClientPropertiesHasConfigurationFromEureka();
}

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -19,56 +20,56 @@
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.credhub</groupId>
<artifactId>spring-credhub-core</artifactId>
<version>${spring-credhub.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.junit.http</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.apache</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.12</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.credhub</groupId>
<artifactId>spring-credhub-core</artifactId>
<version>${spring-credhub.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.junit.http</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.apache</artifactId>
<version>${jgit.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.12</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.cloud</groupId>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,41 +28,43 @@ import org.springframework.util.MultiValueMap;
*
*/
public abstract class BasePropertyPathNotificationExtractor
implements PropertyPathNotificationExtractor {
implements PropertyPathNotificationExtractor {
@Override
public PropertyPathNotification extract(MultiValueMap<String, String> headers,
Map<String, Object> request) {
if (requestBelongsToGitRepoManager(headers)) {
if (request.get("commits") instanceof Collection) {
Set<String> paths = new HashSet<>();
@SuppressWarnings("unchecked")
Collection<Map<String, Object>> commits = (Collection<Map<String, Object>>) request
.get("commits");
addPaths( paths, commits );
if (!paths.isEmpty()) {
return new PropertyPathNotification(paths.toArray(new String[0]));
}
}
}
return null;
}
@Override
public PropertyPathNotification extract(MultiValueMap<String, String> headers,
Map<String, Object> request) {
if (requestBelongsToGitRepoManager(headers)) {
if (request.get("commits") instanceof Collection) {
Set<String> paths = new HashSet<>();
@SuppressWarnings("unchecked")
Collection<Map<String, Object>> commits = (Collection<Map<String, Object>>) request
.get("commits");
addPaths(paths, commits);
if (!paths.isEmpty()) {
return new PropertyPathNotification(paths.toArray(new String[0]));
}
}
}
return null;
}
protected void addPaths(Set< String > paths, Collection< Map< String, Object > > commits) {
for (Map<String, Object> commit : commits) {
addAllPaths(paths, commit, "added");
addAllPaths(paths, commit, "removed");
addAllPaths(paths, commit, "modified");
}
}
protected void addPaths(Set<String> paths, Collection<Map<String, Object>> commits) {
for (Map<String, Object> commit : commits) {
addAllPaths(paths, commit, "added");
addAllPaths(paths, commit, "removed");
addAllPaths(paths, commit, "modified");
}
}
private void addAllPaths(Set<String> paths, Map<String, Object> commit, String name) {
@SuppressWarnings("unchecked")
Collection<String> files = (Collection<String>) commit.get(name);
if (files != null) {
paths.addAll(files);
}
}
protected abstract boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers);
private void addAllPaths(Set<String> paths, Map<String, Object> commit, String name) {
@SuppressWarnings("unchecked")
Collection<String> files = (Collection<String>) commit.get(name);
if (files != null) {
paths.addAll(files);
}
}
protected abstract boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,21 +37,22 @@ public class BitbucketPropertyPathNotificationExtractor
@Override
public PropertyPathNotification extract(MultiValueMap<String, String> headers,
Map<String, Object> request) {
if (("repo:push".equals(headers.getFirst("X-Event-Key")) ||
"pullrequest:fulfilled".equals(headers.getFirst("X-Event-Key"))) &&
StringUtils.hasText(headers.getFirst("X-Hook-UUID"))) {
if (("repo:push".equals(headers.getFirst("X-Event-Key"))
|| "pullrequest:fulfilled".equals(headers.getFirst("X-Event-Key")))
&& StringUtils.hasText(headers.getFirst("X-Hook-UUID"))) {
// Bitbucket cloud
Object push = request.get("push");
if (push instanceof Map && ((Map<?,?>)push).get("changes") instanceof Collection) {
if (push instanceof Map
&& ((Map<?, ?>) push).get("changes") instanceof Collection) {
// Bitbucket doesn't tell us the files that changed so this is a
// broadcast to all apps
return new PropertyPathNotification("application.yml");
}
}
else if ( ("repo:refs_changed".equals(headers.getFirst("X-Event-Key")) ||
"pr:merged".equals(headers.getFirst("X-Event-Key"))) &&
StringUtils.hasText(headers.getFirst("X-Request-Id"))) {
//Bitbucket server
else if (("repo:refs_changed".equals(headers.getFirst("X-Event-Key"))
|| "pr:merged".equals(headers.getFirst("X-Event-Key")))
&& StringUtils.hasText(headers.getFirst("X-Request-Id"))) {
// Bitbucket server
if (request.get("changes") instanceof Collection) {
// Bitbucket doesn't tell us the files that changed so this is a
// broadcast to all apps

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@ import org.springframework.core.annotation.Order;
import org.springframework.util.MultiValueMap;
/**
* A {@link PropertyPathNotificationExtractor} that cycles through a set of (ordered) delegates,
* looking for the first non-null outcome.
* A {@link PropertyPathNotificationExtractor} that cycles through a set of (ordered)
* delegates, looking for the first non-null outcome.
*
* @author Dave Syer
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,52 +36,55 @@ import org.springframework.context.annotation.Import;
@Import(FileMonitorConfiguration.class)
public class EnvironmentMonitorAutoConfiguration {
@Autowired(required=false)
@Autowired(required = false)
private List<PropertyPathNotificationExtractor> extractors;
@Bean
public PropertyPathEndpoint propertyPathEndpoint(BusProperties busProperties) {
return new PropertyPathEndpoint(new CompositePropertyPathNotificationExtractor(this.extractors), busProperties.getId());
return new PropertyPathEndpoint(
new CompositePropertyPathNotificationExtractor(this.extractors),
busProperties.getId());
}
@Configuration
protected static class PropertyPathNotificationExtractorConfiguration {
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.github.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.github.enabled", havingValue = "true", matchIfMissing = true)
public GithubPropertyPathNotificationExtractor githubPropertyPathNotificationExtractor() {
return new GithubPropertyPathNotificationExtractor();
}
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.gitlab.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.gitlab.enabled", havingValue = "true", matchIfMissing = true)
public GitlabPropertyPathNotificationExtractor gitlabPropertyPathNotificationExtractor() {
return new GitlabPropertyPathNotificationExtractor();
}
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.bitbucket.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.bitbucket.enabled", havingValue = "true", matchIfMissing = true)
public BitbucketPropertyPathNotificationExtractor bitbucketPropertyPathNotificationExtractor() {
return new BitbucketPropertyPathNotificationExtractor();
}
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.gitea.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.gitea.enabled", havingValue = "true", matchIfMissing = true)
public GiteaPropertyPathNotificationExtractor giteaPropertyPathNotificationExtractor() {
return new GiteaPropertyPathNotificationExtractor();
}
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.gitee.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.gitee.enabled", havingValue = "true", matchIfMissing = true)
public GiteePropertyPathNotificationExtractor giteePropertyPathNotificationExtractor() {
return new GiteePropertyPathNotificationExtractor();
}
@Bean
@ConditionalOnProperty(value="spring.cloud.config.server.monitor.gogs.enabled", havingValue="true", matchIfMissing=true)
@ConditionalOnProperty(value = "spring.cloud.config.server.monitor.gogs.enabled", havingValue = "true", matchIfMissing = true)
public GogsPropertyPathNotificationExtractor gogsPropertyPathNotificationExtractor() {
return new GogsPropertyPathNotificationExtractor();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
@@ -98,7 +99,7 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
}
/**
* see {@link #getPhase()}
* see {@link #getPhase()}.
* @param phase the phase.
*/
public void setPhase(int phase) {
@@ -111,8 +112,8 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
}
/**
* @see #isRunning()
* @param running true if running.
* @see #isRunning()
*/
public void setRunning(boolean running) {
this.running = running;
@@ -124,8 +125,8 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
}
/**
* @see #isAutoStartup()
* @param autoStartup true to auto start.
* @see #isAutoStartup()
*/
public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
@@ -187,7 +188,8 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
if (this.scmRepository != null) {
try {
Resource resource = this.resourceLoader.getResource(this.scmRepository.getUri());
Resource resource = this.resourceLoader
.getResource(this.scmRepository.getUri());
if (resource instanceof FileSystemResource) {
return Collections.singleton(Paths.get(resource.getURI()));
}
@@ -306,11 +308,13 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
log.debug("registering: " + dir + " for file creation events");
}
try {
dir.register(this.watcher, StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_MODIFY);
} catch (IOException e) {
dir.register(this.watcher, StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_MODIFY);
}
catch (IOException e) {
throw e;
} catch (Exception e) {
}
catch (Exception e) {
throw new IOException("Cannot register watcher for " + dir, e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,24 +30,26 @@ import org.springframework.util.MultiValueMap;
*/
@Order(Ordered.LOWEST_PRECEDENCE - 100)
public class GiteaPropertyPathNotificationExtractor
extends BasePropertyPathNotificationExtractor {
extends BasePropertyPathNotificationExtractor {
private static final String HEADERS_KEY = "X-Gitea-Event";
private static final String HEADERS_KEY = "X-Gitea-Event";
private static final String HEADERS_VALUE = "push";
/**
* gitea doesn't return which files have been added/modified/deleted yet.
*
* @see https://github.com/go-gitea/gitea/issues/4313
*/
@Override
protected void addPaths(Set<String> paths, Collection<Map<String, Object>> commits) {
paths.add( "application.yml" );
}
private static final String HEADERS_VALUE = "push";
/**
* gitea doesn't return which files have been added/modified/deleted yet.
*
* related issue: https://github.com/go-gitea/gitea/issues/4313
*/
@Override
protected void addPaths(Set<String> paths, Collection<Map<String, Object>> commits) {
paths.add("application.yml");
}
@Override
protected boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
@Override
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.util.MultiValueMap;
/**
* @author lly835
* @author lly 835
*
*/
@Order(Ordered.LOWEST_PRECEDENCE - 100)
@@ -33,7 +33,9 @@ public class GiteePropertyPathNotificationExtractor
private static final String HEADERS_VALUE = "Push Hook";
@Override
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
protected boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,12 @@ import org.springframework.util.MultiValueMap;
*/
@Order(Ordered.LOWEST_PRECEDENCE - 300)
public class GithubPropertyPathNotificationExtractor
extends BasePropertyPathNotificationExtractor {
extends BasePropertyPathNotificationExtractor {
@Override
protected boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers) {
return "push".equals(headers.getFirst("X-Github-Event"));
}
@Override
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
return "push".equals(headers.getFirst("X-Github-Event"));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,12 @@ import org.springframework.util.MultiValueMap;
*/
@Order(Ordered.LOWEST_PRECEDENCE - 100)
public class GitlabPropertyPathNotificationExtractor
extends BasePropertyPathNotificationExtractor {
extends BasePropertyPathNotificationExtractor {
@Override
protected boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers) {
return "Push Hook".equals(headers.getFirst("X-Gitlab-Event"));
}
@Override
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
return "Push Hook".equals(headers.getFirst("X-Gitlab-Event"));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,19 +21,21 @@ import org.springframework.core.annotation.Order;
import org.springframework.util.MultiValueMap;
/**
* @author lly835
* @author lly 835
*
*/
@Order(Ordered.LOWEST_PRECEDENCE - 100)
public class GogsPropertyPathNotificationExtractor
extends BasePropertyPathNotificationExtractor {
extends BasePropertyPathNotificationExtractor {
private static final String HEADERS_KEY = "X-Gogs-Event";
private static final String HEADERS_KEY = "X-Gogs-Event";
private static final String HEADERS_VALUE = "push";
private static final String HEADERS_VALUE = "push";
@Override
protected boolean requestBelongsToGitRepoManager(
MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
@Override
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
@@ -46,22 +47,24 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping(path = "${spring.cloud.config.monitor.endpoint.path:}/monitor")
public class PropertyPathEndpoint
implements ApplicationEventPublisherAware {
public class PropertyPathEndpoint implements ApplicationEventPublisherAware {
private static Log log = LogFactory.getLog(PropertyPathEndpoint.class);
private final PropertyPathNotificationExtractor extractor;
private ApplicationEventPublisher applicationEventPublisher;
private String busId;
public PropertyPathEndpoint(PropertyPathNotificationExtractor extractor, String busId) {
public PropertyPathEndpoint(PropertyPathNotificationExtractor extractor,
String busId) {
this.extractor = extractor;
this.busId = busId;
}
/* for testing */ String getBusId() {
return busId;
return this.busId;
}
@Override
@@ -84,9 +87,8 @@ public class PropertyPathEndpoint
if (this.applicationEventPublisher != null) {
for (String service : services) {
log.info("Refresh for: " + service);
this.applicationEventPublisher
.publishEvent(new RefreshRemoteApplicationEvent(this,
this.busId, service));
this.applicationEventPublisher.publishEvent(
new RefreshRemoteApplicationEvent(this, this.busId, service));
}
return services;
}
@@ -107,8 +109,8 @@ public class PropertyPathEndpoint
private Set<String> guessServiceName(String path) {
Set<String> services = new LinkedHashSet<>();
if (path != null) {
String stem = StringUtils
.stripFilenameExtension(StringUtils.getFilename(StringUtils.cleanPath(path)));
String stem = StringUtils.stripFilenameExtension(
StringUtils.getFilename(StringUtils.cleanPath(path)));
// TODO: correlate with service registry
int index = stem.indexOf("-");
while (index >= 0) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,12 +24,12 @@ package org.springframework.cloud.config.monitor;
*/
public class PropertyPathNotification {
private String[] paths;
public PropertyPathNotification(String... paths) {
this.paths = paths;
}
private String[] paths;
public PropertyPathNotification() {
}
@@ -42,15 +42,19 @@ public class PropertyPathNotification {
}
public boolean equals(Object o) {
if (o == this)
if (o == this) {
return true;
if (!(o instanceof PropertyPathNotification))
}
if (!(o instanceof PropertyPathNotification)) {
return false;
}
final PropertyPathNotification other = (PropertyPathNotification) o;
if (!other.canEqual(this))
if (!other.canEqual(this)) {
return false;
if (!java.util.Arrays.deepEquals(this.getPaths(), other.getPaths()))
}
if (!java.util.Arrays.deepEquals(this.getPaths(), other.getPaths())) {
return false;
}
return true;
}
@@ -66,7 +70,8 @@ public class PropertyPathNotification {
}
public String toString() {
return "PropertyPathNotification(paths=" + java.util.Arrays
.deepToString(this.getPaths()) + ")";
return "PropertyPathNotification(paths="
+ java.util.Arrays.deepToString(this.getPaths()) + ")";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,3 +1,3 @@
# Autoconfiguration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.config.monitor.EnvironmentMonitorAutoConfiguration
org.springframework.cloud.config.monitor.EnvironmentMonitorAutoConfiguration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,20 +16,18 @@
package org.springframework.cloud.config.monitor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.Map;
import java.util.UUID;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Spencer Gibb
@@ -44,8 +42,8 @@ public class BitbucketPropertyPathNotificationExtractorTests {
private HttpHeaders headers;
@Before
public void setup(){
headers = new HttpHeaders();
public void setup() {
this.headers = new HttpHeaders();
}
@Test
@@ -54,18 +52,18 @@ public class BitbucketPropertyPathNotificationExtractorTests {
Map<String, Object> value = readPayload("pathsamples/bitbucket.json");
setHeaders("repo:push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("application.yml", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("application.yml");
}
@Test
@Test
public void bitbucketPullRequestFulfillmentDetected() throws Exception {
// https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Merged
Map<String, Object> value = readPayload("pathsamples/bitbucket.json");
setHeaders("pullrequest:fulfilled");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("application.yml", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("application.yml");
}
private void setHeaders(String eventKey) {
@@ -87,50 +85,51 @@ public class BitbucketPropertyPathNotificationExtractorTests {
public void githubNotDetected() throws Exception {
assertNotExtracted("pathsamples/github.json", "repo:push");
}
@Test
public void missingUuidHeader() throws Exception {
// https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push
Map<String, Object> value = readPayload("pathsamples/bitbucket.json");
this.headers.set("X-Event-Key", "repo:push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
@Test
public void missingChanges() throws Exception {
// https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push
Map<String, Object> value = readPayload("pathsamples/bitbucket-invalid.json");
setHeaders("repo:push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
private void assertNotExtracted(String path, String eventKey) throws java.io.IOException {
private void assertNotExtracted(String path, String eventKey)
throws java.io.IOException {
Map<String, Object> value = readPayload(path);
setHeaders(eventKey);
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
@Test
public void bitbucketServerSample() throws Exception {
// https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html
Map<String, Object> value = readPayload("pathsamples/bitbucketserver.json");
setServerHeaders("repo:refs_changed");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("application.yml", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("application.yml");
}
@Test
@Test
public void bitbucketServerSamplePullRequest() throws Exception {
// https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html
Map<String, Object> value = readPayload("pathsamples/bitbucketserver.json");
setServerHeaders("pr:merged");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("application.yml", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("application.yml");
}
private void setServerHeaders(String eventKey) {
@@ -140,39 +139,41 @@ public class BitbucketPropertyPathNotificationExtractorTests {
@Test
public void notAPushOrPullRequestServer() throws Exception {
assertNotExtractedServer("pathsamples/bitbucketserver.json", "repo:comment:added");
assertNotExtractedServer("pathsamples/bitbucketserver.json",
"repo:comment:added");
}
@Test
public void missingUuidHeaderServer() throws Exception {
// https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html
Map<String, Object> value = readPayload("pathsamples/bitbucketserver.json");
this.headers.set("X-Event-Key", "repo:refs_changed");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
@Test
public void missingChangesServer() throws Exception {
// https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html
Map<String, Object> value = readPayload("pathsamples/bitbucketserver-invalid.json");
Map<String, Object> value = readPayload(
"pathsamples/bitbucketserver-invalid.json");
setServerHeaders("repo:refs_changed");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
private void assertNotExtractedServer(String path, String eventKey) throws java.io.IOException {
private void assertNotExtractedServer(String path, String eventKey)
throws java.io.IOException {
Map<String, Object> value = readPayload(path);
setServerHeaders(eventKey);
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
private Map<String, Object> readPayload(String path) throws java.io.IOException {
return new ObjectMapper().readValue(
new ClassPathResource(path).getInputStream(),
new TypeReference<Map<String, Object>>() {
});
return new ObjectMapper().readValue(new ClassPathResource(path).getInputStream(),
new TypeReference<Map<String, Object>>() {
});
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +20,14 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -53,8 +50,8 @@ public class CompositePropertyPathNotificationExtractorTests {
});
this.headers.set("X-Github-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("README.md", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("README.md");
}
@Test
@@ -65,18 +62,19 @@ public class CompositePropertyPathNotificationExtractorTests {
});
this.headers.set("X-Gitlab-Event", "Push Hook");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertThat(extracted).isNotNull();
String[] paths = extracted.getPaths();
assertThat("paths was wrong", paths, arrayContainingInAnyOrder("oldapp.yml", "newapp.properties", "application.yml"));
assertThat(paths).as("paths was wrong").contains("oldapp.yml",
"newapp.properties", "application.yml");
}
@Test
public void fallback() throws Exception {
Map<String, Object> value = Collections.<String, Object> singletonMap("path",
Map<String, Object> value = Collections.<String, Object>singletonMap("path",
"foo");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("foo", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("foo");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -41,33 +41,29 @@ public class EnvironmentMonitorAutoConfigurationTests {
@Test
public void testExtractorsCount() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
BusConfig.class,
EnvironmentMonitorAutoConfiguration.class,
BusConfig.class, EnvironmentMonitorAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class, ServerProperties.class,
PropertyPlaceholderAutoConfiguration.class).properties("server.port=-1")
.run();
PropertyPathEndpoint endpoint = context.getBean(PropertyPathEndpoint.class);
assertEquals(7,
((Collection<?>) ReflectionTestUtils.getField(
ReflectionTestUtils.getField(endpoint, "extractor"),
"extractors")).size());
assertThat(((Collection<?>) ReflectionTestUtils.getField(
ReflectionTestUtils.getField(endpoint, "extractor"), "extractors"))
.size()).isEqualTo(7);
context.close();
}
@Test
public void testCanAddCustomPropertyPathNotificationExtractor() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(
BusConfig.class,
CustomPropertyPathNotificationExtractorConfig.class,
BusConfig.class, CustomPropertyPathNotificationExtractorConfig.class,
EnvironmentMonitorAutoConfiguration.class,
ServletWebServerFactoryAutoConfiguration.class, ServerProperties.class,
PropertyPlaceholderAutoConfiguration.class).properties("server.port=-1")
.run();
PropertyPathEndpoint endpoint = context.getBean(PropertyPathEndpoint.class);
assertEquals(8,
((Collection<?>) ReflectionTestUtils.getField(
ReflectionTestUtils.getField(endpoint, "extractor"),
"extractors")).size());
assertThat(((Collection<?>) ReflectionTestUtils.getField(
ReflectionTestUtils.getField(endpoint, "extractor"), "extractors"))
.size()).isEqualTo(8);
context.close();
}
@@ -78,16 +74,19 @@ public class EnvironmentMonitorAutoConfigurationTests {
public BusProperties busProperties() {
return new BusProperties();
}
}
}
@Configuration
static class CustomPropertyPathNotificationExtractorConfig {
@Bean
public PropertyPathNotificationExtractor customNotificationExtractor() {
return (headers, payload) -> {
throw new UnsupportedOperationException("doesn't do anything");
};
throw new UnsupportedOperationException("doesn't do anything");
};
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,16 @@
package org.springframework.cloud.config.monitor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.Map;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Juan Pablo Santos Rodríguez
@@ -35,32 +33,32 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class GiteaPropertyPathNotificationExtractorTests {
private GiteaPropertyPathNotificationExtractor extractor = new GiteaPropertyPathNotificationExtractor();
private GiteaPropertyPathNotificationExtractor extractor = new GiteaPropertyPathNotificationExtractor();
private HttpHeaders headers = new HttpHeaders();
private HttpHeaders headers = new HttpHeaders();
@Test
public void giteaSample() throws Exception {
// See https://docs.gitea.io/en-us/webhooks/
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gitea.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gitea-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("application.yml", extracted.getPaths()[0]);
}
@Test
public void giteaSample() throws Exception {
// See https://docs.gitea.io/en-us/webhooks/
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gitea.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gitea-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("application.yml");
}
@Test
public void notAPushNotDetected() throws Exception {
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gitea.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gitea-Event", "issues");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
}
@Test
public void notAPushNotDetected() throws Exception {
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gitea.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gitea-Event", "issues");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertThat(extracted).isNull();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,14 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author lly835
*
* @author lly 835
*/
public class GiteePropertyPathNotificationExtractorTests {
@@ -46,8 +45,8 @@ public class GiteePropertyPathNotificationExtractorTests {
});
this.headers.set("x-git-oschina-event", "Push Hook");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("d.txt", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("d.txt");
}
@Test
@@ -58,7 +57,7 @@ public class GiteePropertyPathNotificationExtractorTests {
});
this.headers.set("x-git-oschina-event", "Issue Hook");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,16 +18,14 @@ package org.springframework.cloud.config.monitor;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -48,8 +46,8 @@ public class GithubPropertyPathNotificationExtractorTests {
});
this.headers.set("X-Github-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("README.md", extracted.getPaths()[0]);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("README.md");
}
@Test
@@ -60,7 +58,7 @@ public class GithubPropertyPathNotificationExtractorTests {
});
this.headers.set("X-Github-Event", "issues");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,17 +18,14 @@ package org.springframework.cloud.config.monitor;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -49,9 +46,10 @@ public class GitlabPropertyPathNotificationExtractorTests {
});
this.headers.set("X-Gitlab-Event", "Push Hook");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertThat(extracted).isNotNull();
String[] paths = extracted.getPaths();
assertThat("paths was wrong", paths, arrayContainingInAnyOrder("oldapp.yml", "newapp.properties", "application.yml"));
assertThat(paths).as("paths was wrong").contains("oldapp.yml",
"newapp.properties", "application.yml");
}
@Test
@@ -63,7 +61,7 @@ public class GitlabPropertyPathNotificationExtractorTests {
});
this.headers.set("X-Gitlab-Event", "Issue Hook");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
assertThat(extracted).isNull();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,16 +16,16 @@
package org.springframework.cloud.config.monitor;
import static org.junit.Assert.*;
import java.util.Map;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Craig Walls
@@ -33,32 +33,32 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class GogsPropertyPathNotificationExtractorTests {
private GogsPropertyPathNotificationExtractor extractor = new GogsPropertyPathNotificationExtractor();
private GogsPropertyPathNotificationExtractor extractor = new GogsPropertyPathNotificationExtractor();
private HttpHeaders headers = new HttpHeaders();
private HttpHeaders headers = new HttpHeaders();
@Test
public void gogsSample() throws Exception {
// See https://gogs.io/docs/features/webhook
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gogs.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gogs-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNotNull(extracted);
assertEquals("README.md", extracted.getPaths()[0]);
}
@Test
public void gogsSample() throws Exception {
// See https://gogs.io/docs/features/webhook
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gogs.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gogs-Event", "push");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertThat(extracted).isNotNull();
assertThat(extracted.getPaths()[0]).isEqualTo("README.md");
}
@Test
public void notAPushNotDetected() throws Exception {
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gogs.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gogs-Event", "issues");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertNull(extracted);
}
@Test
public void notAPushNotDetected() throws Exception {
Map<String, Object> value = new ObjectMapper().readValue(
new ClassPathResource("pathsamples/gogs.json").getInputStream(),
new TypeReference<Map<String, Object>>() {
});
this.headers.set("X-Gogs-Event", "issues");
PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
assertThat(extracted).isNull();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,17 +16,18 @@
package org.springframework.cloud.config.monitor;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*
@@ -34,8 +35,8 @@ import org.springframework.http.HttpHeaders;
public class PropertyPathEndpointTests {
private PropertyPathEndpoint endpoint = new PropertyPathEndpoint(
new CompositePropertyPathNotificationExtractor(
Collections.emptyList()), "abc1");
new CompositePropertyPathNotificationExtractor(Collections.emptyList()),
"abc1");
@Before
public void init() {
@@ -44,15 +45,16 @@ public class PropertyPathEndpointTests {
publisher.refresh();
}
@Test
public void testBusId() {
assertEquals("abc1", this.endpoint.getBusId());
}
@Test
public void testBusId() {
assertThat(this.endpoint.getBusId()).isEqualTo("abc1");
}
@Test
public void testNotifyByForm() {
assertEquals(0, this.endpoint
.notifyByForm(new HttpHeaders(), new ArrayList<>()).size());
assertThat(
this.endpoint.notifyByForm(new HttpHeaders(), new ArrayList<>()).size())
.isEqualTo(0);
}
@Test
@@ -60,62 +62,59 @@ public class PropertyPathEndpointTests {
List<String> request = new ArrayList<>();
request.add("/foo/bar.properties");
request.add("/application.properties");
assertEquals("[bar, *]",
this.endpoint.notifyByForm(new HttpHeaders(), request).toString());
assertThat(this.endpoint.notifyByForm(new HttpHeaders(), request).toString())
.isEqualTo("[bar, *]");
}
@Test
public void testNotifyAll() {
assertEquals("[*]",
assertThat(
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "application.yml"))
.toString());
.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "application.yml"))
.toString()).isEqualTo("[*]");
}
@Test
public void testNotifyAllWithProfile() {
assertEquals("[*:local]",
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "application-local.yml"))
.toString());
assertThat(this.endpoint
.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "application-local.yml"))
.toString()).isEqualTo("[*:local]");
}
@Test
public void testNotifyOne() {
assertEquals("[foo]",
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "foo.yml"))
.toString());
assertThat(this.endpoint.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "foo.yml")).toString())
.isEqualTo("[foo]");
}
@Test
public void testNotifyOneWithWindowsPath() {
assertEquals("[foo]",
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "C:\\config\\foo.yml"))
.toString());
assertThat(this.endpoint
.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "C:\\config\\foo.yml"))
.toString()).isEqualTo("[foo]");
}
@Test
public void testNotifyOneWithProfile() {
assertEquals("[foo:local, foo-local]",
assertThat(
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "foo-local.yml"))
.toString());
.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "foo-local.yml"))
.toString()).isEqualTo("[foo:local, foo-local]");
}
@Test
public void testNotifyMultiDash() {
assertEquals("[foo:local-dev, foo-local:dev, foo-local-dev]",
assertThat(
this.endpoint
.notifyByPath(new HttpHeaders(), Collections
.singletonMap("path", "foo-local-dev.yml"))
.toString());
.notifyByPath(new HttpHeaders(),
Collections.singletonMap("path", "foo-local-dev.yml"))
.toString()).isEqualTo(
"[foo:local-dev, foo-local:dev, foo-local-dev]");
}
}

View File

@@ -1,38 +1,38 @@
{
"actor": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/repositories/bitbucket/bitbucket"
},
"html": {
"href": "https://api.bitbucket.org/bitbucket/bitbucket"
},
"avatar": {
"href": "https://api-staging-assetroot.s3.amazonaws.com/c/photos/2014/Aug/01/bitbucket-logo-2629490769-3_avatar.png"
}
},
"uuid": "{673a6070-3421-46c9-9d48-90745f7bfe8e}",
"full_name": "team_name/repo_name",
"name": "repo_name",
"scm": "git",
"is_private": true
},
"push": {
}
}
"actor": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/repositories/bitbucket/bitbucket"
},
"html": {
"href": "https://api.bitbucket.org/bitbucket/bitbucket"
},
"avatar": {
"href": "https://api-staging-assetroot.s3.amazonaws.com/c/photos/2014/Aug/01/bitbucket-logo-2629490769-3_avatar.png"
}
},
"uuid": "{673a6070-3421-46c9-9d48-90745f7bfe8e}",
"full_name": "team_name/repo_name",
"name": "repo_name",
"scm": "git",
"is_private": true
},
"push": {
}
}

View File

@@ -1,206 +1,206 @@
{
"actor": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/repositories/bitbucket/bitbucket"
},
"html": {
"href": "https://api.bitbucket.org/bitbucket/bitbucket"
},
"avatar": {
"href": "https://api-staging-assetroot.s3.amazonaws.com/c/photos/2014/Aug/01/bitbucket-logo-2629490769-3_avatar.png"
}
},
"uuid": "{673a6070-3421-46c9-9d48-90745f7bfe8e}",
"full_name": "team_name/repo_name",
"name": "repo_name",
"scm": "git",
"is_private": true
},
"push": {
"changes": [
{
"new": {
"type": "branch",
"name": "name-of-branch",
"target": {
"type": "commit",
"hash": "709d658dc5b6d6afcd46049c2f332ee3f515a67d",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"message": "new commit message\n",
"date": "2015-06-09T03:34:49+00:00",
"parents": [
{
"type": "commit",
"hash": "1e65c05c1d5171631d92438a13901ca7dae9618c",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/8cbbd65829c7ad834a97841e0defc965718036a0"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/8cbbd65829c7ad834a97841e0defc965718036a0"
}
}
}
],
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/c4b2b7914156a878aa7c9da452a09fb50c2091f2"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/c4b2b7914156a878aa7c9da452a09fb50c2091f2"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/refs/branches/master"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits/master"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branch/master"
}
}
},
"old": {
"type": "branch",
"name": "name-of-branch",
"target": {
"type": "commit",
"hash": "1e65c05c1d5171631d92438a13901ca7dae9618c",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"message": "old commit message\n",
"date": "2015-06-08T21:34:56+00:00",
"parents": [
{
"type": "commit",
"hash": "e0d0c2041e09746be5ce4b55067d5a8e3098c843",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/9c4a3452da3bc4f37af5a6bb9c784246f44406f7"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/9c4a3452da3bc4f37af5a6bb9c784246f44406f7"
}
}
}
],
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/b99ea6dad8f416e57c5ca78c1ccef590600d841b"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/refs/branches/master"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits/master"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branch/master"
}
}
},
"links": {
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branches/compare/c4b2b7914156a878aa7c9da452a09fb50c2091f2..b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"diff": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/diff/c4b2b7914156a878aa7c9da452a09fb50c2091f2..b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits?include=c4b2b7914156a878aa7c9da452a09fb50c2091f2&exclude=b99ea6dad8f416e57c5ca78c1ccef590600d841b"
}
},
"created": false,
"forced": false,
"closed": false,
"commits": [
{
"hash": "03f4a7270240708834de475bcf21532d6134777e",
"type": "commit",
"message": "commit message\n",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user/repo/commit/03f4a7270240708834de475bcf21532d6134777e"
},
"html": {
"href": "https://bitbucket.org/user/repo/commits/03f4a7270240708834de475bcf21532d6134777e"
}
}
}
],
"truncated": false
}
]
}
}
"actor": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/repositories/bitbucket/bitbucket"
},
"html": {
"href": "https://api.bitbucket.org/bitbucket/bitbucket"
},
"avatar": {
"href": "https://api-staging-assetroot.s3.amazonaws.com/c/photos/2014/Aug/01/bitbucket-logo-2629490769-3_avatar.png"
}
},
"uuid": "{673a6070-3421-46c9-9d48-90745f7bfe8e}",
"full_name": "team_name/repo_name",
"name": "repo_name",
"scm": "git",
"is_private": true
},
"push": {
"changes": [
{
"new": {
"type": "branch",
"name": "name-of-branch",
"target": {
"type": "commit",
"hash": "709d658dc5b6d6afcd46049c2f332ee3f515a67d",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"message": "new commit message\n",
"date": "2015-06-09T03:34:49+00:00",
"parents": [
{
"type": "commit",
"hash": "1e65c05c1d5171631d92438a13901ca7dae9618c",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/8cbbd65829c7ad834a97841e0defc965718036a0"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/8cbbd65829c7ad834a97841e0defc965718036a0"
}
}
}
],
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/c4b2b7914156a878aa7c9da452a09fb50c2091f2"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/c4b2b7914156a878aa7c9da452a09fb50c2091f2"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/refs/branches/master"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits/master"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branch/master"
}
}
},
"old": {
"type": "branch",
"name": "name-of-branch",
"target": {
"type": "commit",
"hash": "1e65c05c1d5171631d92438a13901ca7dae9618c",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"message": "old commit message\n",
"date": "2015-06-08T21:34:56+00:00",
"parents": [
{
"type": "commit",
"hash": "e0d0c2041e09746be5ce4b55067d5a8e3098c843",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/9c4a3452da3bc4f37af5a6bb9c784246f44406f7"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/9c4a3452da3bc4f37af5a6bb9c784246f44406f7"
}
}
}
],
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commit/b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/commits/b99ea6dad8f416e57c5ca78c1ccef590600d841b"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/refs/branches/master"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits/master"
},
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branch/master"
}
}
},
"links": {
"html": {
"href": "https://bitbucket.org/user_name/repo_name/branches/compare/c4b2b7914156a878aa7c9da452a09fb50c2091f2..b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"diff": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/diff/c4b2b7914156a878aa7c9da452a09fb50c2091f2..b99ea6dad8f416e57c5ca78c1ccef590600d841b"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/user_name/repo_name/commits?include=c4b2b7914156a878aa7c9da452a09fb50c2091f2&exclude=b99ea6dad8f416e57c5ca78c1ccef590600d841b"
}
},
"created": false,
"forced": false,
"closed": false,
"commits": [
{
"hash": "03f4a7270240708834de475bcf21532d6134777e",
"type": "commit",
"message": "commit message\n",
"author": {
"username": "emmap1",
"display_name": "Emma",
"uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
"links": {
"self": {
"href": "https://api.bitbucket.org/api/2.0/users/emmap1"
},
"html": {
"href": "https://api.bitbucket.org/emmap1"
},
"avatar": {
"href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
}
}
},
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/user/repo/commit/03f4a7270240708834de475bcf21532d6134777e"
},
"html": {
"href": "https://bitbucket.org/user/repo/commits/03f4a7270240708834de475bcf21532d6134777e"
}
}
}
],
"truncated": false
}
]
}
}

View File

@@ -1,30 +1,30 @@
{
"eventKey":"repo:refs_changed",
"date":"2017-09-19T09:45:32+1000",
"actor":{
"name":"admin",
"emailAddress":"admin@example.com",
"id":1,
"displayName":"Administrator",
"active":true,
"slug":"admin",
"type":"NORMAL"
},
"repository":{
"slug":"repository",
"id":84,
"name":"repository",
"scmId":"git",
"state":"AVAILABLE",
"statusMessage":"Available",
"forkable":true,
"project":{
"key":"PROJ",
"id":84,
"name":"project",
"public":false,
"type":"NORMAL"
},
"public":false
}
}
{
"eventKey": "repo:refs_changed",
"date": "2017-09-19T09:45:32+1000",
"actor": {
"name": "admin",
"emailAddress": "admin@example.com",
"id": 1,
"displayName": "Administrator",
"active": true,
"slug": "admin",
"type": "NORMAL"
},
"repository": {
"slug": "repository",
"id": 84,
"name": "repository",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "PROJ",
"id": 84,
"name": "project",
"public": false,
"type": "NORMAL"
},
"public": false
}
}

View File

@@ -1,43 +1,43 @@
{
"eventKey":"repo:refs_changed",
"date":"2017-09-19T09:45:32+1000",
"actor":{
"name":"admin",
"emailAddress":"admin@example.com",
"id":1,
"displayName":"Administrator",
"active":true,
"slug":"admin",
"type":"NORMAL"
},
"repository":{
"slug":"repository",
"id":84,
"name":"repository",
"scmId":"git",
"state":"AVAILABLE",
"statusMessage":"Available",
"forkable":true,
"project":{
"key":"PROJ",
"id":84,
"name":"project",
"public":false,
"type":"NORMAL"
},
"public":false
},
"changes":[
{
"ref":{
"id":"refs/heads/master",
"displayId":"master",
"type":"BRANCH"
},
"refId":"refs/heads/master",
"fromHash":"ecddabb624f6f5ba43816f5926e580a5f680a932",
"toHash":"178864a7d521b6f5e720b386b2c2b0ef8563e0dc",
"type":"UPDATE"
}
]
}
{
"eventKey": "repo:refs_changed",
"date": "2017-09-19T09:45:32+1000",
"actor": {
"name": "admin",
"emailAddress": "admin@example.com",
"id": 1,
"displayName": "Administrator",
"active": true,
"slug": "admin",
"type": "NORMAL"
},
"repository": {
"slug": "repository",
"id": 84,
"name": "repository",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "PROJ",
"id": 84,
"name": "project",
"public": false,
"type": "NORMAL"
},
"public": false
},
"changes": [
{
"ref": {
"id": "refs/heads/master",
"displayId": "master",
"type": "BRANCH"
},
"refId": "refs/heads/master",
"fromHash": "ecddabb624f6f5ba43816f5926e580a5f680a932",
"toHash": "178864a7d521b6f5e720b386b2c2b0ef8563e0dc",
"type": "UPDATE"
}
]
}

View File

@@ -1,81 +1,81 @@
{
"secret": "gitea_push",
"ref": "refs/heads/master",
"before": "70767b558d8f850eac3fead13dfc232d043646a0",
"after": "78b77379c448caf024c73fa280ca571449224590",
"compare_url": "http://gitea.lawyers.corp/internal/lawsuits/compare/70767b558d8f850eac3fead13dfc232d043646a0...78b77379c448caf024c73fa280ca571449224590",
"commits": [
{
"id": "78b77379c448caf024c73fa280ca571449224590",
"message": "SUPPORT-4765: urlencode\n",
"url": "http://gitea.lawyers.corp/internal/lawsuits/commit/78b77379c448caf024c73fa280ca571449224590",
"author": {
"name": "Perry Mason",
"email": "perrym@lawyers.corp",
"username": "git"
},
"committer": {
"name": "Perry Mason",
"email": "perrym@lawyers.corp",
"username": "git"
},
"verification": null,
"timestamp": "2018-08-27T11:18:34Z"
}
],
"repository": {
"id": 480,
"owner": {
"id": 3,
"login": "internal",
"full_name": "",
"email": "",
"avatar_url": "http://gitea.lawyers.corp/avatars/dbc87f99ecd29cb0eb4447807ad73f9f",
"language": "",
"username": "internal"
},
"name": "lawsuits",
"full_name": "internal/lawsuits",
"description": "",
"empty": false,
"private": false,
"fork": false,
"parent": null,
"mirror": false,
"size": 5516,
"html_url": "http://gitea.lawyers.corp/internal/lawsuits",
"ssh_url": "git@localhost:internal/lawsuits.git",
"clone_url": "http://gitea.lawyers.corp/internal/lawsuits.git",
"website": "",
"stars_count": 1,
"forks_count": 20,
"watchers_count": 6,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2018-01-18T15:11:51Z",
"updated_at": "2018-08-27T11:18:34Z",
"permissions": {
"admin": false,
"push": false,
"pull": false
}
},
"pusher": {
"id": 2,
"login": "perrym",
"full_name": "Perry Mason",
"email": "perrym@lawyers.corp",
"avatar_url": "http://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967",
"language": "en-US",
"username": "perrym"
},
"sender": {
"id": 2,
"login": "perrym",
"full_name": "Perry Mason",
"email": "perrym@lawyers.corp",
"avatar_url": "http://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967",
"language": "en-US",
"username": "perrym"
}
}
"secret": "gitea_push",
"ref": "refs/heads/master",
"before": "70767b558d8f850eac3fead13dfc232d043646a0",
"after": "78b77379c448caf024c73fa280ca571449224590",
"compare_url": "http://gitea.lawyers.corp/internal/lawsuits/compare/70767b558d8f850eac3fead13dfc232d043646a0...78b77379c448caf024c73fa280ca571449224590",
"commits": [
{
"id": "78b77379c448caf024c73fa280ca571449224590",
"message": "SUPPORT-4765: urlencode\n",
"url": "http://gitea.lawyers.corp/internal/lawsuits/commit/78b77379c448caf024c73fa280ca571449224590",
"author": {
"name": "Perry Mason",
"email": "perrym@lawyers.corp",
"username": "git"
},
"committer": {
"name": "Perry Mason",
"email": "perrym@lawyers.corp",
"username": "git"
},
"verification": null,
"timestamp": "2018-08-27T11:18:34Z"
}
],
"repository": {
"id": 480,
"owner": {
"id": 3,
"login": "internal",
"full_name": "",
"email": "",
"avatar_url": "http://gitea.lawyers.corp/avatars/dbc87f99ecd29cb0eb4447807ad73f9f",
"language": "",
"username": "internal"
},
"name": "lawsuits",
"full_name": "internal/lawsuits",
"description": "",
"empty": false,
"private": false,
"fork": false,
"parent": null,
"mirror": false,
"size": 5516,
"html_url": "http://gitea.lawyers.corp/internal/lawsuits",
"ssh_url": "git@localhost:internal/lawsuits.git",
"clone_url": "http://gitea.lawyers.corp/internal/lawsuits.git",
"website": "",
"stars_count": 1,
"forks_count": 20,
"watchers_count": 6,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2018-01-18T15:11:51Z",
"updated_at": "2018-08-27T11:18:34Z",
"permissions": {
"admin": false,
"push": false,
"pull": false
}
},
"pusher": {
"id": 2,
"login": "perrym",
"full_name": "Perry Mason",
"email": "perrym@lawyers.corp",
"avatar_url": "http://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967",
"language": "en-US",
"username": "perrym"
},
"sender": {
"id": 2,
"login": "perrym",
"full_name": "Perry Mason",
"email": "perrym@lawyers.corp",
"avatar_url": "http://gitea.lawyers.corp/avatars/5868737ae078a4441031bf550d16e967",
"language": "en-US",
"username": "perrym"
}
}

View File

@@ -1,54 +1,56 @@
{
"before": "fb32ef5812dc132ece716a05c50c7531c6dc1b4d",
"after": "ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"ref": "refs/heads/master",
"user_id": 13,
"user_name": "123",
"user": {
"name": "123",
"username": "test123",
"url": "https://gitee.com/oschina"
},
"repository": {
"name": "webhook",
"url": "http://git.oschina.net/oschina/webhook",
"description": "",
"homepage": "https://gitee.com/oschina/webhook"
},
"commits": [{
"id": "ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"message": "1234 bug fix",
"timestamp": "2016-12-09T17:28:02 08:00",
"url": "https://gitee.com/oschina/webhook/commit/ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"author": {
"name": "123",
"email": "123@123.com",
"time": "2016-12-09T17:28:02 08:00"
},
"added": [
"d.txt"
],
"modified": [
"c.txt"
],
"removed": [
"b.txt"
]
}],
"total_commits_count": 1,
"commits_more_than_ten": false,
"project": {
"name": "webhook",
"path": "webhook",
"url": "https://gitee.com/oschina/webhook",
"git_ssh_url": "git@gitee.com:oschina/webhook.git",
"git_http_url": "https://gitee.com/oschina/webhook.git",
"git_svn_url": "svn://gitee.com/oschina/webhook",
"namespace": "oschina",
"name_with_namespace": "oschina/webhook",
"path_with_namespace": "oschina/webhook",
"default_branch": "master"
},
"hook_name": "push_hooks",
"password": "pwd"
"before": "fb32ef5812dc132ece716a05c50c7531c6dc1b4d",
"after": "ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"ref": "refs/heads/master",
"user_id": 13,
"user_name": "123",
"user": {
"name": "123",
"username": "test123",
"url": "https://gitee.com/oschina"
},
"repository": {
"name": "webhook",
"url": "http://git.oschina.net/oschina/webhook",
"description": "",
"homepage": "https://gitee.com/oschina/webhook"
},
"commits": [
{
"id": "ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"message": "1234 bug fix",
"timestamp": "2016-12-09T17:28:02 08:00",
"url": "https://gitee.com/oschina/webhook/commit/ac63b9ba95191a1bf79d60bc262851a66c12cda1",
"author": {
"name": "123",
"email": "123@123.com",
"time": "2016-12-09T17:28:02 08:00"
},
"added": [
"d.txt"
],
"modified": [
"c.txt"
],
"removed": [
"b.txt"
]
}
],
"total_commits_count": 1,
"commits_more_than_ten": false,
"project": {
"name": "webhook",
"path": "webhook",
"url": "https://gitee.com/oschina/webhook",
"git_ssh_url": "git@gitee.com:oschina/webhook.git",
"git_http_url": "https://gitee.com/oschina/webhook.git",
"git_svn_url": "svn://gitee.com/oschina/webhook",
"namespace": "oschina",
"name_with_namespace": "oschina/webhook",
"path_with_namespace": "oschina/webhook",
"default_branch": "master"
},
"hook_name": "push_hooks",
"password": "pwd"
}

View File

@@ -1,161 +1,157 @@
{
"ref": "refs/heads/changes",
"before": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f",
"commits": [
{
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
}
],
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"description": "",
"fork": false,
"url": "https://github.com/baxterthehacker/public-repo",
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
"created_at": 1430869212,
"updated_at": "2015-05-05T23:40:12Z",
"pushed_at": 1430869217,
"git_url": "git://github.com/baxterthehacker/public-repo.git",
"ssh_url": "git@github.com:baxterthehacker/public-repo.git",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"svn_url": "https://github.com/baxterthehacker/public-repo",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"id": 6752317,
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterthehacker",
"html_url": "https://github.com/baxterthehacker",
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
"type": "User",
"site_admin": false
}
}
"ref": "refs/heads/changes",
"before": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f",
"commits": [
{
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
}
],
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"description": "",
"fork": false,
"url": "https://github.com/baxterthehacker/public-repo",
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
"created_at": 1430869212,
"updated_at": "2015-05-05T23:40:12Z",
"pushed_at": 1430869217,
"git_url": "git://github.com/baxterthehacker/public-repo.git",
"ssh_url": "git@github.com:baxterthehacker/public-repo.git",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"svn_url": "https://github.com/baxterthehacker/public-repo",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"id": 6752317,
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterthehacker",
"html_url": "https://github.com/baxterthehacker",
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
"type": "User",
"site_admin": false
}
}

View File

@@ -1,65 +1,71 @@
{
"object_kind": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
"user_id": 4,
"user_name": "John Smith",
"user_email": "john@example.com",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 15,
"project":{
"name":"Diaspora",
"description":"",
"web_url":"http://example.com/mike/diaspora",
"avatar_url":null,
"git_ssh_url":"git@example.com:mike/diaspora.git",
"git_http_url":"http://example.com/mike/diaspora.git",
"namespace":"Mike",
"visibility_level":0,
"path_with_namespace":"mike/diaspora",
"default_branch":"master",
"homepage":"http://example.com/mike/diaspora",
"url":"git@example.com:mike/diasporadiaspora.git",
"ssh_url":"git@example.com:mike/diaspora.git",
"http_url":"http://example.com/mike/diaspora.git"
},
"repository":{
"name": "Diaspora",
"url": "git@example.com:mike/diasporadiaspora.git",
"description": "",
"homepage": "http://example.com/mike/diaspora",
"git_http_url":"http://example.com/mike/diaspora.git",
"git_ssh_url":"git@example.com:mike/diaspora.git",
"visibility_level":0
},
"commits": [
{
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"message": "Update Catalan translation to e38cb41.",
"timestamp": "2011-12-12T14:27:31+02:00",
"url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": {
"name": "Jordi Mallach",
"email": "jordi@softcatala.org"
},
"added": ["newapp.properties"],
"modified": ["application.yml"],
"removed": []
},
{
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
},
"added": [],
"modified": ["oldapp.yml"],
"removed": []
}
],
"total_commits_count": 4
}
"object_kind": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
"user_id": 4,
"user_name": "John Smith",
"user_email": "john@example.com",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 15,
"project": {
"name": "Diaspora",
"description": "",
"web_url": "http://example.com/mike/diaspora",
"avatar_url": null,
"git_ssh_url": "git@example.com:mike/diaspora.git",
"git_http_url": "http://example.com/mike/diaspora.git",
"namespace": "Mike",
"visibility_level": 0,
"path_with_namespace": "mike/diaspora",
"default_branch": "master",
"homepage": "http://example.com/mike/diaspora",
"url": "git@example.com:mike/diasporadiaspora.git",
"ssh_url": "git@example.com:mike/diaspora.git",
"http_url": "http://example.com/mike/diaspora.git"
},
"repository": {
"name": "Diaspora",
"url": "git@example.com:mike/diasporadiaspora.git",
"description": "",
"homepage": "http://example.com/mike/diaspora",
"git_http_url": "http://example.com/mike/diaspora.git",
"git_ssh_url": "git@example.com:mike/diaspora.git",
"visibility_level": 0
},
"commits": [
{
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"message": "Update Catalan translation to e38cb41.",
"timestamp": "2011-12-12T14:27:31+02:00",
"url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": {
"name": "Jordi Mallach",
"email": "jordi@softcatala.org"
},
"added": [
"newapp.properties"
],
"modified": [
"application.yml"
],
"removed": []
},
{
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev@dv6700.(none)"
},
"added": [],
"modified": [
"oldapp.yml"
],
"removed": []
}
],
"total_commits_count": 4
}

View File

@@ -1,161 +1,157 @@
{
"ref": "refs/heads/changes",
"before": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f",
"commits": [
{
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
}
],
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"description": "",
"fork": false,
"url": "https://github.com/baxterthehacker/public-repo",
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
"created_at": 1430869212,
"updated_at": "2015-05-05T23:40:12Z",
"pushed_at": 1430869217,
"git_url": "git://github.com/baxterthehacker/public-repo.git",
"ssh_url": "git@github.com:baxterthehacker/public-repo.git",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"svn_url": "https://github.com/baxterthehacker/public-repo",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"id": 6752317,
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterthehacker",
"html_url": "https://github.com/baxterthehacker",
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
"type": "User",
"site_admin": false
}
}
"ref": "refs/heads/changes",
"before": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
"after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"created": false,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f",
"commits": [
{
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
}
],
"head_commit": {
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"distinct": true,
"message": "Update README.md",
"timestamp": "2015-05-05T19:40:15-04:00",
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
"author": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"committer": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com",
"username": "baxterthehacker"
},
"added": [
],
"removed": [
],
"modified": [
"README.md"
]
},
"repository": {
"id": 35129377,
"name": "public-repo",
"full_name": "baxterthehacker/public-repo",
"owner": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"private": false,
"html_url": "https://github.com/baxterthehacker/public-repo",
"description": "",
"fork": false,
"url": "https://github.com/baxterthehacker/public-repo",
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
"created_at": 1430869212,
"updated_at": "2015-05-05T23:40:12Z",
"pushed_at": 1430869217,
"git_url": "git://github.com/baxterthehacker/public-repo.git",
"ssh_url": "git@github.com:baxterthehacker/public-repo.git",
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
"svn_url": "https://github.com/baxterthehacker/public-repo",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
},
"pusher": {
"name": "baxterthehacker",
"email": "baxterthehacker@users.noreply.github.com"
},
"sender": {
"login": "baxterthehacker",
"id": 6752317,
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterthehacker",
"html_url": "https://github.com/baxterthehacker",
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
"type": "User",
"site_admin": false
}
}

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-config-sample</artifactId>
<packaging>jar</packaging>
<packaging>jar</packaging>
<name>spring-cloud-config-sample</name>
<description>spring-cloud-config-server</description>
@@ -49,14 +50,14 @@
<build>
<plugins>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
@@ -16,13 +31,13 @@ public class Application {
@Autowired
private Environment environment;
@RequestMapping("/")
public String query(@RequestParam("q") String q) {
return environment.getProperty(q);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@RequestMapping("/")
public String query(@RequestParam("q") String q) {
return this.environment.getProperty(q);
}
}

View File

@@ -6,4 +6,4 @@ endpoints:
logging:
levels:
org.springframework.boot.env.PropertySourcesLoader: TRACE
org.springframework.web: DEBUG
org.springframework.web: DEBUG

View File

@@ -3,4 +3,4 @@ spring:
name: bar
cloud:
config:
uri: http://localhost:${config.port:8888}
uri: http://localhost:${config.port:8888}

View File

@@ -9,4 +9,4 @@ spring:
uri: ${repo1}
bootstrap: true
profiles:
active: composite
active: composite

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import java.io.IOException;
@@ -22,28 +38,33 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
* Test for gh-975.
* org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
* 'vaultEnvironmentRepositoryFactory' defined in
* org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration: Unsatisfied dependency
* No qualifying bean of type 'javax.servlet.http.HttpServletRequest' available:
* Test for gh-975. org.springframework.beans.factory.UnsatisfiedDependencyException:
* Error creating bean with name 'vaultEnvironmentRepositoryFactory' defined in
* org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration:
* Unsatisfied dependency No qualifying bean of type
* 'javax.servlet.http.HttpServletRequest' available.
*
* @author Spencer Gibb
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the config
// server on the classpath we need to set it explicitly
properties = { "spring.cloud.config.enabled:true", "",
"management.security.enabled=false", "management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config
// server on the classpath we need to set it explicitly
properties = { "spring.cloud.config.enabled:true", "",
"management.security.enabled=false",
"management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
public class ApplicationBootstrapTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
private static int configPort = SocketUtils.findAvailableTcpPort();
private static ConfigurableApplicationContext server;
@LocalServerPort
private int port;
private static ConfigurableApplicationContext server;
@BeforeClass
public static void startConfigServer() throws IOException {
System.setProperty("spring.cloud.bootstrap.name", "bootstrapservercomposite");
@@ -69,20 +90,20 @@ public class ApplicationBootstrapTests {
}
}
@Test
@SuppressWarnings("unchecked")
public void contextLoads() {
Map res = new TestRestTemplate()
.getForObject("http://localhost:" + port + BASE_PATH + "/env/info.foo", Map.class);
assertThat(res).containsKey("propertySources");
Map<String, Object> property = (Map<String,Object>) res.get("property");
assertThat(property).containsEntry("value", "bar");
}
public static void main(String[] args) throws IOException {
configPort = 8888;
startConfigServer();
SpringApplication.run(Application.class, args);
}
@Test
@SuppressWarnings("unchecked")
public void contextLoads() {
Map res = new TestRestTemplate().getForObject(
"http://localhost:" + this.port + BASE_PATH + "/env/info.foo", Map.class);
assertThat(res).containsKey("propertySources");
Map<String, Object> property = (Map<String, Object>) res.get("property");
assertThat(property).containsEntry("value", "bar");
}
}

View File

@@ -1,25 +1,43 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
public class ApplicationFailFastTests {
@Test
public void contextFails() {
try {
new SpringApplicationBuilder()
.sources(Application.class)
.run("--server.port=0", "--spring.cloud.config.enabled=true",
"--spring.cloud.config.fail-fast=true",
"--spring.cloud.config.uri=http://server-host-doesnt-exist:1234");
fail("failFast option did not produce an exception");
} catch (Exception e) {
assertTrue("Exception not caused by fail fast", e.getMessage().contains("fail fast"));
}
}
try {
new SpringApplicationBuilder().sources(Application.class).run(
"--server.port=0", "--spring.cloud.config.enabled=true",
"--spring.cloud.config.fail-fast=true",
"--spring.cloud.config.uri=http://server-host-doesnt-exist:1234");
fail("failFast option did not produce an exception");
}
catch (Exception e) {
assertThat(e.getMessage().contains("fail fast"))
.as("Exception not caused by fail fast").isTrue();
}
}
}

View File

@@ -1,9 +1,29 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import java.io.IOException;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.test.context.SpringBootTest;
@@ -14,28 +34,28 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.SocketUtils;
import java.io.IOException;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
// Normally spring.cloud.config.enabled:true is the default but since we have the config
// server on the classpath we need to set it explicitly
properties = { "spring.cloud.config.enabled:true",
"management.security.enabled=false", "management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
// Normally spring.cloud.config.enabled:true is the default but since we have the
// config
// server on the classpath we need to set it explicitly
properties = { "spring.cloud.config.enabled:true",
"management.security.enabled=false",
"management.endpoints.web.exposure.include=*" }, webEnvironment = RANDOM_PORT)
public class ApplicationTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
private static int configPort = SocketUtils.findAvailableTcpPort();
private static ConfigurableApplicationContext server;
@LocalServerPort
private int port;
private static ConfigurableApplicationContext server;
@BeforeClass
public static void startConfigServer() throws IOException {
String baseDir = ConfigServerTestUtils
@@ -46,8 +66,10 @@ public class ApplicationTests {
org.springframework.cloud.config.server.ConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo);
/*FIXME configPort = ((EmbeddedWebApplicationContext) server)
.getEmbeddedServletContainer().getPort();*/
/*
* FIXME configPort = ((EmbeddedWebApplicationContext) server)
* .getEmbeddedServletContainer().getPort();
*/
System.setProperty("config.port", "" + configPort);
}
@@ -59,20 +81,20 @@ public class ApplicationTests {
}
}
@Test
@SuppressWarnings("unchecked")
public void contextLoads() {
Map res = new TestRestTemplate()
.getForObject("http://localhost:" + port + BASE_PATH + "/env/info.foo", Map.class);
assertThat(res).containsKey("propertySources");
Map<String, Object> property = (Map<String,Object>) res.get("property");
assertThat(property).containsEntry("value", "bar");
}
public static void main(String[] args) throws IOException {
configPort = 8888;
startConfigServer();
SpringApplication.run(Application.class, args);
}
@Test
@SuppressWarnings("unchecked")
public void contextLoads() {
Map res = new TestRestTemplate().getForObject(
"http://localhost:" + this.port + BASE_PATH + "/env/info.foo", Map.class);
assertThat(res).containsKey("propertySources");
Map<String, Object> property = (Map<String, Object>) res.get("property");
assertThat(property).containsEntry("value", "bar");
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample;
import java.io.IOException;
@@ -6,6 +22,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.SpringBootTest;
@@ -15,54 +32,56 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertFalse;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,
properties = "spring.application.name:bad", webEnvironment = RANDOM_PORT)
@SpringBootTest(classes = Application.class, properties = "spring.application.name:bad", webEnvironment = RANDOM_PORT)
public class ServerNativeApplicationTests {
private static int configPort = 0;
private static ConfigurableApplicationContext server;
@Autowired
private ConfigurableEnvironment environment;
@LocalServerPort
private int port;
private static ConfigurableApplicationContext server;
@BeforeClass
public static void startConfigServer() throws IOException {
String repo = ConfigServerTestUtils.prepareLocalRepo();
server = SpringApplication.run(
org.springframework.cloud.config.server.ConfigServerApplication.class,
"--server.port=" + configPort, "--spring.config.name=server",
"--spring.cloud.config.server.git.uri=" + repo, "--spring.profiles.active=native");
/*FIXME configPort = ((EmbeddedWebApplicationContext) server)
.getEmbeddedServletContainer().getPort();*/
"--spring.cloud.config.server.git.uri=" + repo,
"--spring.profiles.active=native");
/*
* FIXME configPort = ((EmbeddedWebApplicationContext) server)
* .getEmbeddedServletContainer().getPort();
*/
System.setProperty("config.port", "" + configPort);
}
@AfterClass
public static void close() {
System.clearProperty("config.port");
if (server!=null) {
if (server != null) {
server.close();
}
}
@Test
public void contextLoads() {
// The remote config was bad so there is no bootstrap
assertFalse(this.environment.getPropertySources().contains("bootstrap"));
}
public static void main(String[] args) throws IOException {
configPort = 8888;
startConfigServer();
SpringApplication.run(Application.class, args);
}
@Test
public void contextLoads() {
// The remote config was bad so there is no bootstrap
assertThat(this.environment.getPropertySources().contains("bootstrap")).isFalse();
}
}

View File

@@ -1,4 +1,4 @@
foo:
# whitespace error!
bar: spam
bucket: wham
# whitespace error!
bar: spam
bucket: wham

View File

@@ -1,3 +1,3 @@
info:
info:
foo: bar
raw: true

View File

@@ -1 +1,2 @@
0000000000000000000000000000000000000000 7df4a26d5437d9d4090cd5809967f870444cde8f Dave Syer <dsyer@gopivotal.com> 1406860717 -0700
7df4a26d5437d9d4090cd5809967f870444cde8f b51bc19694589d21c06bab8a4f14660b3303d7b0 Marcin Grzejszczak <marcin@grzejszczak.pl> 1549359437 +0100 commit: Updated

View File

@@ -1 +1,2 @@
0000000000000000000000000000000000000000 7df4a26d5437d9d4090cd5809967f870444cde8f Dave Syer <dsyer@gopivotal.com> 1406860717 -0700
7df4a26d5437d9d4090cd5809967f870444cde8f b51bc19694589d21c06bab8a4f14660b3303d7b0 Marcin Grzejszczak <marcin@grzejszczak.pl> 1549359437 +0100 commit: Updated

View File

@@ -1 +1 @@
7df4a26d5437d9d4090cd5809967f870444cde8f
b51bc19694589d21c06bab8a4f14660b3303d7b0

View File

@@ -13,4 +13,4 @@ spring:
server:
port: 8888
management:
contextPath: /admin
contextPath: /admin

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-config-server</artifactId>
@@ -103,7 +104,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>org.springframework.cloud.config.server.ConfigServerApplication</start-class>
<start-class>org.springframework.cloud.config.server.ConfigServerApplication
</start-class>
</properties>
</project>

View File

@@ -1,9 +1,30 @@
/*
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Configuration;
/**
* Configuration server application.
*
* @author Dave Syer
*/
@Configuration
@EnableAutoConfiguration
@EnableConfigServer

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server;
import org.springframework.cloud.config.server.config.ConfigServerConfiguration;
import org.springframework.context.annotation.Import;
package org.springframework.cloud.config.server;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -24,6 +22,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.cloud.config.server.config.ConfigServerConfiguration;
import org.springframework.context.annotation.Import;
/**
* @author Dave Syer
* @author

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,32 +45,36 @@ import org.springframework.core.env.PropertySource;
* @author Dave Syer
*
*/
public class ConfigServerBootstrapApplicationListener implements
ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
public class ConfigServerBootstrapApplicationListener
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
/**
* Default order of the bootstrap application listener.
*/
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 4;
private int order = DEFAULT_ORDER;
private PropertySource<?> propertySource = new MapPropertySource(
"configServerClient", Collections.<String, Object> singletonMap(
"spring.cloud.config.enabled", "false"));
public void setOrder(int order) {
this.order = order;
}
private PropertySource<?> propertySource = new MapPropertySource("configServerClient",
Collections.<String, Object>singletonMap("spring.cloud.config.enabled",
"false"));
@Override
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
ConfigurableEnvironment environment = event.getEnvironment();
if (!environment.resolvePlaceholders("${spring.cloud.config.enabled:false}")
.equalsIgnoreCase("true")) {
if (!environment.getPropertySources().contains(this.propertySource.getName())) {
if (!environment.getPropertySources()
.contains(this.propertySource.getName())) {
environment.getPropertySources().addLast(this.propertySource);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.bootstrap;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,11 +30,10 @@ import org.springframework.context.annotation.Import;
import org.springframework.util.StringUtils;
/**
* Bootstrap configuration to fetch external configuration from a (possibly
* remote) {@link EnvironmentRepository}. Off by default because it can delay
* startup, but can be enabled with
* <code>spring.cloud.config.server.bootstrap=true</code>. This would be useful,
* for example, if the config server were embedded in another app that wanted to
* Bootstrap configuration to fetch external configuration from a (possibly remote)
* {@link EnvironmentRepository}. Off by default because it can delay startup, but can be
* enabled with <code>spring.cloud.config.server.bootstrap=true</code>. This would be
* useful, for example, if the config server were embedded in another app that wanted to
* be configured from the same repository as all the other clients.
*
* @author Dave Syer
@@ -58,14 +58,15 @@ public class ConfigServerBootstrapConfiguration {
@Bean
public EnvironmentRepositoryPropertySourceLocator environmentRepositoryPropertySourceLocator() {
return new EnvironmentRepositoryPropertySourceLocator(this.repository, this.client.getName(),
this.client.getProfile(), getDefaultLabel());
return new EnvironmentRepositoryPropertySourceLocator(this.repository,
this.client.getName(), this.client.getProfile(), getDefaultLabel());
}
private String getDefaultLabel() {
if (StringUtils.hasText(this.client.getLabel())) {
return this.client.getLabel();
} else if (StringUtils.hasText(this.server.getDefaultLabel())) {
}
else if (StringUtils.hasText(this.server.getDefaultLabel())) {
return this.server.getDefaultLabel();
}
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.composite;
import java.lang.reflect.Type;
@@ -31,12 +32,14 @@ import org.springframework.cloud.config.server.support.EnvironmentRepositoryProp
import org.springframework.core.env.Environment;
/**
* A {@link BeanFactoryPostProcessor} to register {@link EnvironmentRepository} {@link BeanDefinition}s based on the
* composite list configuration.
* A {@link BeanFactoryPostProcessor} to register {@link EnvironmentRepository}
* {@link BeanDefinition}s based on the composite list configuration.
*
* @author Dylan Roberts
*/
public class CompositeEnvironmentBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
public class CompositeEnvironmentBeanFactoryPostProcessor
implements BeanFactoryPostProcessor {
private Environment environment;
public CompositeEnvironmentBeanFactoryPostProcessor(Environment environment) {
@@ -44,35 +47,40 @@ public class CompositeEnvironmentBeanFactoryPostProcessor implements BeanFactory
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
List<String> typePropertyList = CompositeUtils.getCompositeTypeList(environment);
for(int i = 0; i < typePropertyList.size(); i++) {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
List<String> typePropertyList = CompositeUtils
.getCompositeTypeList(this.environment);
for (int i = 0; i < typePropertyList.size(); i++) {
String type = typePropertyList.get(i);
String factoryName = CompositeUtils.getFactoryName(type, beanFactory);
Type[] factoryTypes = CompositeUtils.getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName);
Class<? extends EnvironmentRepositoryProperties> propertiesClass =
(Class<? extends EnvironmentRepositoryProperties>) factoryTypes[1];
EnvironmentRepositoryProperties properties = bindProperties(i, propertiesClass, environment);
Type[] factoryTypes = CompositeUtils
.getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName);
Class<? extends EnvironmentRepositoryProperties> propertiesClass;
propertiesClass = (Class<? extends EnvironmentRepositoryProperties>) factoryTypes[1];
EnvironmentRepositoryProperties properties = bindProperties(i,
propertiesClass, this.environment);
AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder
.genericBeanDefinition(EnvironmentRepository.class)
.setFactoryMethodOnBean("build", factoryName)
.addConstructorArgValue(properties)
.getBeanDefinition();
.addConstructorArgValue(properties).getBeanDefinition();
String beanName = String.format("%s-env-repo%d", type, i);
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition(beanName, beanDefinition);
}
}
private <P extends EnvironmentRepositoryProperties> P bindProperties(
int index, Class<P> propertiesClass, Environment environment) {
private <P extends EnvironmentRepositoryProperties> P bindProperties(int index,
Class<P> propertiesClass, Environment environment) {
Binder binder = Binder.get(environment);
String environmentConfigurationPropertyName = String.format("spring.cloud.config.server.composite[%d]", index);
P properties = binder.bind(environmentConfigurationPropertyName, propertiesClass).orElseCreate(propertiesClass);
String environmentConfigurationPropertyName = String
.format("spring.cloud.config.server.composite[%d]", index);
P properties = binder.bind(environmentConfigurationPropertyName, propertiesClass)
.orElseCreate(propertiesClass);
properties.setOrder(index + 1);
return properties;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.composite;
import java.lang.reflect.AnnotatedType;
@@ -34,60 +35,81 @@ import org.springframework.core.type.MethodMetadata;
/**
* @author Dylan Roberts
*/
public class CompositeUtils {
public final class CompositeUtils {
/**
* Returns list of values of the `type` field from the `spring.cloud.config.server.composite` collection.
*/
public static List<String> getCompositeTypeList(Environment environment) {
return Binder.get(environment)
.bind("spring.cloud.config.server", CompositeConfig.class)
.get().getComposite().stream()
.map(map -> (String)map.get("type"))
.collect(Collectors.toList());
}
private CompositeUtils() {
throw new IllegalStateException("Can't instantiate a utility class");
}
static class CompositeConfig {
List<Map<String, Object>> composite;
/**
* Returns list of values of the `type` field from the
* `spring.cloud.config.server.composite` collection.
* @param environment Spring Environment
* @return list of matching types
*/
public static List<String> getCompositeTypeList(Environment environment) {
return Binder.get(environment)
.bind("spring.cloud.config.server", CompositeConfig.class).get()
.getComposite().stream().map(map -> (String) map.get("type"))
.collect(Collectors.toList());
}
public List<Map<String, Object>> getComposite() {
return composite;
}
/**
* Given a type of EnvironmentRepository (git, svn, native, etc...) returns the name
* of the factory bean. See {@link #getCompositeTypeList(Environment)}
* @param type type of a repository
* @param beanFactory Spring Bean Factory
* @return name of the factory bean
*/
public static String getFactoryName(String type,
ConfigurableListableBeanFactory beanFactory) {
String[] factoryNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
beanFactory, EnvironmentRepositoryFactory.class, true, false);
return Arrays.stream(factoryNames).filter(n -> n.startsWith(type)).findFirst()
.orElse(null);
}
public void setComposite(List<Map<String, Object>> composite) {
this.composite = composite;
}
}
/**
* Given a Factory Name return the generic type parameters of the factory (The actual
* repository class, and its properties class).
* @param beanFactory Spring Bean Factory
* @param factoryName name of the factory
* @return generic type params of the factory
*/
public static Type[] getEnvironmentRepositoryFactoryTypeParams(
ConfigurableListableBeanFactory beanFactory, String factoryName) {
MethodMetadata methodMetadata = (MethodMetadata) beanFactory
.getBeanDefinition(factoryName).getSource();
Class<?> factoryClass = null;
try {
factoryClass = Class.forName(methodMetadata.getReturnTypeName());
}
catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
Optional<AnnotatedType> annotatedFactoryType = Arrays
.stream(factoryClass.getAnnotatedInterfaces()).filter(i -> {
ParameterizedType parameterizedType = (ParameterizedType) i.getType();
return parameterizedType.getRawType()
.equals(EnvironmentRepositoryFactory.class);
}).findFirst();
ParameterizedType factoryParameterizedType = (ParameterizedType) annotatedFactoryType
.orElse(factoryClass.getAnnotatedSuperclass()).getType();
return factoryParameterizedType.getActualTypeArguments();
}
/**
* Given a type of EnvironmentRepository (git, svn, native, etc...) returns the name of the factory bean.
* See {@link #getCompositeTypeList(Environment)}
*/
public static String getFactoryName(String type, ConfigurableListableBeanFactory beanFactory) {
String[] factoryNames = BeanFactoryUtils
.beanNamesForTypeIncludingAncestors(beanFactory, EnvironmentRepositoryFactory.class, true, false);
return Arrays.stream(factoryNames).filter(n -> n.startsWith(type)).findFirst().orElse(null);
}
static class CompositeConfig {
/**
* Given a Factory Name return the generic type parameters of the factory (The actual repository class, and its properties class)o
*/
public static Type[] getEnvironmentRepositoryFactoryTypeParams(ConfigurableListableBeanFactory beanFactory, String factoryName) {
MethodMetadata methodMetadata = (MethodMetadata) beanFactory.getBeanDefinition(factoryName).getSource();
Class<?> factoryClass = null;
try {
factoryClass = Class.forName(methodMetadata.getReturnTypeName());
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
Optional<AnnotatedType> annotatedFactoryType = Arrays.stream(factoryClass.getAnnotatedInterfaces())
.filter(i -> {
ParameterizedType parameterizedType = (ParameterizedType) i.getType();
return parameterizedType.getRawType().equals(EnvironmentRepositoryFactory.class);
}).findFirst();
ParameterizedType factoryParameterizedType = (ParameterizedType) annotatedFactoryType
.orElse(factoryClass.getAnnotatedSuperclass()).getType();
return factoryParameterizedType.getActualTypeArguments();
}
List<Map<String, Object>> composite;
public List<Map<String, Object>> getComposite() {
return this.composite;
}
public void setComposite(List<Map<String, Object>> composite) {
this.composite = composite;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.composite;
import java.lang.annotation.Documented;
@@ -31,4 +32,5 @@ import org.springframework.context.annotation.Conditional;
@Documented
@Conditional(OnSearchPathLocatorPresent.class)
public @interface ConditionalOnMissingSearchPathLocator {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.composite;
import java.lang.annotation.Documented;
@@ -31,4 +32,5 @@ import org.springframework.context.annotation.Conditional;
@Documented
@Conditional(OnSearchPathLocatorPresent.class)
public @interface ConditionalOnSearchPathLocator {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.composite;
import java.lang.reflect.Type;
@@ -32,29 +33,40 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
* @author Dylan Roberts
*/
public class OnSearchPathLocatorPresent extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
List<String> types = CompositeUtils.getCompositeTypeList(context.getEnvironment());
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
List<String> types = CompositeUtils
.getCompositeTypeList(context.getEnvironment());
// get EnvironmentRepository types from registered factories
List<Class<? extends EnvironmentRepository>> repositoryTypes = new ArrayList<>();
for (String type : types) {
String factoryName = CompositeUtils.getFactoryName(type, beanFactory);
Type[] actualTypeArguments = CompositeUtils.getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName);
Class<? extends EnvironmentRepository> repositoryType =
(Class<? extends EnvironmentRepository>) actualTypeArguments[0];
repositoryTypes.add(repositoryType);
}
// get EnvironmentRepository types from registered factories
List<Class<? extends EnvironmentRepository>> repositoryTypes = new ArrayList<>();
for (String type : types) {
String factoryName = CompositeUtils.getFactoryName(type, beanFactory);
Type[] actualTypeArguments = CompositeUtils
.getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName);
Class<? extends EnvironmentRepository> repositoryType;
repositoryType = (Class<? extends EnvironmentRepository>) actualTypeArguments[0];
repositoryTypes.add(repositoryType);
}
boolean required = metadata
.isAnnotated(ConditionalOnSearchPathLocator.class.getName());
boolean foundSearchPathLocator = repositoryTypes.stream()
.anyMatch(SearchPathLocator.class::isAssignableFrom);
if (required && !foundSearchPathLocator) {
return ConditionOutcome.noMatch(
ConditionMessage.forCondition(ConditionalOnSearchPathLocator.class)
.notAvailable(SearchPathLocator.class.getTypeName()));
}
if (!required && foundSearchPathLocator) {
return ConditionOutcome.noMatch(ConditionMessage
.forCondition(ConditionalOnMissingSearchPathLocator.class)
.available(SearchPathLocator.class.getTypeName()));
}
return ConditionOutcome.match();
}
boolean required = metadata.isAnnotated(ConditionalOnSearchPathLocator.class.getName());
boolean foundSearchPathLocator = repositoryTypes.stream().anyMatch(SearchPathLocator.class::isAssignableFrom);
if (required && !foundSearchPathLocator) {
return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnSearchPathLocator.class).notAvailable(SearchPathLocator.class.getTypeName()));
}
if (!required && foundSearchPathLocator) {
return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnMissingSearchPathLocator.class).available(SearchPathLocator.class.getTypeName()));
}
return ConditionOutcome.match();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.config.server.config;
import java.util.ArrayList;
@@ -42,14 +43,14 @@ public class CompositeConfiguration {
@Primary
@ConditionalOnBean(SearchPathLocator.class)
public SearchPathCompositeEnvironmentRepository searchPathCompositeEnvironmentRepository() {
return new SearchPathCompositeEnvironmentRepository(environmentRepos);
return new SearchPathCompositeEnvironmentRepository(this.environmentRepos);
}
@Bean
@Primary
@ConditionalOnMissingBean(SearchPathLocator.class)
public CompositeEnvironmentRepository compositeEnvironmentRepository() {
return new CompositeEnvironmentRepository(environmentRepos);
return new CompositeEnvironmentRepository(this.environmentRepos);
}
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.config.server.config;
@@ -28,8 +27,9 @@ import org.springframework.context.annotation.Import;
@Configuration
@ConditionalOnBean(ConfigServerConfiguration.Marker.class)
@EnableConfigurationProperties(ConfigServerProperties.class)
@Import({ EnvironmentRepositoryConfiguration.class, CompositeConfiguration.class, ResourceRepositoryConfiguration.class,
ConfigServerEncryptionConfiguration.class, ConfigServerMvcConfiguration.class })
@Import({ EnvironmentRepositoryConfiguration.class, CompositeConfiguration.class,
ResourceRepositoryConfiguration.class, ConfigServerEncryptionConfiguration.class,
ConfigServerMvcConfiguration.class })
public class ConfigServerAutoConfiguration {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.cloud.config.server.config;
@@ -25,10 +24,14 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
public class ConfigServerConfiguration {
class Marker {}
@Bean
public Marker enableConfigServerMarker() {
return new Marker();
}
class Marker {
}
}

Some files were not shown because too many files have changed in this diff Show More