commit
b88d627543
@ -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.alicloud.acm;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
public class AcmAutoConfiguration {
|
||||
}
|
@ -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.alicloud.ans;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
public class AnsAutoConfiguration {
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.alicloud.context.AliCloudContextAutoConfiguration;
|
||||
import org.springframework.cloud.alicloud.context.AliCloudProperties;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AliCloudContextAutoConfiguration.class)
|
||||
public class AliCloudPropertiesDefaultTests {
|
||||
|
||||
@Autowired
|
||||
private AliCloudProperties aliCloudProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(aliCloudProperties.getAccessKey()).isNull();
|
||||
assertThat(aliCloudProperties.getSecretKey()).isNull();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.alicloud.context.AliCloudContextAutoConfiguration;
|
||||
import org.springframework.cloud.alicloud.context.AliCloudProperties;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AliCloudContextAutoConfiguration.class, properties = {
|
||||
"spring.cloud.alicloud.access-key=123",
|
||||
"spring.cloud.alicloud.secret-key=123456" })
|
||||
public class AliCloudPropertiesLoadTests {
|
||||
|
||||
@Autowired
|
||||
private AliCloudProperties aliCloudProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(aliCloudProperties.getAccessKey()).isEqualTo("123");
|
||||
assertThat(aliCloudProperties.getSecretKey()).isEqualTo("123456");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = AliCloudSpringApplicationTests.AliCloudDisabledApp.class, properties = {
|
||||
"spring.application.name=myapp",
|
||||
"spring.cloud.alicloud.edas.application.name=myapp",
|
||||
"spring.cloud.alicloud.access-key=ak", "spring.cloud.alicloud.secret-key=sk",
|
||||
"spring.cloud.alicloud.oss.endpoint=test" }, webEnvironment = RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class AliCloudSpringApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
System.out.println("Context load...");
|
||||
}
|
||||
|
||||
@SpringBootApplication
|
||||
public static class AliCloudDisabledApp {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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.context.acm;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AcmContextBootstrapConfiguration.class }, properties = {
|
||||
"spring.application.name=myapp", "spring.application.group=com.alicloud.test",
|
||||
"spring.profiles.active=profile1,profile2", "spring.cloud.alicloud.access-key=ak",
|
||||
"spring.cloud.alicloud.secret-key=sk",
|
||||
"spring.cloud.alicloud.acm.server-mode=EDAS",
|
||||
"spring.cloud.alicloud.acm.server-port=11111",
|
||||
"spring.cloud.alicloud.acm.server-list=10.10.10.10",
|
||||
"spring.cloud.alicloud.acm.namespace=testNamespace",
|
||||
"spring.cloud.alicloud.acm.endpoint=testDomain",
|
||||
"spring.cloud.alicloud.acm.group=testGroup",
|
||||
"spring.cloud.alicloud.acm.file-extension=yaml" })
|
||||
public class AcmIntegrationPropertiesLoad2Tests {
|
||||
|
||||
@Autowired
|
||||
private AcmIntegrationProperties acmIntegrationProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(acmIntegrationProperties.getGroupConfigurationDataIds().size())
|
||||
.isEqualTo(2);
|
||||
assertThat(acmIntegrationProperties.getApplicationConfigurationDataIds().size())
|
||||
.isEqualTo(6);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.acm;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AcmContextBootstrapConfiguration.class }, properties = {
|
||||
"spring.application.name=myapp", "spring.application.group=com.alicloud.test",
|
||||
"spring.cloud.alicloud.access-key=ak", "spring.cloud.alicloud.secret-key=sk",
|
||||
"spring.cloud.alicloud.acm.server-mode=EDAS",
|
||||
"spring.cloud.alicloud.acm.server-port=11111",
|
||||
"spring.cloud.alicloud.acm.server-list=10.10.10.10",
|
||||
"spring.cloud.alicloud.acm.namespace=testNamespace",
|
||||
"spring.cloud.alicloud.acm.endpoint=testDomain",
|
||||
"spring.cloud.alicloud.acm.group=testGroup",
|
||||
"spring.cloud.alicloud.acm.file-extension=yaml" })
|
||||
public class AcmIntegrationPropertiesLoadTests {
|
||||
|
||||
@Autowired
|
||||
private AcmIntegrationProperties acmIntegrationProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(acmIntegrationProperties.getGroupConfigurationDataIds().size())
|
||||
.isEqualTo(2);
|
||||
assertThat(acmIntegrationProperties.getApplicationConfigurationDataIds().size())
|
||||
.isEqualTo(2);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.acm;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.context.AliCloudServerMode;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AcmContextBootstrapConfiguration.class }, properties = {
|
||||
"spring.application.name=myapp" })
|
||||
public class AcmPropertiesDefaultTests {
|
||||
|
||||
@Autowired
|
||||
private AcmProperties acmProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(acmProperties.getServerMode()).isEqualTo(AliCloudServerMode.LOCAL);
|
||||
assertThat(acmProperties.getServerList()).isEqualTo("127.0.0.1");
|
||||
assertThat(acmProperties.getServerPort()).isEqualTo("8080");
|
||||
assertThat(acmProperties.getEndpoint()).isNull();
|
||||
assertThat(acmProperties.getFileExtension()).isEqualTo("properties");
|
||||
assertThat(acmProperties.getGroup()).isEqualTo("DEFAULT_GROUP");
|
||||
assertThat(acmProperties.getNamespace()).isNull();
|
||||
assertThat(acmProperties.getRamRoleName()).isNull();
|
||||
assertThat(acmProperties.getTimeout()).isEqualTo(3000);
|
||||
}
|
||||
}
|
@ -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.acm;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.context.AliCloudServerMode;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AcmContextBootstrapConfiguration.class }, properties = {
|
||||
"spring.application.name=myapp", "spring.cloud.alicloud.access-key=ak",
|
||||
"spring.cloud.alicloud.secret-key=sk",
|
||||
"spring.cloud.alicloud.acm.server-mode=EDAS",
|
||||
"spring.cloud.alicloud.acm.server-port=11111",
|
||||
"spring.cloud.alicloud.acm.server-list=10.10.10.10",
|
||||
"spring.cloud.alicloud.acm.namespace=testNamespace",
|
||||
"spring.cloud.alicloud.acm.endpoint=testDomain",
|
||||
"spring.cloud.alicloud.acm.group=testGroup",
|
||||
"spring.cloud.alicloud.acm.file-extension=yaml" })
|
||||
public class AcmPropertiesLoadTests {
|
||||
|
||||
@Autowired
|
||||
private AcmProperties acmProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(acmProperties.getServerMode()).isEqualTo(AliCloudServerMode.EDAS);
|
||||
assertThat(acmProperties.getServerList()).isEqualTo("10.10.10.10");
|
||||
assertThat(acmProperties.getServerPort()).isEqualTo("11111");
|
||||
assertThat(acmProperties.getEndpoint()).isEqualTo("testDomain");
|
||||
assertThat(acmProperties.getGroup()).isEqualTo("testGroup");
|
||||
assertThat(acmProperties.getFileExtension()).isEqualTo("yaml");
|
||||
assertThat(acmProperties.getNamespace()).isEqualTo("testNamespace");
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.alicloud.context.ans.AnsContextAutoConfiguration;
|
||||
import org.springframework.cloud.alicloud.context.ans.AnsProperties;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.context.AliCloudServerMode;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AnsContextAutoConfiguration.class })
|
||||
public class AnsPropertiesDefaultTests {
|
||||
|
||||
@Autowired
|
||||
private AnsProperties ansProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(ansProperties.getServerMode()).isEqualTo(AliCloudServerMode.LOCAL);
|
||||
assertThat(ansProperties.getServerList()).isEqualTo("127.0.0.1");
|
||||
assertThat(ansProperties.getServerPort()).isEqualTo("8080");
|
||||
assertThat(ansProperties.getClientDomains()).isEqualTo("");
|
||||
assertThat(ansProperties.getClientWeight()).isEqualTo(1.0F);
|
||||
assertThat(ansProperties.getClientWeights().size()).isEqualTo(0);
|
||||
assertThat(ansProperties.getClientTokens().size()).isEqualTo(0);
|
||||
assertThat(ansProperties.getClientMetadata().size()).isEqualTo(0);
|
||||
assertThat(ansProperties.getClientToken()).isNull();
|
||||
assertThat(ansProperties.getClientCluster()).isEqualTo("DEFAULT");
|
||||
assertThat(ansProperties.isRegisterEnabled()).isTrue();
|
||||
assertThat(ansProperties.getClientInterfaceName()).isNull();
|
||||
assertThat(ansProperties.getClientPort()).isEqualTo(-1);
|
||||
assertThat(ansProperties.getEnv()).isEqualTo("DEFAULT");
|
||||
assertThat(ansProperties.isSecure()).isFalse();
|
||||
assertThat(ansProperties.getTags().size()).isEqualTo(1);
|
||||
assertThat(ansProperties.getTags().keySet().iterator().next())
|
||||
.isEqualTo("ANS_SERVICE_TYPE");
|
||||
assertThat(ansProperties.getTags().get("ANS_SERVICE_TYPE"))
|
||||
.isEqualTo("SPRING_CLOUD");
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.context.AliCloudServerMode;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { AnsContextAutoConfiguration.class }, properties = {
|
||||
"spring.cloud.alicloud.ans.server-mode=EDAS",
|
||||
"spring.cloud.alicloud.ans.server-port=11111",
|
||||
"spring.cloud.alicloud.ans.server-list=10.10.10.10",
|
||||
"spring.cloud.alicloud.ans.client-domains=testDomain",
|
||||
"spring.cloud.alicloud.ans.client-weight=0.9",
|
||||
"spring.cloud.alicloud.ans.client-weights.testDomain=0.9" })
|
||||
public class AnsPropertiesLoadTests {
|
||||
|
||||
@Autowired
|
||||
private AnsProperties ansProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(ansProperties.getServerMode()).isEqualTo(AliCloudServerMode.EDAS);
|
||||
assertThat(ansProperties.getServerList()).isEqualTo("10.10.10.10");
|
||||
assertThat(ansProperties.getServerPort()).isEqualTo("11111");
|
||||
assertThat(ansProperties.getClientDomains()).isEqualTo("testDomain");
|
||||
assertThat(ansProperties.getClientWeight()).isEqualTo(0.9F);
|
||||
assertThat(ansProperties.getClientWeights().size()).isEqualTo(1);
|
||||
assertThat(ansProperties.getClientTokens().size()).isEqualTo(0);
|
||||
assertThat(ansProperties.getClientMetadata().size()).isEqualTo(0);
|
||||
assertThat(ansProperties.getClientToken()).isNull();
|
||||
assertThat(ansProperties.getClientCluster()).isEqualTo("DEFAULT");
|
||||
assertThat(ansProperties.isRegisterEnabled()).isTrue();
|
||||
assertThat(ansProperties.getClientInterfaceName()).isNull();
|
||||
assertThat(ansProperties.getClientPort()).isEqualTo(-1);
|
||||
assertThat(ansProperties.getEnv()).isEqualTo("DEFAULT");
|
||||
assertThat(ansProperties.isSecure()).isFalse();
|
||||
assertThat(ansProperties.getTags().size()).isEqualTo(1);
|
||||
assertThat(ansProperties.getTags().keySet().iterator().next())
|
||||
.isEqualTo("ANS_SERVICE_TYPE");
|
||||
assertThat(ansProperties.getTags().get("ANS_SERVICE_TYPE"))
|
||||
.isEqualTo("SPRING_CLOUD");
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.edas;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { EdasContextAutoConfiguration.class })
|
||||
public class EdasPropertiesDefaultTests {
|
||||
|
||||
@Autowired
|
||||
private EdasProperties edasProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(edasProperties.getNamespace()).isNull();
|
||||
assertThat(edasProperties.isApplicationNameValid()).isFalse();
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.edas;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { EdasContextAutoConfiguration.class }, properties = {
|
||||
"spring.cloud.alicloud.edas.namespace=testns",
|
||||
"spring.cloud.alicloud.edas.application.name=myapps" })
|
||||
public class EdasPropertiesLoad2Tests {
|
||||
|
||||
@Autowired
|
||||
private EdasProperties edasProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(edasProperties.getNamespace()).isEqualTo("testns");
|
||||
assertThat(edasProperties.getApplicationName()).isEqualTo("myapps");
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.edas;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { EdasContextAutoConfiguration.class }, properties = {
|
||||
"spring.cloud.alicloud.edas.namespace=testns", "spring.application.name=myapps" })
|
||||
public class EdasPropertiesLoadTests {
|
||||
|
||||
@Autowired
|
||||
private EdasProperties edasProperties;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(edasProperties.getNamespace()).isEqualTo("testns");
|
||||
assertThat(edasProperties.getApplicationName()).isEqualTo("myapps");
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.oss;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.alicloud.context.AliCloudProperties;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = OssContextAutoConfiguration.class, properties = {
|
||||
"spring.cloud.alicloud.accessKey=your-ak",
|
||||
"spring.cloud.alicloud.secretKey=your-sk",
|
||||
"spring.cloud.alicloud.oss.endpoint=http://oss-cn-beijing.aliyuncs.com",
|
||||
"spring.cloud.alicloud.oss.config.userAgent=alibaba" })
|
||||
public class OssLoadTests {
|
||||
|
||||
@Autowired
|
||||
private OssProperties ossProperties;
|
||||
|
||||
@Autowired
|
||||
private AliCloudProperties aliCloudProperties;
|
||||
|
||||
@Autowired
|
||||
private OSSClient ossClient;
|
||||
|
||||
@Test
|
||||
public void testProperties() {
|
||||
assertThat(aliCloudProperties.getAccessKey()).isEqualTo("your-ak");
|
||||
assertThat(aliCloudProperties.getSecretKey()).isEqualTo("your-sk");
|
||||
assertThat(ossProperties.getEndpoint())
|
||||
.isEqualTo("http://oss-cn-beijing.aliyuncs.com");
|
||||
assertThat(ossProperties.getConfig().getUserAgent()).isEqualTo("alibaba");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClient() {
|
||||
assertThat(ossClient.getEndpoint().toString())
|
||||
.isEqualTo("http://oss-cn-beijing.aliyuncs.com");
|
||||
assertThat(ossClient.getClientConfiguration().getUserAgent())
|
||||
.isEqualTo("alibaba");
|
||||
assertThat(ossClient.getCredentialsProvider().getCredentials().getAccessKeyId())
|
||||
.isEqualTo("your-ak");
|
||||
assertThat(
|
||||
ossClient.getCredentialsProvider().getCredentials().getSecretAccessKey())
|
||||
.isEqualTo("your-sk");
|
||||
}
|
||||
}
|
@ -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.alicloud.oss;
|
||||
|
||||
/**
|
||||
* @author xiaolongzuo
|
||||
*/
|
||||
public class OssAutoConfiguration {
|
||||
}
|
Loading…
Reference in New Issue