屋小巧安置,田少勤耕耘,妻贱合夫心,此乃真富裕。——富兰克林

今天进行streampark参数化单元测试,用来测试多个数据库下的兼容情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.apache.streampark;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.streampark.console.core.entity.Application;
import org.apache.streampark.console.core.mapper.ApplicationMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

/**
* MapperTest
*/
class MapperTest {

@ParameterizedTest
@ValueSource(strings = {"pgsql", "mysql", "h2"})
void test(String profile) {
System.setProperty("spring.profiles.active", profile);
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(StreamParkConsoleBootstrap.class).profiles(profile).run()) {
ApplicationMapper applicationMapper = context.getBean(ApplicationMapper.class);
Application app = new Application();
app.setProjectName("test");
Assertions.assertDoesNotThrow(() -> applicationMapper.page(new Page<>(), app));
}
}
}

代码放到了这里:

streampark-mapper-test: streampark mapper测试,用于兼容多数据库