mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
format code with maven plugins
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package com.alibaba.alicloud.acm;
|
||||
|
||||
import com.alibaba.alicloud.acm.refresh.AcmContextRefresher;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
import com.taobao.diamond.client.Diamond;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -25,12 +30,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.alicloud.acm.refresh.AcmContextRefresher;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
|
||||
import com.taobao.diamond.client.Diamond;
|
||||
|
||||
/**
|
||||
* Created on 01/10/2017.
|
||||
*
|
||||
@@ -67,4 +66,5 @@ public class AcmAutoConfiguration implements ApplicationContextAware {
|
||||
throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -19,13 +19,13 @@ package com.alibaba.alicloud.acm;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySource;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySource;
|
||||
|
||||
/**
|
||||
* @author juven.xuxb, 5/17/16.
|
||||
*/
|
||||
@@ -38,8 +38,8 @@ public class AcmPropertySourceRepository {
|
||||
}
|
||||
|
||||
/**
|
||||
* get all acm properties from application context
|
||||
* @return
|
||||
* get all acm properties from application context.
|
||||
* @return list of acm propertysource
|
||||
*/
|
||||
public List<AcmPropertySource> getAll() {
|
||||
List<AcmPropertySource> result = new ArrayList<>();
|
||||
@@ -66,4 +66,5 @@ public class AcmPropertySourceRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -52,4 +52,5 @@ public class AcmPropertySource extends MapPropertySource {
|
||||
public boolean isGroupLevel() {
|
||||
return groupLevel;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -23,15 +23,15 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import com.alibaba.edas.acm.exception.ConfigException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import com.alibaba.edas.acm.exception.ConfigException;
|
||||
|
||||
/**
|
||||
* @author juven.xuxb
|
||||
* @author xiaolongzuo
|
||||
@@ -41,12 +41,11 @@ class AcmPropertySourceBuilder {
|
||||
private Logger log = LoggerFactory.getLogger(AcmPropertySourceBuilder.class);
|
||||
|
||||
/**
|
||||
* 传入 ACM 的 DataId 和 groupID,获取到解析后的 AcmProperty 对象
|
||||
*
|
||||
* @param dataId
|
||||
* @param diamondGroup
|
||||
* @param groupLevel
|
||||
* @return
|
||||
* 传入 ACM 的 DataId 和 groupID,获取到解析后的 AcmProperty 对象.
|
||||
* @param dataId dataid of diamond
|
||||
* @param diamondGroup group of diamond
|
||||
* @param groupLevel group level of diamond
|
||||
* @return acm property source
|
||||
*/
|
||||
AcmPropertySource build(String dataId, String diamondGroup, boolean groupLevel) {
|
||||
Properties properties = loadDiamondData(dataId, diamondGroup);
|
||||
@@ -102,4 +101,5 @@ class AcmPropertySourceBuilder {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.alibaba.alicloud.acm.bootstrap;
|
||||
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
|
||||
@@ -23,8 +25,6 @@ import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
|
||||
/**
|
||||
* @author juven.xuxb
|
||||
* @author xiaolongzuo
|
||||
@@ -69,4 +69,5 @@ public class AcmPropertySourceLocator implements PropertySourceLocator {
|
||||
composite.addFirstPropertySource(ps);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -23,14 +23,14 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySource;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
|
||||
/**
|
||||
* Created on 01/10/2017.
|
||||
*
|
||||
@@ -80,4 +80,5 @@ public class AcmEndpoint {
|
||||
result.put("runtime", runtime);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.alibaba.alicloud.acm.endpoint;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -24,15 +28,12 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
@ConditionalOnWebApplication
|
||||
@ConditionalOnClass(name = "org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration")
|
||||
@ConditionalOnClass(
|
||||
name = "org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration")
|
||||
@ConditionalOnProperty(name = "spring.cloud.alicloud.acm.enabled", matchIfMissing = true)
|
||||
public class AcmEndpointAutoConfiguration {
|
||||
|
||||
@@ -59,4 +60,5 @@ public class AcmEndpointAutoConfiguration {
|
||||
AcmPropertySourceRepository acmPropertySourceRepository) {
|
||||
return new AcmHealthIndicator(acmProperties, acmPropertySourceRepository);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -19,15 +19,15 @@ package com.alibaba.alicloud.acm.endpoint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySource;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author leijuan
|
||||
* @author juven
|
||||
@@ -70,4 +70,5 @@ public class AcmHealthIndicator extends AbstractHealthIndicator {
|
||||
}
|
||||
builder.up().withDetail("dataIds", dataIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -23,8 +23,13 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import com.alibaba.edas.acm.listener.ConfigChangeListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.cloud.context.refresh.ContextRefresher;
|
||||
@@ -34,11 +39,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import com.alibaba.edas.acm.listener.ConfigChangeListener;
|
||||
|
||||
/**
|
||||
* On application start up, AcmContextRefresher add diamond listeners to all application
|
||||
* level dataIds, when there is a change in the data, listeners will refresh
|
||||
@@ -120,4 +120,5 @@ public class AcmContextRefresher
|
||||
throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -47,6 +47,7 @@ public class AcmRefreshHistory {
|
||||
public LinkedList<Record> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Record {
|
||||
@@ -57,7 +58,7 @@ class Record {
|
||||
|
||||
private final String md5;
|
||||
|
||||
public Record(String timestamp, String dataId, String md5) {
|
||||
Record(String timestamp, String dataId, String md5) {
|
||||
this.timestamp = timestamp;
|
||||
this.dataId = dataId;
|
||||
this.md5 = md5;
|
||||
@@ -74,4 +75,5 @@ class Record {
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package com.alibaba.alicloud.acm;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Assert;
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySourceLocator;
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
@@ -32,6 +32,7 @@ import org.powermock.api.support.MethodProxy;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -40,12 +41,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.alicloud.acm.bootstrap.AcmPropertySourceLocator;
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmIntegrationProperties;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@@ -54,16 +51,18 @@ import com.alibaba.edas.acm.ConfigService;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(SpringRunner.class)
|
||||
@PrepareForTest({ ConfigService.class })
|
||||
@SpringBootTest(classes = AcmConfigurationTests.TestConfig.class, properties = {
|
||||
"spring.application.name=test-name", "spring.profiles.active=dev,test",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8848",
|
||||
"spring.cloud.alicloud.acm.endpoint=test-endpoint",
|
||||
"spring.cloud.alicloud.acm.namespace=test-namespace",
|
||||
"spring.cloud.alicloud.acm.timeout=1000",
|
||||
"spring.cloud.alicloud.acm.group=test-group",
|
||||
"spring.cloud.alicloud.acm.refresh-enabled=false",
|
||||
"spring.cloud.alicloud.acm.file-extension=properties" }, webEnvironment = NONE)
|
||||
@SpringBootTest(classes = AcmConfigurationTests.TestConfig.class,
|
||||
properties = { "spring.application.name=test-name",
|
||||
"spring.profiles.active=dev,test",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8848",
|
||||
"spring.cloud.alicloud.acm.endpoint=test-endpoint",
|
||||
"spring.cloud.alicloud.acm.namespace=test-namespace",
|
||||
"spring.cloud.alicloud.acm.timeout=1000",
|
||||
"spring.cloud.alicloud.acm.group=test-group",
|
||||
"spring.cloud.alicloud.acm.refresh-enabled=false",
|
||||
"spring.cloud.alicloud.acm.file-extension=properties" },
|
||||
webEnvironment = NONE)
|
||||
public class AcmConfigurationTests {
|
||||
|
||||
static {
|
||||
@@ -112,9 +111,9 @@ public class AcmConfigurationTests {
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("AcmPropertySourceLocator was not created", locator);
|
||||
assertNotNull("AcmProperties was not created", properties);
|
||||
assertNotNull("AcmIntegrationProperties was not created", integrationProperties);
|
||||
assertThat(locator).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(integrationProperties).isNotNull();
|
||||
|
||||
checkoutAcmServerAddr();
|
||||
checkoutAcmServerPort();
|
||||
@@ -130,60 +129,48 @@ public class AcmConfigurationTests {
|
||||
}
|
||||
|
||||
private void checkoutAcmServerAddr() {
|
||||
assertEquals("AcmProperties server address is wrong", "127.0.0.1",
|
||||
properties.getServerList());
|
||||
|
||||
assertThat(properties.getServerList()).isEqualTo("127.0.0.1");
|
||||
}
|
||||
|
||||
private void checkoutAcmServerPort() {
|
||||
assertEquals("AcmProperties server port is wrong", "8848",
|
||||
properties.getServerPort());
|
||||
|
||||
assertThat(properties.getServerPort()).isEqualTo("8848");
|
||||
}
|
||||
|
||||
private void checkoutAcmEndpoint() {
|
||||
assertEquals("AcmProperties endpoint is wrong", "test-endpoint",
|
||||
properties.getEndpoint());
|
||||
|
||||
assertThat(properties.getEndpoint()).isEqualTo("test-endpoint");
|
||||
}
|
||||
|
||||
private void checkoutAcmNamespace() {
|
||||
assertEquals("AcmProperties namespace is wrong", "test-namespace",
|
||||
properties.getNamespace());
|
||||
|
||||
assertThat(properties.getNamespace()).isEqualTo("test-namespace");
|
||||
}
|
||||
|
||||
private void checkoutAcmGroup() {
|
||||
assertEquals("AcmProperties' group is wrong", "test-group",
|
||||
properties.getGroup());
|
||||
assertThat(properties.getGroup()).isEqualTo("test-group");
|
||||
}
|
||||
|
||||
private void checkoutAcmFileExtension() {
|
||||
assertEquals("AcmProperties' file extension is wrong", "properties",
|
||||
properties.getFileExtension());
|
||||
assertThat(properties.getFileExtension()).isEqualTo("properties");
|
||||
}
|
||||
|
||||
private void checkoutAcmTimeout() {
|
||||
assertEquals("AcmProperties' timeout is wrong", 1000, properties.getTimeout());
|
||||
assertThat(properties.getTimeout()).isEqualTo(1000);
|
||||
}
|
||||
|
||||
private void checkoutAcmRefreshEnabled() {
|
||||
assertEquals("AcmProperties' refresh enabled is wrong", false,
|
||||
properties.isRefreshEnabled());
|
||||
assertThat(properties.isRefreshEnabled()).isEqualTo(false);
|
||||
}
|
||||
|
||||
private void checkoutAcmProfiles() {
|
||||
assertArrayEquals("AcmProperties' profiles is wrong",
|
||||
new String[] { "dev", "test" },
|
||||
integrationProperties.getActiveProfiles());
|
||||
assertThat(integrationProperties.getActiveProfiles())
|
||||
.isEqualTo(new String[] { "dev", "test" });
|
||||
}
|
||||
|
||||
private void checkoutDataLoad() {
|
||||
Assert.assertEquals(environment.getProperty("user.age"), "12");
|
||||
assertThat(environment.getProperty("user.age")).isEqualTo("12");
|
||||
}
|
||||
|
||||
private void checkoutProfileDataLoad() {
|
||||
Assert.assertEquals(environment.getProperty("user.name"), "dev");
|
||||
assertThat(environment.getProperty("user.name")).isEqualTo("dev");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -191,5 +178,7 @@ public class AcmConfigurationTests {
|
||||
@ImportAutoConfiguration({ AcmEndpointAutoConfiguration.class,
|
||||
AcmAutoConfiguration.class, AcmContextBootstrapConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2019 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package com.alibaba.alicloud.acm;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -29,6 +30,7 @@ import org.powermock.api.support.MethodProxy;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -37,9 +39,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@@ -48,11 +48,12 @@ import com.alibaba.edas.acm.ConfigService;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(SpringRunner.class)
|
||||
@PrepareForTest({ ConfigService.class })
|
||||
@SpringBootTest(classes = AcmFileExtensionTest.TestConfig.class, properties = {
|
||||
"spring.application.name=test-name",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8080",
|
||||
"spring.cloud.alicloud.acm.file-extension=yaml" }, webEnvironment = NONE)
|
||||
@SpringBootTest(classes = AcmFileExtensionTest.TestConfig.class,
|
||||
properties = { "spring.application.name=test-name",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8080",
|
||||
"spring.cloud.alicloud.acm.file-extension=yaml" },
|
||||
webEnvironment = NONE)
|
||||
public class AcmFileExtensionTest {
|
||||
|
||||
static {
|
||||
@@ -94,5 +95,7 @@ public class AcmFileExtensionTest {
|
||||
@ImportAutoConfiguration({ AcmEndpointAutoConfiguration.class,
|
||||
AcmAutoConfiguration.class, AcmContextBootstrapConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2019 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package com.alibaba.alicloud.acm;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -29,6 +30,7 @@ import org.powermock.api.support.MethodProxy;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -37,9 +39,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.alicloud.acm.endpoint.AcmEndpointAutoConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@@ -48,12 +48,14 @@ import com.alibaba.edas.acm.ConfigService;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(SpringRunner.class)
|
||||
@PrepareForTest({ ConfigService.class })
|
||||
@SpringBootTest(classes = AcmGroupConfigurationTest.TestConfig.class, properties = {
|
||||
"spring.application.name=test-name", "spring.application.group=com.test.hello",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8080",
|
||||
"spring.cloud.alicloud.acm.timeout=1000",
|
||||
"spring.cloud.alicloud.acm.group=test-group" }, webEnvironment = NONE)
|
||||
@SpringBootTest(classes = AcmGroupConfigurationTest.TestConfig.class,
|
||||
properties = { "spring.application.name=test-name",
|
||||
"spring.application.group=com.test.hello",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8080",
|
||||
"spring.cloud.alicloud.acm.timeout=1000",
|
||||
"spring.cloud.alicloud.acm.group=test-group" },
|
||||
webEnvironment = NONE)
|
||||
public class AcmGroupConfigurationTest {
|
||||
|
||||
static {
|
||||
@@ -102,5 +104,7 @@ public class AcmGroupConfigurationTest {
|
||||
@ImportAutoConfiguration({ AcmEndpointAutoConfiguration.class,
|
||||
AcmAutoConfiguration.class, AcmContextBootstrapConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* https://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,
|
||||
@@ -16,15 +16,18 @@
|
||||
|
||||
package com.alibaba.alicloud.acm.endpoint;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmAutoConfiguration;
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -33,6 +36,7 @@ import org.powermock.api.support.MethodProxy;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.health.Health.Builder;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
@@ -41,12 +45,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.alicloud.acm.AcmAutoConfiguration;
|
||||
import com.alibaba.alicloud.acm.AcmPropertySourceRepository;
|
||||
import com.alibaba.alicloud.acm.refresh.AcmRefreshHistory;
|
||||
import com.alibaba.alicloud.context.acm.AcmContextBootstrapConfiguration;
|
||||
import com.alibaba.alicloud.context.acm.AcmProperties;
|
||||
import com.alibaba.edas.acm.ConfigService;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@@ -55,11 +55,12 @@ import com.alibaba.edas.acm.ConfigService;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(SpringRunner.class)
|
||||
@PrepareForTest({ ConfigService.class })
|
||||
@SpringBootTest(classes = AcmEndpointTests.TestConfig.class, properties = {
|
||||
"spring.application.name=test-name",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8848",
|
||||
"spring.cloud.alicloud.acm.file-extension=properties" }, webEnvironment = NONE)
|
||||
@SpringBootTest(classes = AcmEndpointTests.TestConfig.class,
|
||||
properties = { "spring.application.name=test-name",
|
||||
"spring.cloud.alicloud.acm.server-list=127.0.0.1",
|
||||
"spring.cloud.alicloud.acm.server-port=8848",
|
||||
"spring.cloud.alicloud.acm.file-extension=properties" },
|
||||
webEnvironment = NONE)
|
||||
public class AcmEndpointTests {
|
||||
|
||||
static {
|
||||
@@ -134,9 +135,9 @@ public class AcmEndpointTests {
|
||||
AcmEndpoint acmEndpoint = new AcmEndpoint(properties, refreshHistory,
|
||||
propertySourceRepository);
|
||||
Map<String, Object> map = acmEndpoint.invoke();
|
||||
assertEquals(map.get("config"), properties);
|
||||
assertEquals(((Map) map.get("runtime")).get("refreshHistory"),
|
||||
refreshHistory.getRecords());
|
||||
assertThat(properties).isEqualTo(map.get("config"));
|
||||
assertThat(refreshHistory.getRecords())
|
||||
.isEqualTo(((Map) map.get("runtime")).get("refreshHistory"));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -144,5 +145,7 @@ public class AcmEndpointTests {
|
||||
@ImportAutoConfiguration({ AcmEndpointAutoConfiguration.class,
|
||||
AcmAutoConfiguration.class, AcmContextBootstrapConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user