Merge remote-tracking branch 'upstream/master' into binder-dev
commit
77fedf72b4
@ -1,107 +0,0 @@
|
|||||||
package org.springframework.cloud.alicloud.context.sms;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.cloud.alicloud.context.AliCloudProperties;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author pbting
|
|
||||||
*/
|
|
||||||
@ConfigurationProperties(prefix = "spring.cloud.alicloud.sms")
|
|
||||||
public class SmsConfigProperties implements Serializable {
|
|
||||||
|
|
||||||
// 产品名称:云通信短信API产品,开发者无需替换
|
|
||||||
public static final String smsProduct = "Dysmsapi";
|
|
||||||
// 产品域名,开发者无需替换
|
|
||||||
public static final String smsDomain = "dysmsapi.aliyuncs.com";
|
|
||||||
|
|
||||||
private AliCloudProperties aliCloudProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private String reportQueueName;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private String upQueueName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected String connnectTimeout = "10000";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected String readTimeout = "10000";
|
|
||||||
|
|
||||||
public SmsConfigProperties(AliCloudProperties aliCloudProperties) {
|
|
||||||
this.aliCloudProperties = aliCloudProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConnnectTimeout() {
|
|
||||||
return connnectTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnnectTimeout(String connnectTimeout) {
|
|
||||||
this.connnectTimeout = connnectTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReadTimeout() {
|
|
||||||
return readTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadTimeout(String readTimeout) {
|
|
||||||
this.readTimeout = readTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void overiideFromEnv(Environment environment) {
|
|
||||||
overiideCustomFromEnv(environment);
|
|
||||||
if (StringUtils.isEmpty(connnectTimeout)) {
|
|
||||||
String resolveResult = environment.resolveRequiredPlaceholders(
|
|
||||||
"${spring.cloud.alibaba.sms.connect-timeout:}");
|
|
||||||
this.setConnnectTimeout(
|
|
||||||
StringUtils.isEmpty(resolveResult) ? "10000" : resolveResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(readTimeout)) {
|
|
||||||
String resolveResult = environment.resolveRequiredPlaceholders(
|
|
||||||
"${spring.cloud.alibaba.sms.read-timeout:}");
|
|
||||||
this.setReadTimeout(
|
|
||||||
StringUtils.isEmpty(resolveResult) ? "10000" : resolveResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void overiideCustomFromEnv(Environment environment) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReportQueueName() {
|
|
||||||
return reportQueueName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReportQueueName(String reportQueueName) {
|
|
||||||
this.reportQueueName = reportQueueName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUpQueueName() {
|
|
||||||
return upQueueName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessKeyId() {
|
|
||||||
return aliCloudProperties.getAccessKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessKeySecret() {
|
|
||||||
return aliCloudProperties.getSecretKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpQueueName(String upQueueName) {
|
|
||||||
this.upQueueName = upQueueName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package org.springframework.cloud.alicloud.context.sms;
|
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author pbting
|
|
||||||
*/
|
|
||||||
public class SmsConfigRegistration {
|
|
||||||
|
|
||||||
private Environment environment;
|
|
||||||
|
|
||||||
private SmsConfigProperties smsConfigProperties;
|
|
||||||
|
|
||||||
public SmsConfigRegistration(Environment environment,
|
|
||||||
SmsConfigProperties smsConfigProperties) {
|
|
||||||
this.environment = environment;
|
|
||||||
this.smsConfigProperties = smsConfigProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void initSmsConfigRegistration() {
|
|
||||||
smsConfigProperties.overiideFromEnv(environment);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,74 @@
|
|||||||
|
package org.springframework.cloud.alicloud.context.sms;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author pbting
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "spring.cloud.alicloud.sms")
|
||||||
|
public class SmsProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Product name.
|
||||||
|
*/
|
||||||
|
public static final String smsProduct = "Dysmsapi";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Product domain.
|
||||||
|
*/
|
||||||
|
public static final String smsDomain = "dysmsapi.aliyuncs.com";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report queue name.
|
||||||
|
*/
|
||||||
|
private String reportQueueName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Up queue name.
|
||||||
|
*/
|
||||||
|
private String upQueueName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect timeout.
|
||||||
|
*/
|
||||||
|
private String connectTimeout = "10000";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read timeout.
|
||||||
|
*/
|
||||||
|
private String readTimeout = "10000";
|
||||||
|
|
||||||
|
public String getConnectTimeout() {
|
||||||
|
return connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnectTimeout(String connectTimeout) {
|
||||||
|
this.connectTimeout = connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReadTimeout() {
|
||||||
|
return readTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadTimeout(String readTimeout) {
|
||||||
|
this.readTimeout = readTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReportQueueName() {
|
||||||
|
return reportQueueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReportQueueName(String reportQueueName) {
|
||||||
|
this.reportQueueName = reportQueueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpQueueName() {
|
||||||
|
return upQueueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpQueueName(String upQueueName) {
|
||||||
|
this.upQueueName = upQueueName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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 com.alibaba.csp.sentinel.datasource.nacos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class NacosDataSource {
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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 com.aliyuncs.dysmsapi.model.v20170525;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class SendSmsRequest {
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alibaba.nacos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class NacosConfigAutoConfiguration {
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alicloud.context.ans;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.cloud.alicloud.context.BaseAliCloudSpringApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class AnsContextApplicationListenerTests extends BaseAliCloudSpringApplication {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAnsContextApplicationListenerDefault() {
|
||||||
|
assertThat(System
|
||||||
|
.getProperty("com.alibaba.ans.shaded.com.taobao.vipserver.serverlist"))
|
||||||
|
.isEqualTo("192.168.1.100");
|
||||||
|
assertThat(System.getProperty("vipserver.server.port")).isEqualTo("8888");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alicloud.context.nacos;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.springframework.cloud.alicloud.context.BaseAliCloudSpringApplication;
|
||||||
|
import org.springframework.cloud.alicloud.utils.ChangeOrderUtils;
|
||||||
|
|
||||||
|
import com.alibaba.cloud.context.ans.AliCloudAnsInitializer;
|
||||||
|
import com.alibaba.cloud.context.edas.EdasChangeOrderConfigurationFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
@PrepareForTest({ EdasChangeOrderConfigurationFactory.class,
|
||||||
|
NacosParameterInitListener.class, AliCloudAnsInitializer.class })
|
||||||
|
public class NacosParameterInitListenerTests extends BaseAliCloudSpringApplication {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() {
|
||||||
|
ChangeOrderUtils.mockChangeOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNacosParameterInitListener() {
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.server-mode"))
|
||||||
|
.isEqualTo("EDAS");
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.server-addr"))
|
||||||
|
.isEqualTo("");
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.endpoint"))
|
||||||
|
.isEqualTo("testDomain");
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.namespace"))
|
||||||
|
.isEqualTo("testTenantId");
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.access-key"))
|
||||||
|
.isEqualTo("testAK");
|
||||||
|
assertThat(System.getProperty("spring.cloud.nacos.config.secret-key"))
|
||||||
|
.isEqualTo("testSK");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alicloud.context.sentinel;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.springframework.cloud.alicloud.context.BaseAliCloudSpringApplication;
|
||||||
|
import org.springframework.cloud.alicloud.context.Constants;
|
||||||
|
import org.springframework.cloud.alicloud.utils.ChangeOrderUtils;
|
||||||
|
|
||||||
|
import com.alibaba.cloud.context.edas.EdasChangeOrderConfigurationFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
@PrepareForTest({ EdasChangeOrderConfigurationFactory.class,
|
||||||
|
SentinelAliCloudListener.class })
|
||||||
|
public class SentinelAliCloudListenerTests extends BaseAliCloudSpringApplication {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() {
|
||||||
|
ChangeOrderUtils.mockChangeOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNacosParameterInitListener() {
|
||||||
|
assertThat(System.getProperty(Constants.Sentinel.NACOS_DATASOURCE_ENDPOINT))
|
||||||
|
.isEqualTo("testDomain");
|
||||||
|
assertThat(System.getProperty(Constants.Sentinel.PROJECT_NAME))
|
||||||
|
.isEqualTo("testProjectName");
|
||||||
|
assertThat(System.getProperty(Constants.Sentinel.NACOS_DATASOURCE_NAMESPACE))
|
||||||
|
.isEqualTo("testTenantId");
|
||||||
|
assertThat(System.getProperty(Constants.Sentinel.NACOS_DATASOURCE_AK))
|
||||||
|
.isEqualTo("testAK");
|
||||||
|
assertThat(System.getProperty(Constants.Sentinel.NACOS_DATASOURCE_SK))
|
||||||
|
.isEqualTo("testSK");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alicloud.context.sms;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||||
|
|
||||||
|
import org.assertj.core.api.AssertionsForClassTypes;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
import org.springframework.cloud.alicloud.context.AliCloudContextAutoConfiguration;
|
||||||
|
import org.springframework.cloud.alicloud.context.edas.EdasContextAutoConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class SmsPropertiesTests {
|
||||||
|
|
||||||
|
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||||
|
.withConfiguration(AutoConfigurations.of(SmsContextAutoConfiguration.class,
|
||||||
|
EdasContextAutoConfiguration.class,
|
||||||
|
AliCloudContextAutoConfiguration.class));
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigurationValueDefaultsAreAsExpected() {
|
||||||
|
this.contextRunner.run(context -> {
|
||||||
|
SmsProperties config = context.getBean(SmsProperties.class);
|
||||||
|
assertThat(config.getReportQueueName()).isNull();
|
||||||
|
assertThat(config.getUpQueueName()).isNull();
|
||||||
|
assertThat(config.getConnectTimeout()).isEqualTo("10000");
|
||||||
|
assertThat(config.getReadTimeout()).isEqualTo("10000");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigurationValuesAreCorrectlyLoaded() {
|
||||||
|
this.contextRunner
|
||||||
|
.withPropertyValues("spring.cloud.alicloud.sms.reportQueueName=q1",
|
||||||
|
"spring.cloud.alicloud.sms.upQueueName=q2",
|
||||||
|
"spring.cloud.alicloud.sms.connect-timeout=20",
|
||||||
|
"spring.cloud.alicloud.sms.read-timeout=30")
|
||||||
|
.run(context -> {
|
||||||
|
SmsProperties config = context.getBean(SmsProperties.class);
|
||||||
|
AssertionsForClassTypes.assertThat(config.getReportQueueName())
|
||||||
|
.isEqualTo("q1");
|
||||||
|
AssertionsForClassTypes.assertThat(config.getUpQueueName())
|
||||||
|
.isEqualTo("q2");
|
||||||
|
AssertionsForClassTypes.assertThat(config.getConnectTimeout())
|
||||||
|
.isEqualTo("20");
|
||||||
|
AssertionsForClassTypes.assertThat(config.getReadTimeout())
|
||||||
|
.isEqualTo("30");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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
|
||||||
|
*
|
||||||
|
* 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.alicloud.utils;
|
||||||
|
|
||||||
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
|
||||||
|
import com.alibaba.cloud.context.edas.EdasChangeOrderConfiguration;
|
||||||
|
import com.alibaba.cloud.context.edas.EdasChangeOrderConfigurationFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaolongzuo
|
||||||
|
*/
|
||||||
|
public class ChangeOrderUtils {
|
||||||
|
|
||||||
|
private ChangeOrderUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void mockChangeOrder() {
|
||||||
|
EdasChangeOrderConfiguration edasChangeOrderConfiguration = PowerMockito
|
||||||
|
.mock(EdasChangeOrderConfiguration.class);
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.isEdasManaged()).thenReturn(true);
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getAddressServerDomain())
|
||||||
|
.thenReturn("testDomain");
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getTenantId())
|
||||||
|
.thenReturn("testTenantId");
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getDauthAccessKey())
|
||||||
|
.thenReturn("testAK");
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getDauthSecretKey())
|
||||||
|
.thenReturn("testSK");
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getProjectName())
|
||||||
|
.thenReturn("testProjectName");
|
||||||
|
PowerMockito.when(edasChangeOrderConfiguration.getAddressServerPort())
|
||||||
|
.thenReturn("8080");
|
||||||
|
PowerMockito.mockStatic(EdasChangeOrderConfigurationFactory.class);
|
||||||
|
PowerMockito
|
||||||
|
.when(EdasChangeOrderConfigurationFactory
|
||||||
|
.getEdasChangeOrderConfiguration())
|
||||||
|
.thenReturn(edasChangeOrderConfiguration);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue