Skip to content

Commit

Permalink
refactor: 测试用例调整,添加容器并行
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed Dec 2, 2024
1 parent bfa0602 commit 28e163d
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class UserControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@SpringBootTest
@AutoConfigureWebTestClient(timeout = "15000")
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class UserControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@SpringBootTest
@AutoConfigureWebTestClient(timeout = "15000")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class BookControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
@SpringBootTest
@AutoConfigureWebTestClient(timeout = "15000")
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class GreetingControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
@AutoConfigureMockMvc
@SpringBootTest
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class ProducerControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import freemarker.template.Template;
import freemarker.template.TemplateException;
import jakarta.mail.internet.MimeMessage;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -51,7 +50,6 @@
*
* @author livk
*/
@Slf4j
@SpringBootTest
class MailTest {

Expand Down Expand Up @@ -106,10 +104,8 @@ void test1() throws IOException, TemplateException {
Template template = new Template("template", new StringReader(txt), configuration);
String result = "www.baidu.com -> 123456";
String s1 = FreemarkerUtils.processTemplateIntoString(template, map);
log.info("processTemplateIntoString result:{}", s1);
assertEquals(result, s1);
String s2 = FreemarkerUtils.parse(txt, map);
log.info("parse result:{}", s2);
assertEquals(result, s2);
}

Expand All @@ -125,7 +121,6 @@ void testSql() {
String resultSql = "INSERT INTO sys_user(user_name,sex,age,address,status,create_time,update_time) VALUES (livk,1,26,shenzhen,1,"
+ format + "," + format + "),(livk,1,26,shenzhen,1," + format + "," + format + ")";
String parse = parse(sql, map);
log.info("parse result:{}", parse);
assertEquals(resultSql, parse);
}

Expand All @@ -135,7 +130,6 @@ private String parse(String freemarker, Map<String, Object> model) {
return out.toString();
}
catch (Exception e) {
log.error("{}", e.getMessage());
return "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class UserControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class UserControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class UserControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@SpringBootTest({ "spring.pulsar.consumer.topics=livk-topic", "spring.pulsar.consumer.subscription.name=consumer" })
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class MessageControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class RabbitControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author livk
*/
@SpringBootTest(classes = MqttApp.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class MqttTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@Slf4j
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CacheControllerTest {

@Container
Expand Down Expand Up @@ -90,7 +90,7 @@ void testGet() throws Exception {
.getContentAsString();
result.add(newUUID);
}
assertEquals(result.size(), 1);
assertEquals(1, result.size());
}

@Test
Expand All @@ -113,7 +113,7 @@ void testPut() throws Exception {
.getContentAsString();
result.add(newUUID);
}
assertEquals(result.size(), 3);
assertEquals(3, result.size());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class LockControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* @author livk
*/
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CuratorHealthIndicatorTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author livk
*/
@SpringBootTest
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CuratorAppTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class ShopControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class ShopControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class UserControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void java() {
Map<String, String> result = service.java();

assertNotEquals(result.get("java-version"), System.getProperty("java.version"));
assertEquals(result.get("java-version"), "17");
assertEquals("17", result.get("java-version"));
assertTrue(Boolean.parseBoolean(result.get("mockito")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void springBoot() {
Map<String, String> result = service.springBoot();

assertNotEquals(result.get("spring-boot-version"), SpringBootVersion.getVersion());
assertEquals(result.get("spring-boot-version"), "1.0.0");
assertEquals("1.0.0", result.get("spring-boot-version"));
assertTrue(Boolean.parseBoolean(result.get("mockito")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void spring() {
Map<String, String> result = service.spring();

assertNotEquals(result.get("spring-version"), SpringVersion.getVersion());
assertEquals(result.get("spring-version"), "1.0.0");
assertEquals("1.0.0", result.get("spring-version"));
assertTrue(Boolean.parseBoolean(result.get("mockito")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class RateLimiterControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@SpringBootTest(classes = MySQLTypeHandlerExampleApp.class)
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class UserControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
@SpringBootTest(classes = PGSQLTypeHandlerExampleApp.class)
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class UserControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class OssControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
@SpringBootTest
@AutoConfigureWebTestClient
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class StudentControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class StudentControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@SpringBootTest
@AutoConfigureMockMvc
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class ScheduleControllerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class JacksonSupportTest {
<c>3</c>
</b>
</pro>
""";
""";

@Test
void javaType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.MultiValueMap;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -59,7 +58,7 @@ void body() throws IOException {
ServletInputStream inputStream = wrapper.getInputStream();
byte[] bytes = FileCopyUtils.copyToByteArray(inputStream);
assertArrayEquals(JsonMapperUtils.writeValueAsBytes(map), bytes);
assertEquals(wrapper.getContentType(), MediaType.APPLICATION_JSON_VALUE);
assertEquals(MediaType.APPLICATION_JSON_VALUE, wrapper.getContentType());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
@SpringJUnitConfig(CuratorConfig.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CuratorOperationsTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
@SpringJUnitConfig(CuratorConfig.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CuratorTemplateTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author livk
*/
@SpringJUnitConfig(CuratorLockConfig.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class CuratorLockTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author livk
*/
@SpringJUnitConfig(RedissonLockConfig.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class RedissonLockTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @author livk
*/
@SpringJUnitConfig(MybatisConfig.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class MysqlJsonTypeHandlerTest {

@Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @author livk
*/
@SpringJUnitConfig(MybatisConfig.class)
@Testcontainers(disabledWithoutDocker = true)
@Testcontainers(parallel = true)
class PostgresJsonTypeHandlerTest {

@Container
Expand Down
Loading

0 comments on commit 28e163d

Please sign in to comment.