-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
298 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...boot-starter/src/test/java/me/ahoo/simba/spring/boot/starter/jdbc/JdbcPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.simba.spring.boot.starter.jdbc; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* JdbcPropertiesTest . | ||
* | ||
* @author ahoo wang | ||
*/ | ||
class JdbcPropertiesTest { | ||
|
||
@Test | ||
void isEnabled() { | ||
JdbcProperties properties = new JdbcProperties(); | ||
Assertions.assertTrue(properties.isEnabled()); | ||
} | ||
|
||
@Test | ||
void setEnabled() { | ||
JdbcProperties properties = new JdbcProperties(); | ||
properties.setEnabled(false); | ||
Assertions.assertFalse(properties.isEnabled()); | ||
} | ||
|
||
@Test | ||
void getInitialDelay() { | ||
JdbcProperties properties = new JdbcProperties(); | ||
Assertions.assertEquals(Duration.ofSeconds(0), properties.getInitialDelay()); | ||
} | ||
|
||
@Test | ||
void setInitialDelay() { | ||
Duration initialDelay = Duration.ofSeconds(1); | ||
JdbcProperties properties = new JdbcProperties(); | ||
properties.setInitialDelay(initialDelay); | ||
Assertions.assertEquals(initialDelay, properties.getInitialDelay()); | ||
} | ||
|
||
@Test | ||
void getTtl() { | ||
Duration ttl = Duration.ofSeconds(10); | ||
JdbcProperties properties = new JdbcProperties(); | ||
Assertions.assertEquals(ttl, properties.getTtl()); | ||
} | ||
|
||
@Test | ||
void setTtl() { | ||
Duration ttl = Duration.ofSeconds(10); | ||
JdbcProperties properties = new JdbcProperties(); | ||
properties.setTtl(ttl); | ||
Assertions.assertEquals(ttl, properties.getTtl()); | ||
} | ||
|
||
@Test | ||
void getTransition() { | ||
JdbcProperties properties = new JdbcProperties(); | ||
Assertions.assertEquals(Duration.ofSeconds(6), properties.getTransition()); | ||
} | ||
|
||
@Test | ||
void setTransition() { | ||
Duration transition = Duration.ofSeconds(8); | ||
JdbcProperties properties = new JdbcProperties(); | ||
properties.setTransition(transition); | ||
Assertions.assertEquals(transition, properties.getTransition()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
.../src/test/java/me/ahoo/simba/spring/boot/starter/jdbc/SimbaJdbcAutoConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.simba.spring.boot.starter.jdbc; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import me.ahoo.simba.core.MutexContendServiceFactory; | ||
import me.ahoo.simba.jdbc.MutexOwnerRepository; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
/** | ||
* SimbaJdbcAutoConfigurationTest . | ||
* | ||
* @author ahoo wang | ||
*/ | ||
class SimbaJdbcAutoConfigurationTest { | ||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); | ||
|
||
@Test | ||
void contextLoads() { | ||
this.contextRunner | ||
.withPropertyValues("spring.datasource.url=jdbc:mysql://localhost:3306/simba_db") | ||
.withUserConfiguration(DataSourceAutoConfiguration.class, SimbaJdbcAutoConfiguration.class) | ||
.run(context -> { | ||
assertThat(context) | ||
.hasSingleBean(SimbaJdbcAutoConfiguration.class) | ||
.hasSingleBean(JdbcProperties.class) | ||
.hasSingleBean(MutexOwnerRepository.class) | ||
.hasSingleBean(MutexContendServiceFactory.class) | ||
; | ||
}); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...ot-starter/src/test/java/me/ahoo/simba/spring/boot/starter/redis/RedisPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.simba.spring.boot.starter.redis; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import me.ahoo.simba.spring.boot.starter.jdbc.JdbcProperties; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* RedisPropertiesTest . | ||
* | ||
* @author ahoo wang | ||
*/ | ||
class RedisPropertiesTest { | ||
|
||
@Test | ||
void isEnabled() { | ||
RedisProperties properties = new RedisProperties(); | ||
Assertions.assertTrue(properties.isEnabled()); | ||
} | ||
|
||
@Test | ||
void setEnabled() { | ||
RedisProperties properties = new RedisProperties(); | ||
properties.setEnabled(false); | ||
Assertions.assertFalse(properties.isEnabled()); | ||
} | ||
|
||
@Test | ||
void getTtl() { | ||
Duration ttl = Duration.ofSeconds(10); | ||
RedisProperties properties = new RedisProperties(); | ||
Assertions.assertEquals(ttl, properties.getTtl()); | ||
} | ||
|
||
@Test | ||
void setTtl() { | ||
Duration ttl = Duration.ofSeconds(10); | ||
RedisProperties properties = new RedisProperties(); | ||
properties.setTtl(ttl); | ||
Assertions.assertEquals(ttl, properties.getTtl()); | ||
} | ||
|
||
@Test | ||
void getTransition() { | ||
RedisProperties properties = new RedisProperties(); | ||
Assertions.assertEquals(Duration.ofSeconds(6), properties.getTransition()); | ||
} | ||
|
||
@Test | ||
void setTransition() { | ||
Duration transition = Duration.ofSeconds(8); | ||
RedisProperties properties = new RedisProperties(); | ||
properties.setTransition(transition); | ||
Assertions.assertEquals(transition, properties.getTransition()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...t/java/me/ahoo/simba/spring/boot/starter/redis/SimbaSpringRedisAutoConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.simba.spring.boot.starter.redis; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import me.ahoo.simba.core.MutexContendServiceFactory; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
import org.springframework.data.redis.listener.RedisMessageListenerContainer; | ||
|
||
/** | ||
* SimbaSpringRedisAutoConfigurationTest . | ||
* | ||
* @author ahoo wang | ||
*/ | ||
class SimbaSpringRedisAutoConfigurationTest { | ||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); | ||
|
||
@Test | ||
void contextLoads() { | ||
this.contextRunner | ||
.withUserConfiguration(RedisAutoConfiguration.class, SimbaSpringRedisAutoConfiguration.class) | ||
.run(context -> { | ||
assertThat(context) | ||
.hasSingleBean(SimbaSpringRedisAutoConfiguration.class) | ||
.hasSingleBean(RedisProperties.class) | ||
.hasSingleBean(RedisMessageListenerContainer.class) | ||
.hasSingleBean(MutexContendServiceFactory.class) | ||
; | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...er/src/test/java/me/ahoo/simba/spring/boot/starter/zookeeper/ZookeeperPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.simba.spring.boot.starter.zookeeper; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* ZookeeperPropertiesTest . | ||
* | ||
* @author ahoo wang | ||
*/ | ||
class ZookeeperPropertiesTest { | ||
|
||
@Test | ||
void isEnabled() { | ||
ZookeeperProperties properties=new ZookeeperProperties(); | ||
Assertions.assertTrue(properties.isEnabled()); | ||
} | ||
|
||
@Test | ||
void setEnabled() { | ||
ZookeeperProperties properties=new ZookeeperProperties(); | ||
properties.setEnabled(false); | ||
Assertions.assertFalse(properties.isEnabled()); | ||
} | ||
} |