Skip to content

Commit

Permalink
- 删除了初始的 index.html 文件,该文件包含静态内容和Bootstrap样式
Browse files Browse the repository at this point in the history
- 移除了 QueryHelperTest 类,该类包含对 QueryHelper 类的单元测试
- 添加了 WebConfigurationTest 类,该类为测试配置类,设置了自定义参数解析器
- 删除了 UsersControllerTest 类,该类包含对 UsersController 的集成测试
- 更新了 BootApplicationTest 类,添加了 WebConfigurationTest 的导入,并调整了测试方法的名称
- 添加了 application-test.yml 文件,配置了日志、数据库连接、Redis和OAuth2客户端注册信息
  • Loading branch information
vnobo committed Oct 11, 2024
1 parent 34e6175 commit a58a34a
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 305 deletions.
33 changes: 0 additions & 33 deletions boot/platform/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -1,33 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>管理平台</title>
<!-- Bootstrap CSS -->
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" rel="stylesheet">
<style>
html, body {
height: 100%;
}
</style>
</head>
<body>
<div class="container h-100">
<div class="d-flex align-items-center h-100">
<div class="card" style="width: 36rem">
<div class="card-body">
<h1 class="card-title">欢迎使用服务!</h1>
<p class="card-text">最好用的API调试页面!</p>
<a class="btn btn-primary btn-lg" href="./" role="button">Swagger Api 文档</a>
</div>
</div>
</div>
</div>
<script crossorigin="anonymous"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package com.plate.boot;

import com.plate.boot.config.WebConfigurationTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;

import java.security.*;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author <a href="https://github.com/vnobo">Alex Bob</a>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = "spring.profiles.active=test")
@Import({WebConfigurationTest.class})
class BootApplicationTest {

@Test
void contextLoads() throws NoSuchAlgorithmException {
void contextLoadsTest() throws NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(2048);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
PrivateKey privateKey = keyPair.getPrivate();
PublicKey publicKey = keyPair.getPublic();
System.out.println(privateKey);
System.out.println(publicKey);
assertThat(privateKey).isNotNull();
assertThat(publicKey).isNotNull();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.plate.boot.config;

import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.ReactivePageableHandlerMethodArgumentResolver;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;

/**
* Configures web-related settings and behaviors for an application, including RSocket setup,
* scheduling, asynchronous method handling, and custom argument resolvers for reactive environments.
* This configuration class integrates with Spring's WebFlux features to enable functionalities
* like scheduling tasks, processing asynchronous requests, and defining custom argument resolving
* strategies for handler methods.
*/
@TestConfiguration(proxyBeanMethods = false)
public class WebConfigurationTest implements WebFluxConfigurer {
/**
* Configures custom argument resolvers for handler methods in a reactive environment.
* This method specifically sets up a {@link ReactivePageableHandlerMethodArgumentResolver}
* to handle {@link Pageable} arguments, limiting the maximum page size and setting a default
* fallback page size when none is provided.
*
* @param configurer The {@link ArgumentResolverConfigurer} used to register custom argument resolvers.
*/
@Override
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
ReactivePageableHandlerMethodArgumentResolver pageableResolver =
new ReactivePageableHandlerMethodArgumentResolver();
pageableResolver.setMaxPageSize(100);
pageableResolver.setFallbackPageable(Pageable.ofSize(25));
configurer.addCustomResolver(pageableResolver);
}

}

This file was deleted.

Loading

0 comments on commit a58a34a

Please sign in to comment.