Skip to content

Commit

Permalink
test: fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
AkagiYui committed Apr 15, 2024
1 parent 87d0986 commit 5a939e6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 69 deletions.
34 changes: 0 additions & 34 deletions src/test/java/com/akagiyui/drive/KenkoDriveApplicationTests.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/test/java/com/akagiyui/drive/config/SecurityConfigTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.akagiyui.drive.notifier
package com.akagiyui.common.notifier

import com.akagiyui.common.notifier.GotifyPusher
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.web.client.ResourceAccessException

/**
* Gotify 推送测试
*
* @author AkagiYui
*/
@SpringBootTest
class GotifyPusherTest {
class GotifyPusherTests {

@Test
@Disabled
@Disabled("no gotify server for test")
fun sendMessage() {
val gotifyPusher = GotifyPusher(
"https://gotify.server",
Expand Down
31 changes: 31 additions & 0 deletions src/test/kotlin/com/akagiyui/drive/KenkoDriveApplicationTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.akagiyui.drive

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.MessageSource
import org.springframework.context.i18n.LocaleContextHolder
import java.util.*

/**
* @author AkagiYui
*/
@SpringBootTest
class KenkoDriveApplicationTests(@Autowired private val messageSource: MessageSource) {
@Test
fun contextLoads() {
Assertions.assertEquals(1, 2 - 1)
}

@Test
fun i18nTest() {
val locale = LocaleContextHolder.getLocale()
println("locale: $locale")
if (locale == Locale.SIMPLIFIED_CHINESE) {
Assertions.assertEquals("测试", messageSource.getMessage("TEST", arrayOf(), locale))
} else {
Assertions.assertEquals("test", messageSource.getMessage("TEST", arrayOf(), locale))
}
}
}
25 changes: 25 additions & 0 deletions src/test/kotlin/com/akagiyui/drive/config/SecurityConfigTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.akagiyui.drive.config

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.security.crypto.password.PasswordEncoder

/**
* Spring Security 测试
*
* @author AkagiYui
*/
@SpringBootTest
class SecurityConfigTests(@Autowired private val passwordEncoder: PasswordEncoder) {

@Test
fun passwordEncoder() {
val encoded = passwordEncoder.encode("123456")
println(encoded)
Assertions.assertNotNull(encoded)
Assertions.assertNotEquals("123456", encoded)
}

}

0 comments on commit 5a939e6

Please sign in to comment.