From af46fb48de10536f2e4d8f1205eac133c64aa4f9 Mon Sep 17 00:00:00 2001 From: zhangjiawei <349071347@qq.com> Date: Tue, 13 Aug 2024 10:54:42 +0800 Subject: [PATCH 1/2] add unit test --- ...ataClientEnvironmentPostProcessorTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/SeataClientEnvironmentPostProcessorTest.java diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/SeataClientEnvironmentPostProcessorTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/SeataClientEnvironmentPostProcessorTest.java new file mode 100644 index 00000000000..4164a627bb5 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/SeataClientEnvironmentPostProcessorTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.core.Ordered; + +public class SeataClientEnvironmentPostProcessorTest { + + @Test + public void testSeataClientEnvironmentPostProcessor() { + AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext("io.seata.spring.boot.autoconfigure.properties"); + + SeataClientEnvironmentPostProcessor seataClientEnvironmentPostProcessor = new SeataClientEnvironmentPostProcessor(); + seataClientEnvironmentPostProcessor.postProcessEnvironment(applicationContext.getEnvironment(), null); + Assertions.assertEquals(Ordered.HIGHEST_PRECEDENCE, seataClientEnvironmentPostProcessor.getOrder()); + } +} From eff39cb4755a1da36475de585774ca56eb54269b Mon Sep 17 00:00:00 2001 From: zhangjiawei <349071347@qq.com> Date: Wed, 14 Aug 2024 00:20:20 +0800 Subject: [PATCH 2/2] add unit test --- changes/en-us/2.x.md | 2 + changes/zh-cn/2.x.md | 2 + .../SagaAsyncThreadPoolPropertiesTest.java | 36 ++++++++++ .../properties/SeataPropertiesTest.java | 63 ++++++++++++++++ .../SpringCloudAlibabaConfigurationTest.java | 46 ++++++++++++ .../client/LoadBalancePropertiesTest.java | 8 +++ .../properties/client/LockPropertiesTest.java | 36 ++++++++++ .../properties/client/RmPropertiesTest.java | 72 +++++++++++++++++++ .../client/ServicePropertiesTest.java | 67 +++++++++++++++++ .../properties/client/TmPropertiesTest.java | 48 +++++++++++++ .../client/UndoCompressPropertiesTest.java | 36 ++++++++++ .../properties/client/UndoPropertiesTest.java | 39 ++++++++++ .../autoconfigure/BasePropertiesTest.java | 14 ++-- .../properties/LogPropertiesTest.java | 31 ++++++++ .../properties/ShutdownPropertiesTest.java | 30 ++++++++ .../ThreadFactoryPropertiesTest.java | 47 ++++++++++++ .../properties/TransportPropertiesTest.java | 53 ++++++++++++++ .../config/ConfigApolloPropertiesTest.java | 41 +++++++++++ .../config/ConfigConsulPropertiesTest.java | 36 ++++++++++ .../config/ConfigCustomPropertiesTest.java | 31 ++++++++ .../config/ConfigEtcd3PropertiesTest.java | 33 +++++++++ .../config/ConfigFilePropertiesTest.java | 31 ++++++++ .../config/ConfigNacosPropertiesTest.java | 49 +++++++++++++ .../config/ConfigPropertiesTest.java | 33 +++++++++ .../config/ConfigZooKeeperPropertiesTest.java | 41 +++++++++++ .../config/test/ApolloPropertiesTest.java | 58 --------------- .../config/test/ConfigPropertiesTest.java | 50 ------------- .../config/test/ConsulPropertiesTest.java | 51 ------------- .../config/test/CustomPropertiesTest.java | 51 ------------- .../config/test/Etcd3PropertiesTest.java | 50 ------------- .../config/test/FilePropertiesTest.java | 49 ------------- .../config/test/NacosPropertiesTest.java | 55 -------------- .../config/test/ZooKeeperPropertiesTest.java | 55 -------------- .../RegistryConsulPropertiesTest.java | 34 +++++++++ .../RegistryCustomPropertiesTest.java | 30 ++++++++ .../registry/RegistryEtcd3PropertiesTest.java | 32 +++++++++ .../RegistryEurekaPropertiesTest.java | 34 +++++++++ .../registry/RegistryNacosPropertiesTest.java | 55 ++++++++++++++ .../registry/RegistryPropertiesTest.java | 32 +++++++++ .../registry/RegistryRaftPropertiesTest.java | 39 ++++++++++ .../registry/RegistryRedisPropertiesTest.java | 39 ++++++++++ .../registry/RegistrySofaPropertiesTest.java | 43 +++++++++++ .../RegistryZooKeeperPropertiesTest.java | 41 +++++++++++ .../server/MetricsPropertiesTest.java | 37 ++++++++++ .../server/ServerPropertiesTest.java | 51 +++++++++++++ .../server/ServerRaftPropertiesTest.java | 57 +++++++++++++++ .../server/ServerRecoveryPropertiesTest.java | 37 ++++++++++ .../server/ServerUndoPropertiesTest.java | 33 +++++++++ .../server/session/SessionPropertiesTest.java | 33 +++++++++ .../server/store/StoreDBPropertiesTest.java | 57 +++++++++++++++ .../server/store/StoreFilePropertiesTest.java | 41 +++++++++++ .../server/store/StorePropertiesTest.java | 41 +++++++++++ .../store/StoreRedisPropertiesTest.java | 59 +++++++++++++++ 53 files changed, 1743 insertions(+), 426 deletions(-) create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SagaAsyncThreadPoolPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SeataPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SpringCloudAlibabaConfigurationTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LockPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/RmPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/ServicePropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/TmPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoCompressPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/LogPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ShutdownPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ThreadFactoryPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/TransportPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigApolloPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigConsulPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigCustomPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigEtcd3PropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigFilePropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigNacosPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigZooKeeperPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ApolloPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConfigPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConsulPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/CustomPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/Etcd3PropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/FilePropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/NacosPropertiesTest.java delete mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ZooKeeperPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryCustomPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3PropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRaftPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/MetricsPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRaftPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRecoveryPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerUndoPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/session/SessionPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreDBPropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreFilePropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StorePropertiesTest.java create mode 100644 seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisPropertiesTest.java diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 9ccfbcb904a..410df01ed73 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -62,6 +62,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6608](https://github.com/apache/incubator-seata/pull/6608)] add unit test for sql-parser-core - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] improve the test case coverage of saga module to 70% - [[#6695](https://github.com/apache/incubator-seata/pull/6695)] old version(< 0.7.1) client test case for multi-version protocol +- [[#6750](https://github.com/apache/incubator-seata/pull/6750)] increase spring autoconfigure module unit test converage Thanks to these contributors for their code commits. Please report an unintended omission. @@ -88,6 +89,7 @@ Thanks to these contributors for their code commits. Please report an unintended - [caohdgege](https://github.com/caohdgege) - [imashimaro](https://github.com/hmj776521114) - [lyl2008dsg](https://github.com/lyl2008dsg) +- [l81893521](https://github.com/l81893521) Also, we receive many valuable issues, questions and advices from our community. Thanks for you all. diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 1965a9a9516..8ff261d1e40 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -64,6 +64,7 @@ - [[#6608](https://github.com/apache/incubator-seata/pull/6608)] 添加sql-parser-core模块测试用例 - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] 增加saga模块的测试用例覆盖率 - [[#6695](https://github.com/apache/incubator-seata/pull/6695)] 多版本协议的旧版本(< 0.7.1)客户端测试用例 +- [[#6750](https://github.com/apache/incubator-seata/pull/6750)] 提升spring autoconfigure模块单测覆盖率 @@ -93,6 +94,7 @@ - [caohdgege](https://github.com/caohdgege) - [imashimaro](https://github.com/hmj776521114) - [lyl2008dsg](https://github.com/lyl2008dsg) +- [l81893521](https://github.com/l81893521) diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SagaAsyncThreadPoolPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SagaAsyncThreadPoolPropertiesTest.java new file mode 100644 index 00000000000..b3cc5c1136b --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SagaAsyncThreadPoolPropertiesTest.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class SagaAsyncThreadPoolPropertiesTest { + + @Test + public void testSagaAsyncThreadPoolProperties() { + SagaAsyncThreadPoolProperties sagaAsyncThreadPoolProperties = new SagaAsyncThreadPoolProperties(); + sagaAsyncThreadPoolProperties.setCorePoolSize(1); + Assertions.assertEquals(1, sagaAsyncThreadPoolProperties.getCorePoolSize()); + + sagaAsyncThreadPoolProperties.setMaxPoolSize(1); + Assertions.assertEquals(1, sagaAsyncThreadPoolProperties.getMaxPoolSize()); + + sagaAsyncThreadPoolProperties.setKeepAliveTime(1); + Assertions.assertEquals(1, sagaAsyncThreadPoolProperties.getKeepAliveTime()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SeataPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SeataPropertiesTest.java new file mode 100644 index 00000000000..d93ed795738 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SeataPropertiesTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class SeataPropertiesTest { + + @Test + public void testSeataProperties() { + SeataProperties seataProperties = new SeataProperties(); + seataProperties.setEnabled(true); + Assertions.assertTrue(seataProperties.isEnabled()); + + seataProperties.setApplicationId("applicationId"); + Assertions.assertEquals("applicationId", seataProperties.getApplicationId()); + + seataProperties.setTxServiceGroup("group"); + Assertions.assertEquals("group", seataProperties.getTxServiceGroup()); + + seataProperties.setEnableAutoDataSourceProxy(true); + Assertions.assertTrue(seataProperties.isEnableAutoDataSourceProxy()); + + seataProperties.setDataSourceProxyMode("AT"); + Assertions.assertEquals("AT", seataProperties.getDataSourceProxyMode()); + + seataProperties.setUseJdkProxy(true); + Assertions.assertTrue(seataProperties.isUseJdkProxy()); + + String[] excludesForAutoProxying = new String[]{"test"}; + seataProperties.setExcludesForAutoProxying(excludesForAutoProxying); + Assertions.assertEquals(excludesForAutoProxying, seataProperties.getExcludesForAutoProxying()); + + String[] scanPackages = new String[]{"com"}; + seataProperties.setScanPackages(scanPackages); + Assertions.assertEquals(scanPackages, seataProperties.getScanPackages()); + + String[] excludesForScanning = new String[]{"com"}; + seataProperties.setExcludesForScanning(excludesForScanning); + Assertions.assertEquals(excludesForScanning, seataProperties.getExcludesForScanning()); + + seataProperties.setAccessKey("key"); + Assertions.assertEquals("key", seataProperties.getAccessKey()); + + seataProperties.setSecretKey("secret"); + Assertions.assertEquals("secret", seataProperties.getSecretKey()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SpringCloudAlibabaConfigurationTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SpringCloudAlibabaConfigurationTest.java new file mode 100644 index 00000000000..c7e38ca656a --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/SpringCloudAlibabaConfigurationTest.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.core.env.PropertiesPropertySource; + +import java.util.Properties; + +public class SpringCloudAlibabaConfigurationTest { + + @Test + public void testSpringCloudAlibabaConfiguration() { + AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext("org.apache.seata.spring.boot.autoconfigure.properties"); + Properties properties = new Properties(); + properties.setProperty("spring.application.name", "test"); + applicationContext.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("my_test", properties)); + + SpringCloudAlibabaConfiguration springCloudAlibabaConfiguration = (SpringCloudAlibabaConfiguration) applicationContext.getBean("springCloudAlibabaConfiguration"); + + // application id is null + Assertions.assertEquals("test", springCloudAlibabaConfiguration.getApplicationId()); + // application is not null + Assertions.assertEquals("test", springCloudAlibabaConfiguration.getApplicationId()); + Assertions.assertEquals("default_tx_group", springCloudAlibabaConfiguration.getTxServiceGroup()); + springCloudAlibabaConfiguration.setTxServiceGroup("default_tx_group_1"); + Assertions.assertEquals("default_tx_group_1", springCloudAlibabaConfiguration.getTxServiceGroup()); + applicationContext.close(); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LoadBalancePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LoadBalancePropertiesTest.java index c3319caf98c..601ed88165f 100644 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LoadBalancePropertiesTest.java +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LoadBalancePropertiesTest.java @@ -22,6 +22,7 @@ import org.apache.seata.config.FileConfiguration; import org.apache.seata.config.springcloud.SpringApplicationContextProvider; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -61,6 +62,13 @@ public void testLoadBalanceProperties() { assertEquals(30, currentConfiguration.getInt("client.loadBalance.virtualNodes")); System.setProperty("seata.client.loadBalance.type", "test"); assertEquals("test", currentConfiguration.getConfig("client.loadBalance.type")); + + LoadBalanceProperties loadBalanceProperties = new LoadBalanceProperties(); + loadBalanceProperties.setType("type"); + Assertions.assertEquals("type", loadBalanceProperties.getType()); + + loadBalanceProperties.setVirtualNodes(1); + Assertions.assertEquals(1, loadBalanceProperties.getVirtualNodes()); } @AfterAll diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LockPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LockPropertiesTest.java new file mode 100644 index 00000000000..4cb0fa58f8b --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/LockPropertiesTest.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class LockPropertiesTest { + + @Test + public void testLockProperties() { + LockProperties lockProperties = new LockProperties(); + lockProperties.setRetryInterval(1); + Assertions.assertEquals(1, lockProperties.getRetryInterval()); + + lockProperties.setRetryTimes(1); + Assertions.assertEquals(1, lockProperties.getRetryTimes()); + + lockProperties.setRetryPolicyBranchRollbackOnConflict(true); + Assertions.assertEquals(true, lockProperties.isRetryPolicyBranchRollbackOnConflict()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/RmPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/RmPropertiesTest.java new file mode 100644 index 00000000000..d8f3906827c --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/RmPropertiesTest.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RmPropertiesTest { + + @Test + public void testRmProperties() { + RmProperties rmProperties = new RmProperties(); + rmProperties.setAsyncCommitBufferLimit(1); + Assertions.assertEquals(1, rmProperties.getAsyncCommitBufferLimit()); + + rmProperties.setReportRetryCount(1); + Assertions.assertEquals(1, rmProperties.getReportRetryCount()); + + rmProperties.setTableMetaCheckEnable(true); + Assertions.assertTrue(rmProperties.isTableMetaCheckEnable()); + + rmProperties.setReportSuccessEnable(true); + Assertions.assertTrue(rmProperties.isReportSuccessEnable()); + + rmProperties.setSagaBranchRegisterEnable(true); + Assertions.assertTrue(rmProperties.isSagaBranchRegisterEnable()); + + rmProperties.setSagaJsonParser("json"); + Assertions.assertEquals("json", rmProperties.getSagaJsonParser()); + + rmProperties.setTableMetaCheckerInterval(1); + Assertions.assertEquals(1, rmProperties.getTableMetaCheckerInterval()); + + rmProperties.setSagaRetryPersistModeUpdate(true); + Assertions.assertTrue(rmProperties.isSagaRetryPersistModeUpdate()); + + rmProperties.setSagaCompensatePersistModeUpdate(true); + Assertions.assertTrue(rmProperties.isSagaCompensatePersistModeUpdate()); + + rmProperties.setTccActionInterceptorOrder(1); + Assertions.assertEquals(1, rmProperties.getTccActionInterceptorOrder()); + + rmProperties.setSqlParserType("type"); + Assertions.assertEquals("type", rmProperties.getSqlParserType()); + + rmProperties.setBranchExecutionTimeoutXA(1); + Assertions.assertEquals(1, rmProperties.getBranchExecutionTimeoutXA()); + + rmProperties.setConnectionTwoPhaseHoldTimeoutXA(1); + Assertions.assertEquals(1, rmProperties.getConnectionTwoPhaseHoldTimeoutXA()); + + rmProperties.setApplicationDataLimitCheck(true); + Assertions.assertTrue(rmProperties.getApplicationDataLimitCheck()); + + rmProperties.setApplicationDataLimit(1); + Assertions.assertEquals(1, rmProperties.getApplicationDataLimit()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/ServicePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/ServicePropertiesTest.java new file mode 100644 index 00000000000..d0f1975a032 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/ServicePropertiesTest.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.Map; + +public class ServicePropertiesTest { + + @Test + public void testServiceProperties() { + ServiceProperties serviceProperties = new ServiceProperties(); + + Map vGroupMapping = new HashMap<>(); + vGroupMapping.put("default_tx_group", "default"); + serviceProperties.setVgroupMapping(vGroupMapping); + Assertions.assertEquals("default", serviceProperties.getVgroupMapping().get("default_tx_group")); + + Map groupList = new HashMap<>(); + groupList.put("default", "127.0.0.1:8091"); + serviceProperties.setGrouplist(groupList); + Assertions.assertEquals("127.0.0.1:8091", serviceProperties.getGrouplist().get("default")); + + serviceProperties.setDisableGlobalTransaction(true); + Assertions.assertTrue(serviceProperties.isDisableGlobalTransaction()); + } + + @Test + public void testAfterPropertiesSet() throws Exception { + ServiceProperties serviceProperties = new ServiceProperties(); + serviceProperties.afterPropertiesSet(); + Assertions.assertEquals("default", serviceProperties.getVgroupMapping().get("default_tx_group")); + Assertions.assertEquals("default", serviceProperties.getVgroupMapping().get("my_test_tx_group")); + Assertions.assertEquals("127.0.0.1:8091", serviceProperties.getGrouplist().get("default")); + + serviceProperties = new ServiceProperties(); + + Map vGroupMapping = new HashMap<>(); + vGroupMapping.put("default_tx_group", "default"); + serviceProperties.setVgroupMapping(vGroupMapping); + + Map groupList = new HashMap<>(); + groupList.put("default", "127.0.0.1:8091"); + serviceProperties.setGrouplist(groupList); + + serviceProperties.afterPropertiesSet(); + Assertions.assertEquals("default", serviceProperties.getVgroupMapping().get("default_tx_group")); + Assertions.assertEquals("127.0.0.1:8091", serviceProperties.getGrouplist().get("default")); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/TmPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/TmPropertiesTest.java new file mode 100644 index 00000000000..f9e8b92e310 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/TmPropertiesTest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class TmPropertiesTest { + + @Test + public void testTmProperties() { + TmProperties tmProperties = new TmProperties(); + tmProperties.setCommitRetryCount(1); + Assertions.assertEquals(1, tmProperties.getCommitRetryCount()); + + tmProperties.setRollbackRetryCount(1); + Assertions.assertEquals(1, tmProperties.getRollbackRetryCount()); + + tmProperties.setDefaultGlobalTransactionTimeout(1); + Assertions.assertEquals(1, tmProperties.getDefaultGlobalTransactionTimeout()); + + tmProperties.setDegradeCheck(true); + Assertions.assertTrue(tmProperties.isDegradeCheck()); + + tmProperties.setDegradeCheckPeriod(1); + Assertions.assertEquals(1, tmProperties.getDegradeCheckPeriod()); + + tmProperties.setDegradeCheckAllowTimes(1); + Assertions.assertEquals(1, tmProperties.getDegradeCheckAllowTimes()); + + tmProperties.setInterceptorOrder(1); + Assertions.assertEquals(1, tmProperties.getInterceptorOrder()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoCompressPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoCompressPropertiesTest.java new file mode 100644 index 00000000000..66d084f3fc7 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoCompressPropertiesTest.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UndoCompressPropertiesTest { + + @Test + public void testUndoCompressProperties() { + UndoCompressProperties undoCompressProperties = new UndoCompressProperties(); + undoCompressProperties.setEnable(true); + Assertions.assertTrue(undoCompressProperties.isEnable()); + + undoCompressProperties.setType("type"); + Assertions.assertEquals("type", undoCompressProperties.getType()); + + undoCompressProperties.setThreshold("threshold"); + Assertions.assertEquals("threshold", undoCompressProperties.getThreshold()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoPropertiesTest.java new file mode 100644 index 00000000000..fed185b03fb --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/client/UndoPropertiesTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.client; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UndoPropertiesTest { + + @Test + public void testUndoProperties() { + UndoProperties undoProperties = new UndoProperties(); + undoProperties.setDataValidation(true); + Assertions.assertTrue(undoProperties.isDataValidation()); + + undoProperties.setLogSerialization("jackson"); + Assertions.assertEquals("jackson", undoProperties.getLogSerialization()); + + undoProperties.setLogTable("table"); + Assertions.assertEquals("table", undoProperties.getLogTable()); + + undoProperties.setOnlyCareUpdateColumns(true); + Assertions.assertTrue(undoProperties.isOnlyCareUpdateColumns()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/BasePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/BasePropertiesTest.java index 06ada82a929..d4a0b899548 100644 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/BasePropertiesTest.java +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/BasePropertiesTest.java @@ -34,7 +34,7 @@ public class BasePropertiesTest { - protected static AnnotationConfigApplicationContext applicationContex; + protected static AnnotationConfigApplicationContext applicationContext; protected static final String STR_TEST_AAA = "aaa"; protected static final String STR_TEST_BBB = "bbb"; protected static final String STR_TEST_CCC = "ccc"; @@ -47,28 +47,28 @@ public class BasePropertiesTest { @BeforeEach public void setUp() throws IOException { - applicationContex = new AnnotationConfigApplicationContext( + applicationContext = new AnnotationConfigApplicationContext( new String[] {"org.apache.seata.spring.boot.autoconfigure.properties.config.test"}); SeataCoreEnvironmentPostProcessor processor = new SeataCoreEnvironmentPostProcessor(); processor.postProcessEnvironment(null, null); // set new applicationContex for test cases in extension test classes - ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_APPLICATION_CONTEXT, applicationContex); - ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT, applicationContex.getEnvironment()); + ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_APPLICATION_CONTEXT, applicationContext); + ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT, applicationContext.getEnvironment()); Properties properties=new Properties(); ClassLoader classLoader = getClass().getClassLoader(); File f = new File(classLoader.getResource("application-test.properties").getFile()); try(InputStream in =new FileInputStream(f)) { properties.load(in); } - applicationContex.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("serverProperties", properties)); + applicationContext.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("serverProperties", properties)); } @AfterEach public void closeContext() { - if(applicationContex!=null) { - applicationContex.close(); + if(applicationContext!=null) { + applicationContext.close(); } } diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/LogPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/LogPropertiesTest.java new file mode 100644 index 00000000000..7bb55b7017d --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/LogPropertiesTest.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class LogPropertiesTest { + + @Test + public void testLogProperties() { + LogProperties logProperties = new LogProperties(); + logProperties.setExceptionRate(1); + + Assertions.assertEquals(1, logProperties.getExceptionRate()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ShutdownPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ShutdownPropertiesTest.java new file mode 100644 index 00000000000..3cd44014f3e --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ShutdownPropertiesTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ShutdownPropertiesTest { + + @Test + public void testShutdownProperties() { + ShutdownProperties shutdownProperties = new ShutdownProperties(); + shutdownProperties.setWait(1); + Assertions.assertEquals(1, shutdownProperties.getWait()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ThreadFactoryPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ThreadFactoryPropertiesTest.java new file mode 100644 index 00000000000..97e77ff529a --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/ThreadFactoryPropertiesTest.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ThreadFactoryPropertiesTest { + + @Test + public void testThreadFactoryProperties() { + ThreadFactoryProperties threadFactoryProperties = new ThreadFactoryProperties(); + threadFactoryProperties.setBossThreadPrefix("boss"); + threadFactoryProperties.setWorkerThreadPrefix("worker"); + threadFactoryProperties.setWorkerThreadSize("1"); + threadFactoryProperties.setClientSelectorThreadPrefix("prefix"); + threadFactoryProperties.setClientWorkerThreadPrefix("prefix"); + threadFactoryProperties.setServerExecutorThreadPrefix("prefix"); + threadFactoryProperties.setBossThreadSize(1); + threadFactoryProperties.setClientSelectorThreadSize(1); + threadFactoryProperties.setShareBossWorker(true); + + Assertions.assertEquals("boss", threadFactoryProperties.getBossThreadPrefix()); + Assertions.assertEquals("worker", threadFactoryProperties.getWorkerThreadPrefix()); + Assertions.assertEquals("1", threadFactoryProperties.getWorkerThreadSize()); + Assertions.assertEquals("prefix", threadFactoryProperties.getClientSelectorThreadPrefix()); + Assertions.assertEquals("prefix", threadFactoryProperties.getClientWorkerThreadPrefix()); + Assertions.assertEquals("prefix", threadFactoryProperties.getServerExecutorThreadPrefix()); + Assertions.assertEquals(1, threadFactoryProperties.getBossThreadSize()); + Assertions.assertEquals(1, threadFactoryProperties.getClientSelectorThreadSize()); + Assertions.assertEquals(true, threadFactoryProperties.isShareBossWorker()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/TransportPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/TransportPropertiesTest.java new file mode 100644 index 00000000000..3bb56b1cc44 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/TransportPropertiesTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class TransportPropertiesTest { + + @Test + public void testTransportProperties() { + TransportProperties transportProperties = new TransportProperties(); + transportProperties.setServer("server"); + transportProperties.setType("type"); + transportProperties.setSerialization("serialization"); + transportProperties.setCompressor("compressor"); + transportProperties.setHeartbeat(true); + transportProperties.setEnableClientBatchSendRequest(true); + transportProperties.setEnableRmClientBatchSendRequest(true); + transportProperties.setEnableTmClientBatchSendRequest(true); + transportProperties.setEnableTcServerBatchSendResponse(true); + transportProperties.setRpcRmRequestTimeout(1); + transportProperties.setRpcTmRequestTimeout(1); + transportProperties.setRpcTcRequestTimeout(1); + + Assertions.assertEquals("server", transportProperties.getServer()); + Assertions.assertEquals("type", transportProperties.getType()); + Assertions.assertEquals("serialization", transportProperties.getSerialization()); + Assertions.assertEquals("compressor", transportProperties.getCompressor()); + Assertions.assertTrue(transportProperties.isHeartbeat()); + Assertions.assertTrue(transportProperties.isEnableClientBatchSendRequest()); + Assertions.assertTrue(transportProperties.isEnableRmClientBatchSendRequest()); + Assertions.assertTrue(transportProperties.isEnableTmClientBatchSendRequest()); + Assertions.assertTrue(transportProperties.isEnableTcServerBatchSendResponse()); + Assertions.assertEquals(1, transportProperties.getRpcRmRequestTimeout()); + Assertions.assertEquals(1, transportProperties.getRpcTmRequestTimeout()); + Assertions.assertEquals(1, transportProperties.getRpcTcRequestTimeout()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigApolloPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigApolloPropertiesTest.java new file mode 100644 index 00000000000..854b49bbee9 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigApolloPropertiesTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigApolloPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigApolloProperties() { + ConfigApolloProperties configApolloProperties = new ConfigApolloProperties(); + configApolloProperties.setApolloMeta(STR_TEST_AAA); + Assertions.assertEquals(configApolloProperties.getApolloMeta(), STR_TEST_AAA); + configApolloProperties.setApolloAccessKeySecret(STR_TEST_BBB); + Assertions.assertEquals(configApolloProperties.getApolloAccessKeySecret(), STR_TEST_BBB); + configApolloProperties.setAppId(STR_TEST_CCC); + Assertions.assertEquals(configApolloProperties.getAppId(), STR_TEST_CCC); + configApolloProperties.setNamespace(STR_TEST_DDD); + Assertions.assertEquals(configApolloProperties.getNamespace(), STR_TEST_DDD); + configApolloProperties.setCluster(STR_TEST_EEE); + Assertions.assertEquals(configApolloProperties.getCluster(), STR_TEST_EEE); + configApolloProperties.setApolloConfigService(STR_TEST_FFF); + Assertions.assertEquals(configApolloProperties.getApolloConfigService(), STR_TEST_FFF); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigConsulPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigConsulPropertiesTest.java new file mode 100644 index 00000000000..4c87ee3c3db --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigConsulPropertiesTest.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigConsulPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigConsulProperties() { + + ConfigConsulProperties configConsulProperties = new ConfigConsulProperties(); + configConsulProperties.setServerAddr(STR_TEST_AAA); + Assertions.assertEquals(STR_TEST_AAA, configConsulProperties.getServerAddr()); + configConsulProperties.setAclToken(STR_TEST_BBB); + Assertions.assertEquals(STR_TEST_BBB, configConsulProperties.getAclToken()); + configConsulProperties.setKey(STR_TEST_CCC); + Assertions.assertEquals(STR_TEST_CCC, configConsulProperties.getKey()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigCustomPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigCustomPropertiesTest.java new file mode 100644 index 00000000000..9bfc46aa59d --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigCustomPropertiesTest.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigCustomPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigCustomProperties() { + ConfigCustomProperties configCustomProperties = new ConfigCustomProperties(); + configCustomProperties.setName(STR_TEST_AAA); + Assertions.assertEquals(STR_TEST_AAA, configCustomProperties.getName()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigEtcd3PropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigEtcd3PropertiesTest.java new file mode 100644 index 00000000000..f790e14d363 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigEtcd3PropertiesTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigEtcd3PropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigEtcd3Properties() { + ConfigEtcd3Properties configEtcd3Properties = new ConfigEtcd3Properties(); + configEtcd3Properties.setKey(STR_TEST_AAA); + configEtcd3Properties.setServerAddr(STR_TEST_BBB); + Assertions.assertEquals(STR_TEST_AAA, configEtcd3Properties.getKey()); + Assertions.assertEquals(STR_TEST_BBB, configEtcd3Properties.getServerAddr()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigFilePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigFilePropertiesTest.java new file mode 100644 index 00000000000..558dcd7b356 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigFilePropertiesTest.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigFilePropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigFileProperties() { + ConfigFileProperties configFileProperties = new ConfigFileProperties(); + configFileProperties.setName(STR_TEST_AAA); + Assertions.assertEquals(STR_TEST_AAA, configFileProperties.getName()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigNacosPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigNacosPropertiesTest.java new file mode 100644 index 00000000000..af486a6d84f --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigNacosPropertiesTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigNacosPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigNacosProperties() { + ConfigNacosProperties configNacosProperties = new ConfigNacosProperties(); + configNacosProperties.setServerAddr("addr"); + configNacosProperties.setAccessKey("key"); + configNacosProperties.setSecretKey("key"); + configNacosProperties.setNamespace("namespace"); + configNacosProperties.setUsername("username"); + configNacosProperties.setPassword("password"); + configNacosProperties.setContextPath("path"); + configNacosProperties.setRamRoleName("ram"); + configNacosProperties.setGroup("group"); + configNacosProperties.setDataId("dataId"); + Assertions.assertEquals("addr", configNacosProperties.getServerAddr()); + Assertions.assertEquals("key", configNacosProperties.getAccessKey()); + Assertions.assertEquals("key", configNacosProperties.getSecretKey()); + Assertions.assertEquals("namespace", configNacosProperties.getNamespace()); + Assertions.assertEquals("username", configNacosProperties.getUsername()); + Assertions.assertEquals("password", configNacosProperties.getPassword()); + Assertions.assertEquals("path", configNacosProperties.getContextPath()); + Assertions.assertEquals("ram", configNacosProperties.getRamRoleName()); + Assertions.assertEquals("group", configNacosProperties.getGroup()); + Assertions.assertEquals("dataId", configNacosProperties.getDataId()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigPropertiesTest.java new file mode 100644 index 00000000000..561aac3fdf5 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigPropertiesTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigFileProperties() { + ConfigProperties configProperties = new ConfigProperties(); + configProperties.setDataType(STR_TEST_AAA); + configProperties.setType(STR_TEST_BBB); + Assertions.assertEquals(STR_TEST_AAA, configProperties.getDataType()); + Assertions.assertEquals(STR_TEST_BBB, configProperties.getType()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigZooKeeperPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigZooKeeperPropertiesTest.java new file mode 100644 index 00000000000..0e746b9e162 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/ConfigZooKeeperPropertiesTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config; + +import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ConfigZooKeeperPropertiesTest extends BasePropertiesTest { + + @Test + public void testConfigZooKeeperProperties() { + ConfigZooKeeperProperties configZooKeeperProperties = new ConfigZooKeeperProperties(); + configZooKeeperProperties.setServerAddr(STR_TEST_AAA); + configZooKeeperProperties.setNodePath(STR_TEST_BBB); + configZooKeeperProperties.setUsername(STR_TEST_CCC); + configZooKeeperProperties.setPassword(STR_TEST_DDD); + configZooKeeperProperties.setConnectTimeout(LONG_TEST_ONE); + configZooKeeperProperties.setSessionTimeout(LONG_TEST_TWO); + Assertions.assertEquals(STR_TEST_AAA, configZooKeeperProperties.getServerAddr()); + Assertions.assertEquals(STR_TEST_BBB, configZooKeeperProperties.getNodePath()); + Assertions.assertEquals(STR_TEST_CCC, configZooKeeperProperties.getUsername()); + Assertions.assertEquals(STR_TEST_DDD, configZooKeeperProperties.getPassword()); + Assertions.assertEquals(LONG_TEST_ONE, configZooKeeperProperties.getConnectTimeout()); + Assertions.assertEquals(LONG_TEST_TWO, configZooKeeperProperties.getSessionTimeout()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ApolloPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ApolloPropertiesTest.java deleted file mode 100644 index 48d3aa71fd7..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ApolloPropertiesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.config.apollo.ApolloConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigApolloProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -class ApolloPropertiesTest extends BasePropertiesTest { - - @Bean("testConfigApolloProperties") - public ConfigApolloProperties configApolloProperties() { - return new ConfigApolloProperties().setApolloMeta(STR_TEST_AAA).setApolloAccessKeySecret(STR_TEST_BBB).setAppId( - STR_TEST_CCC).setNamespace(STR_TEST_DDD).setCluster(STR_TEST_EEE).setApolloConfigService(STR_TEST_FFF); - } - - @Test - public void testConfigApolloProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide( - configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig(ApolloConfiguration.getApolloMetaFileKey())); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig(ApolloConfiguration.getApolloSecretFileKey())); - assertEquals(STR_TEST_CCC, currentConfiguration.getConfig(ApolloConfiguration.getApolloAppIdFileKey())); - assertEquals(STR_TEST_DDD, currentConfiguration.getConfig(ApolloConfiguration.getApolloNamespaceKey())); - assertEquals(STR_TEST_EEE, currentConfiguration.getConfig(ApolloConfiguration.getApolloCluster())); - assertEquals(STR_TEST_FFF, currentConfiguration.getConfig(ApolloConfiguration.getApolloConfigService())); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConfigPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConfigPropertiesTest.java deleted file mode 100644 index 8721bed5126..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConfigPropertiesTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class ConfigPropertiesTest extends BasePropertiesTest { - @Bean("testConfigProperties") - public ConfigProperties configProperties() { - return new ConfigProperties().setType(STR_TEST_AAA).setDataType(STR_TEST_BBB); - } - - @Test - public void testConfigFileProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals("file", currentConfiguration.getConfig("config.type")); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig("config.dataType")); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConsulPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConsulPropertiesTest.java deleted file mode 100644 index a215a8ebd45..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ConsulPropertiesTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigConsulProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class ConsulPropertiesTest extends BasePropertiesTest { - @Bean("testConfigConsulProperties") - public ConfigConsulProperties configConsulProperties() { - return new ConfigConsulProperties().setServerAddr(STR_TEST_AAA).setAclToken(STR_TEST_BBB).setKey(STR_TEST_CCC); - } - - @Test - public void testConfigConsulProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig("config.consul.serverAddr")); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig("config.consul.aclToken")); - assertEquals(STR_TEST_CCC, currentConfiguration.getConfig("config.consul.key")); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/CustomPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/CustomPropertiesTest.java deleted file mode 100644 index f5b8ecfeb63..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/CustomPropertiesTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigCustomProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class CustomPropertiesTest extends BasePropertiesTest { - - @Bean("testConfigCustomProperties") - public ConfigCustomProperties configCustomProperties() { - return new ConfigCustomProperties().setName(STR_TEST_AAA); - } - - @Test - public void testConfigCustomProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig("config.custom.name")); - } - -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/Etcd3PropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/Etcd3PropertiesTest.java deleted file mode 100644 index b9aee79d430..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/Etcd3PropertiesTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigEtcd3Properties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class Etcd3PropertiesTest extends BasePropertiesTest { - @Bean("testConfigEtcd3Properties") - public ConfigEtcd3Properties configEtcd3Properties() { - return new ConfigEtcd3Properties().setServerAddr(STR_TEST_AAA).setKey(STR_TEST_BBB); - } - - @Test - public void testConfigEtcd3Properties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig("config.etcd3.serverAddr")); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig("config.etcd3.key")); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/FilePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/FilePropertiesTest.java deleted file mode 100644 index d842587948b..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/FilePropertiesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigFileProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class FilePropertiesTest extends BasePropertiesTest { - @Bean("testConfigFileProperties") - public ConfigFileProperties configFileProperties() { - return new ConfigFileProperties().setName(STR_TEST_AAA); - } - - @Test - public void testConfigFileProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig("config.file.name")); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/NacosPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/NacosPropertiesTest.java deleted file mode 100644 index b28db301970..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/NacosPropertiesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.config.nacos.NacosConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigNacosProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class NacosPropertiesTest extends BasePropertiesTest { - @Bean("testConfigNacosProperties") - public ConfigNacosProperties configNacosProperties() { - return new ConfigNacosProperties().setServerAddr(STR_TEST_AAA).setDataId(STR_TEST_BBB).setGroup(STR_TEST_CCC).setNamespace(STR_TEST_DDD).setUsername(STR_TEST_EEE).setPassword(STR_TEST_FFF); - } - - @Test - public void testConfigNacosProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig(NacosConfiguration.getNacosAddrFileKey())); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig(NacosConfiguration.getNacosDataIdKey())); - assertEquals(STR_TEST_CCC, currentConfiguration.getConfig(NacosConfiguration.getNacosGroupKey())); - assertEquals(STR_TEST_DDD, currentConfiguration.getConfig(NacosConfiguration.getNacosNameSpaceFileKey())); - assertEquals(STR_TEST_EEE, currentConfiguration.getConfig(NacosConfiguration.getNacosUserName())); - assertEquals(STR_TEST_FFF, currentConfiguration.getConfig(NacosConfiguration.getNacosPassword())); - } -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ZooKeeperPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ZooKeeperPropertiesTest.java deleted file mode 100644 index a2994ec083b..00000000000 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/config/test/ZooKeeperPropertiesTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.config.test; - -import org.apache.seata.common.loader.EnhancedServiceLoader; -import org.apache.seata.config.Configuration; -import org.apache.seata.config.ExtConfigurationProvider; -import org.apache.seata.config.FileConfiguration; -import org.apache.seata.spring.boot.autoconfigure.BasePropertiesTest; -import org.apache.seata.spring.boot.autoconfigure.properties.config.ConfigZooKeeperProperties; -import org.apache.seata.spring.boot.autoconfigure.provider.SpringApplicationContextProvider; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - - -@org.springframework.context.annotation.Configuration -@Import(SpringApplicationContextProvider.class) -public class ZooKeeperPropertiesTest extends BasePropertiesTest { - @Bean("testConfigZooKeeperProperties") - public ConfigZooKeeperProperties configZooKeeperProperties() { - return new ConfigZooKeeperProperties().setNodePath(STR_TEST_AAA).setServerAddr(STR_TEST_BBB).setUsername(STR_TEST_CCC).setPassword(STR_TEST_DDD).setConnectTimeout(LONG_TEST_ONE).setSessionTimeout(LONG_TEST_TWO); - } - - @Test - public void testConfigZooKeeperProperties() { - FileConfiguration configuration = mock(FileConfiguration.class); - Configuration currentConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration); - - assertEquals(STR_TEST_AAA, currentConfiguration.getConfig("config.zk.nodePath")); - assertEquals(STR_TEST_BBB, currentConfiguration.getConfig("config.zk.serverAddr")); - assertEquals(STR_TEST_CCC, currentConfiguration.getConfig("config.zk.username")); - assertEquals(STR_TEST_DDD, currentConfiguration.getConfig("config.zk.password")); - assertEquals(LONG_TEST_ONE, currentConfiguration.getInt("config.zk.connectTimeout")); - assertEquals(LONG_TEST_TWO, currentConfiguration.getInt("config.zk.sessionTimeout")); - } - -} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulPropertiesTest.java new file mode 100644 index 00000000000..cc3302e495b --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryConsulPropertiesTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryConsulPropertiesTest { + + @Test + public void testRegistryConsulProperties() { + RegistryConsulProperties registryConsulProperties = new RegistryConsulProperties(); + registryConsulProperties.setServerAddr("server"); + registryConsulProperties.setAclToken("acl"); + registryConsulProperties.setCluster("cluster"); + Assertions.assertEquals("server", registryConsulProperties.getServerAddr()); + Assertions.assertEquals("acl", registryConsulProperties.getAclToken()); + Assertions.assertEquals("cluster", registryConsulProperties.getCluster()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryCustomPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryCustomPropertiesTest.java new file mode 100644 index 00000000000..d2ed81c3194 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryCustomPropertiesTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryCustomPropertiesTest { + + @Test + public void testRegistryCustomProperties() { + RegistryCustomProperties registryCustomProperties = new RegistryCustomProperties(); + registryCustomProperties.setName("name"); + Assertions.assertEquals("name", registryCustomProperties.getName()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3PropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3PropertiesTest.java new file mode 100644 index 00000000000..44307ddd705 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEtcd3PropertiesTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryEtcd3PropertiesTest { + + @Test + public void testRegistryEtcd3Properties() { + RegistryEtcd3Properties registryEtcd3Properties = new RegistryEtcd3Properties(); + registryEtcd3Properties.setServerAddr("server"); + registryEtcd3Properties.setCluster("cluster"); + Assertions.assertEquals("server", registryEtcd3Properties.getServerAddr()); + Assertions.assertEquals("cluster", registryEtcd3Properties.getCluster()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaPropertiesTest.java new file mode 100644 index 00000000000..405349c60e9 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryEurekaPropertiesTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryEurekaPropertiesTest { + + @Test + public void testRegistryEurekaProperties() { + RegistryEurekaProperties registryEurekaProperties = new RegistryEurekaProperties(); + registryEurekaProperties.setApplication("application"); + registryEurekaProperties.setServiceUrl("url"); + registryEurekaProperties.setWeight("1"); + Assertions.assertEquals("application", registryEurekaProperties.getApplication()); + Assertions.assertEquals("url", registryEurekaProperties.getServiceUrl()); + Assertions.assertEquals("1", registryEurekaProperties.getWeight()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosPropertiesTest.java new file mode 100644 index 00000000000..96117672b6a --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryNacosPropertiesTest.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryNacosPropertiesTest { + + @Test + public void testRegistryNacosProperties() { + RegistryNacosProperties registryNacosProperties = new RegistryNacosProperties(); + registryNacosProperties.setServerAddr("addr"); + registryNacosProperties.setAccessKey("key"); + registryNacosProperties.setSecretKey("key"); + registryNacosProperties.setNamespace("namespace"); + registryNacosProperties.setUsername("username"); + registryNacosProperties.setPassword("password"); + registryNacosProperties.setContextPath("path"); + registryNacosProperties.setRamRoleName("ram"); + registryNacosProperties.setGroup("group"); + registryNacosProperties.setApplication("application"); + registryNacosProperties.setClientApplication("client"); + registryNacosProperties.setCluster("cluster"); + registryNacosProperties.setSlbPattern("slb"); + + Assertions.assertEquals("addr", registryNacosProperties.getServerAddr()); + Assertions.assertEquals("key", registryNacosProperties.getAccessKey()); + Assertions.assertEquals("key", registryNacosProperties.getSecretKey()); + Assertions.assertEquals("namespace", registryNacosProperties.getNamespace()); + Assertions.assertEquals("username", registryNacosProperties.getUsername()); + Assertions.assertEquals("password", registryNacosProperties.getPassword()); + Assertions.assertEquals("path", registryNacosProperties.getContextPath()); + Assertions.assertEquals("ram", registryNacosProperties.getRamRoleName()); + Assertions.assertEquals("group", registryNacosProperties.getGroup()); + Assertions.assertEquals("application", registryNacosProperties.getApplication()); + Assertions.assertEquals("client", registryNacosProperties.getClientApplication()); + Assertions.assertEquals("cluster", registryNacosProperties.getCluster()); + Assertions.assertEquals("slb", registryNacosProperties.getSlbPattern()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryPropertiesTest.java new file mode 100644 index 00000000000..e84f875942d --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryPropertiesTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryPropertiesTest { + + @Test + public void testRegistryProperties() { + RegistryProperties registryProperties = new RegistryProperties(); + registryProperties.setType("type"); + registryProperties.setPreferredNetworks("network"); + Assertions.assertEquals("type", registryProperties.getType()); + Assertions.assertEquals("network", registryProperties.getPreferredNetworks()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRaftPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRaftPropertiesTest.java new file mode 100644 index 00000000000..fede752d6df --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRaftPropertiesTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryRaftPropertiesTest { + + @Test + public void testRegistryRaftProperties() { + RegistryRaftProperties registryRaftProperties = new RegistryRaftProperties(); + registryRaftProperties.setServerAddr("server"); + registryRaftProperties.setUsername("username"); + registryRaftProperties.setPassword("pwd"); + registryRaftProperties.setMetadataMaxAgeMs(1L); + registryRaftProperties.setTokenValidityInMilliseconds(1L); + + Assertions.assertEquals("server", registryRaftProperties.getServerAddr()); + Assertions.assertEquals("username", registryRaftProperties.getUsername()); + Assertions.assertEquals("pwd", registryRaftProperties.getPassword()); + Assertions.assertEquals(1L, registryRaftProperties.getMetadataMaxAgeMs()); + Assertions.assertEquals(1L, registryRaftProperties.getTokenValidityInMilliseconds()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisPropertiesTest.java new file mode 100644 index 00000000000..c3f55a45c8a --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryRedisPropertiesTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryRedisPropertiesTest { + + @Test + public void testRegistryRedisProperties() { + RegistryRedisProperties registryRedisProperties = new RegistryRedisProperties(); + registryRedisProperties.setServerAddr("server"); + registryRedisProperties.setDb(1); + registryRedisProperties.setPassword("pwd"); + registryRedisProperties.setCluster("cluster"); + registryRedisProperties.setTimeout(1); + + Assertions.assertEquals("server", registryRedisProperties.getServerAddr()); + Assertions.assertEquals(1, registryRedisProperties.getDb()); + Assertions.assertEquals("pwd", registryRedisProperties.getPassword()); + Assertions.assertEquals("cluster", registryRedisProperties.getCluster()); + Assertions.assertEquals(1, registryRedisProperties.getTimeout()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaPropertiesTest.java new file mode 100644 index 00000000000..5246db3227c --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistrySofaPropertiesTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistrySofaPropertiesTest { + + @Test + public void testRegistrySofaProperties() { + RegistrySofaProperties registrySofaProperties = new RegistrySofaProperties(); + registrySofaProperties.setServerAddr("server"); + registrySofaProperties.setCluster("cluster"); + registrySofaProperties.setRegion("region"); + registrySofaProperties.setApplication("application"); + registrySofaProperties.setDatacenter("datacenter"); + registrySofaProperties.setAddressWaitTime("time"); + registrySofaProperties.setGroup("group"); + + Assertions.assertEquals("server", registrySofaProperties.getServerAddr()); + Assertions.assertEquals("cluster", registrySofaProperties.getCluster()); + Assertions.assertEquals("region", registrySofaProperties.getRegion()); + Assertions.assertEquals("application", registrySofaProperties.getApplication()); + Assertions.assertEquals("datacenter", registrySofaProperties.getDatacenter()); + Assertions.assertEquals("time", registrySofaProperties.getAddressWaitTime()); + Assertions.assertEquals("group", registrySofaProperties.getGroup()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperPropertiesTest.java new file mode 100644 index 00000000000..9532af542df --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/registry/RegistryZooKeeperPropertiesTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.registry; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryZooKeeperPropertiesTest { + + @Test + public void testRegistryZooKeeperProperties() { + RegistryZooKeeperProperties registryZooKeeperProperties = new RegistryZooKeeperProperties(); + registryZooKeeperProperties.setServerAddr("server"); + registryZooKeeperProperties.setCluster("cluster"); + registryZooKeeperProperties.setUsername("username"); + registryZooKeeperProperties.setPassword("pwd"); + registryZooKeeperProperties.setConnectTimeout(1); + registryZooKeeperProperties.setSessionTimeout(1); + + Assertions.assertEquals("server", registryZooKeeperProperties.getServerAddr()); + Assertions.assertEquals("cluster", registryZooKeeperProperties.getCluster()); + Assertions.assertEquals("username", registryZooKeeperProperties.getUsername()); + Assertions.assertEquals("pwd", registryZooKeeperProperties.getPassword()); + Assertions.assertEquals(1, registryZooKeeperProperties.getConnectTimeout()); + Assertions.assertEquals(1, registryZooKeeperProperties.getSessionTimeout()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/MetricsPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/MetricsPropertiesTest.java new file mode 100644 index 00000000000..85335f61b64 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/MetricsPropertiesTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class MetricsPropertiesTest { + + @Test + public void testMetricsProperties() { + MetricsProperties metricsProperties = new MetricsProperties(); + metricsProperties.setRegistryType("type"); + metricsProperties.setExporterList("list"); + metricsProperties.setEnabled(true); + metricsProperties.setExporterPrometheusPort(1); + + Assertions.assertEquals("type", metricsProperties.getRegistryType()); + Assertions.assertEquals("list", metricsProperties.getExporterList()); + Assertions.assertTrue(metricsProperties.getEnabled()); + Assertions.assertEquals(1, metricsProperties.getExporterPrometheusPort()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerPropertiesTest.java new file mode 100644 index 00000000000..fc9161a07ce --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerPropertiesTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ServerPropertiesTest { + + @Test + public void testMetricsProperties() { + ServerProperties serverProperties = new ServerProperties(); + serverProperties.setXaerNotaRetryTimeout(1); + serverProperties.setRetryDeadThreshold(1); + serverProperties.setApplicationDataLimit(1); + serverProperties.setServicePort(1); + serverProperties.setEnableCheckAuth(true); + serverProperties.setApplicationDataLimitCheck(true); + serverProperties.setEnableParallelHandleBranch(true); + serverProperties.setEnableParallelRequestHandle(true); + serverProperties.setRollbackRetryTimeoutUnlockEnable(true); + serverProperties.setMaxCommitRetryTimeout(1L); + serverProperties.setMaxRollbackRetryTimeout(1L); + + Assertions.assertEquals(1, serverProperties.getXaerNotaRetryTimeout()); + Assertions.assertEquals(1, serverProperties.getRetryDeadThreshold()); + Assertions.assertEquals(1, serverProperties.getApplicationDataLimit()); + Assertions.assertEquals(1, serverProperties.getServicePort()); + Assertions.assertTrue(serverProperties.getEnableCheckAuth()); + Assertions.assertTrue(serverProperties.getApplicationDataLimitCheck()); + Assertions.assertTrue(serverProperties.getEnableParallelHandleBranch()); + Assertions.assertTrue(serverProperties.getEnableParallelRequestHandle()); + Assertions.assertTrue(serverProperties.getRollbackRetryTimeoutUnlockEnable()); + Assertions.assertEquals(1L, serverProperties.getMaxCommitRetryTimeout()); + Assertions.assertEquals(1L, serverProperties.getMaxRollbackRetryTimeout()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRaftPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRaftPropertiesTest.java new file mode 100644 index 00000000000..7c7e76892c6 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRaftPropertiesTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ServerRaftPropertiesTest { + + @Test + public void testServerRaftProperties() { + ServerRaftProperties serverRaftProperties = new ServerRaftProperties(); + serverRaftProperties.setServerAddr("server"); + serverRaftProperties.setGroup("group"); + serverRaftProperties.setCompressor("compressor"); + serverRaftProperties.setSerialization("serialization"); + serverRaftProperties.setApplyBatch(1); + serverRaftProperties.setDisruptorBufferSize(1); + serverRaftProperties.setElectionTimeoutMs(1); + serverRaftProperties.setMaxAppendBufferSize(1); + serverRaftProperties.setMaxReplicatorInflightMsgs(1); + serverRaftProperties.setReporterInitialDelay(1); + serverRaftProperties.setSnapshotInterval(1); + serverRaftProperties.setAutoJoin(true); + serverRaftProperties.setReporterEnabled(true); + serverRaftProperties.setSync(true); + + Assertions.assertEquals("server", serverRaftProperties.getServerAddr()); + Assertions.assertEquals("group", serverRaftProperties.getGroup()); + Assertions.assertEquals("compressor", serverRaftProperties.getCompressor()); + Assertions.assertEquals("serialization", serverRaftProperties.getSerialization()); + Assertions.assertEquals(1, serverRaftProperties.getApplyBatch()); + Assertions.assertEquals(1, serverRaftProperties.getDisruptorBufferSize()); + Assertions.assertEquals(1, serverRaftProperties.getElectionTimeoutMs()); + Assertions.assertEquals(1, serverRaftProperties.getMaxAppendBufferSize()); + Assertions.assertEquals(1, serverRaftProperties.getMaxReplicatorInflightMsgs()); + Assertions.assertEquals(1, serverRaftProperties.getReporterInitialDelay()); + Assertions.assertEquals(1, serverRaftProperties.getSnapshotInterval()); + Assertions.assertTrue(serverRaftProperties.getAutoJoin()); + Assertions.assertTrue(serverRaftProperties.isReporterEnabled()); + Assertions.assertTrue(serverRaftProperties.isSync()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRecoveryPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRecoveryPropertiesTest.java new file mode 100644 index 00000000000..9c6eaa45059 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerRecoveryPropertiesTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ServerRecoveryPropertiesTest { + + @Test + public void testServerRecoveryProperties() { + ServerRecoveryProperties serverRecoveryProperties = new ServerRecoveryProperties(); + serverRecoveryProperties.setAsyncCommittingRetryPeriod(1L); + serverRecoveryProperties.setCommittingRetryPeriod(1L); + serverRecoveryProperties.setRollbackingRetryPeriod(1L); + serverRecoveryProperties.setTimeoutRetryPeriod(1L); + + Assertions.assertEquals(1L, serverRecoveryProperties.getAsyncCommittingRetryPeriod()); + Assertions.assertEquals(1L, serverRecoveryProperties.getCommittingRetryPeriod()); + Assertions.assertEquals(1L, serverRecoveryProperties.getRollbackingRetryPeriod()); + Assertions.assertEquals(1L, serverRecoveryProperties.getTimeoutRetryPeriod()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerUndoPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerUndoPropertiesTest.java new file mode 100644 index 00000000000..d2a1ff3e951 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/ServerUndoPropertiesTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ServerUndoPropertiesTest { + + @Test + public void testServerUndoProperties() { + ServerUndoProperties serverUndoProperties = new ServerUndoProperties(); + serverUndoProperties.setLogSaveDays((short) 1); + serverUndoProperties.setLogDeletePeriod(1); + + Assertions.assertEquals(1, serverUndoProperties.getLogSaveDays()); + Assertions.assertEquals(1, serverUndoProperties.getLogDeletePeriod()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/session/SessionPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/session/SessionPropertiesTest.java new file mode 100644 index 00000000000..0391461ffda --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/session/SessionPropertiesTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server.session; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class SessionPropertiesTest { + + @Test + public void testSessionProperties() { + SessionProperties sessionProperties = new SessionProperties(); + sessionProperties.setEnableBranchAsync(true); + sessionProperties.setBranchAsyncQueueSize(1); + + Assertions.assertTrue(sessionProperties.getEnableBranchAsync()); + Assertions.assertEquals(1, sessionProperties.getBranchAsyncQueueSize()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreDBPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreDBPropertiesTest.java new file mode 100644 index 00000000000..e6674fcc76b --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreDBPropertiesTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server.store; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StoreDBPropertiesTest { + + @Test + public void testStoreDBProperties() { + StoreDBProperties storeDBProperties = new StoreDBProperties(); + storeDBProperties.setUrl("url"); + storeDBProperties.setUser("user"); + storeDBProperties.setPassword("pwd"); + storeDBProperties.setDatasource("datasource"); + storeDBProperties.setDbType("type"); + storeDBProperties.setGlobalTable("global"); + storeDBProperties.setBranchTable("branch"); + storeDBProperties.setLockTable("lock"); + storeDBProperties.setDistributedLockTable("distribute"); + storeDBProperties.setDriverClassName("driver"); + storeDBProperties.setMinConn(1); + storeDBProperties.setMaxConn(1); + storeDBProperties.setQueryLimit(1); + storeDBProperties.setMaxWait(1L); + + Assertions.assertEquals("url", storeDBProperties.getUrl()); + Assertions.assertEquals("user", storeDBProperties.getUser()); + Assertions.assertEquals("pwd", storeDBProperties.getPassword()); + Assertions.assertEquals("datasource", storeDBProperties.getDatasource()); + Assertions.assertEquals("type", storeDBProperties.getDbType()); + Assertions.assertEquals("global", storeDBProperties.getGlobalTable()); + Assertions.assertEquals("branch", storeDBProperties.getBranchTable()); + Assertions.assertEquals("lock", storeDBProperties.getLockTable()); + Assertions.assertEquals("distribute", storeDBProperties.getDistributedLockTable()); + Assertions.assertEquals("driver", storeDBProperties.getDriverClassName()); + Assertions.assertEquals(1, storeDBProperties.getMinConn()); + Assertions.assertEquals(1, storeDBProperties.getMaxConn()); + Assertions.assertEquals(1, storeDBProperties.getQueryLimit()); + Assertions.assertEquals(1L, storeDBProperties.getMaxWait()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreFilePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreFilePropertiesTest.java new file mode 100644 index 00000000000..9f2c949b412 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreFilePropertiesTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server.store; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StoreFilePropertiesTest { + + @Test + public void testStoreFileProperties() { + StoreFileProperties storeFileProperties = new StoreFileProperties(); + storeFileProperties.setDir("dir"); + storeFileProperties.setFlushDiskMode("disk"); + storeFileProperties.setFileWriteBufferCacheSize(1); + storeFileProperties.setMaxBranchSessionSize(1); + storeFileProperties.setMaxGlobalSessionSize(1); + storeFileProperties.setSessionReloadReadSize(1); + + Assertions.assertEquals("dir", storeFileProperties.getDir()); + Assertions.assertEquals("disk", storeFileProperties.getFlushDiskMode()); + Assertions.assertEquals(1, storeFileProperties.getFileWriteBufferCacheSize()); + Assertions.assertEquals(1, storeFileProperties.getMaxGlobalSessionSize()); + Assertions.assertEquals(1, storeFileProperties.getMaxBranchSessionSize()); + Assertions.assertEquals(1, storeFileProperties.getSessionReloadReadSize()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StorePropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StorePropertiesTest.java new file mode 100644 index 00000000000..a7ca9067c05 --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StorePropertiesTest.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server.store; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StorePropertiesTest { + + @Test + public void testStoreProperties() { + StoreProperties storeProperties = new StoreProperties(); + storeProperties.setMode("mode"); + storeProperties.setPublicKey("public"); + + StoreProperties.Session session = new StoreProperties.Session(); + session.setMode("mode"); + + StoreProperties.Lock lock = new StoreProperties.Lock(); + lock.setMode("mode"); + + Assertions.assertEquals("mode", storeProperties.getMode()); + Assertions.assertEquals("public", storeProperties.getPublicKey()); + Assertions.assertEquals("mode", session.getMode()); + Assertions.assertEquals("mode", lock.getMode()); + } +} diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisPropertiesTest.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisPropertiesTest.java new file mode 100644 index 00000000000..4dafb99925f --- /dev/null +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-server/src/test/java/org/apache/seata/spring/boot/autoconfigure/properties/server/store/StoreRedisPropertiesTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.seata.spring.boot.autoconfigure.properties.server.store; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StoreRedisPropertiesTest { + + @Test + public void testStoreRedisProperties() { + StoreRedisProperties storeRedisProperties = new StoreRedisProperties(); + storeRedisProperties.setMode("mode"); + storeRedisProperties.setType("type"); + storeRedisProperties.setPassword("pwd"); + storeRedisProperties.setDatabase(1); + storeRedisProperties.setMaxConn(1); + storeRedisProperties.setMinConn(1); + storeRedisProperties.setQueryLimit(1); + storeRedisProperties.setMaxTotal(1); + + Assertions.assertEquals("mode", storeRedisProperties.getMode()); + Assertions.assertEquals("type", storeRedisProperties.getType()); + Assertions.assertEquals("pwd", storeRedisProperties.getPassword()); + Assertions.assertEquals(1, storeRedisProperties.getDatabase()); + Assertions.assertEquals(1, storeRedisProperties.getMaxConn()); + Assertions.assertEquals(1, storeRedisProperties.getMinConn()); + Assertions.assertEquals(1, storeRedisProperties.getQueryLimit()); + Assertions.assertEquals(1, storeRedisProperties.getMaxTotal()); + + StoreRedisProperties.Single single = new StoreRedisProperties.Single(); + single.setHost("host"); + single.setPort(80); + Assertions.assertEquals("host", single.getHost()); + Assertions.assertEquals(80, single.getPort()); + + StoreRedisProperties.Sentinel sentinel = new StoreRedisProperties.Sentinel(); + sentinel.setSentinelHosts("host"); + sentinel.setMasterName("master"); + sentinel.setSentinelPassword("pwd"); + Assertions.assertEquals("host", sentinel.getSentinelHosts()); + Assertions.assertEquals("master", sentinel.getMasterName()); + Assertions.assertEquals("pwd", sentinel.getSentinelPassword()); + } +}