Открыть боковую панель
Aurora OS
Kotlin Multiplatform
Libraries
ktor
Коммиты
544372d9
Не подтверждена
Коммит
544372d9
создал
Июн 10, 2021
по автору
Leonid Stashevsky
Зафиксировано автором
GitHub
Июн 10, 2021
Просмотр файлов
KTOR-2586 Fix module start twice; Fix starting exception (#2502)
владелец
f7aa31b5
Изменения
8
Скрыть пробелы
Построчно
Рядом
ktor-server/ktor-server-cio/jvm/test/io/ktor/tests/server/cio/CIOEngineTest.kt
Просмотр файла @
544372d9
...
...
@@ -34,3 +34,5 @@ class CIOSustainabilityTest : SustainabilityTestSuite<CIOApplicationEngine, CIOA
enableSsl
=
false
}
}
class
CIOConfigTest
:
ConfigTestSuite
(
CIO
)
ktor-server/ktor-server-host-common/jvm/src/io/ktor/server/engine/ApplicationEngineEnvironmentReloading.kt
Просмотр файла @
544372d9
...
...
@@ -302,7 +302,7 @@ public class ApplicationEngineEnvironmentReloading(
try
{
launchModuleByName
(
name
,
currentClassLoader
,
newInstance
)
}
catch
(
_
:
Throwable
)
{
}
catch
(
_
:
ReloadingException
)
{
module
(
newInstance
)
}
}
...
...
ktor-server/ktor-server-host-common/jvm/src/io/ktor/server/engine/internal/CallableUtils.kt
Просмотр файла @
544372d9
...
...
@@ -41,8 +41,9 @@ internal fun ApplicationEnvironment.executeModuleFunction(
if
(
Function1
::
class
.
java
.
isAssignableFrom
(
clazz
))
{
val
constructor
=
clazz
.
declaredConstructors
.
single
()
if
(
constructor
.
parameterCount
!=
0
)
{
throw
R
untime
Exception
(
"Module function with captured variables cannot be instantiated '$fqName'"
)
throw
R
eloading
Exception
(
"Module function with captured variables cannot be instantiated '$fqName'"
)
}
constructor
.
isAccessible
=
true
@Suppress
(
"UNCHECKED_CAST"
)
val
function
=
constructor
.
newInstance
()
as
Function1
<
Application
,
Unit
>
...
...
@@ -85,8 +86,8 @@ private fun <R> ApplicationEnvironment.callFunctionWithInjection(
instance
:
Any
?,
entryPoint
:
KFunction
<
R
>,
application
:
Application
):
R
=
entryPoint
.
callBy
(
entryPoint
.
parameters
.
filterNot
{
it
.
isOptional
}.
associateBy
(
):
R
{
val
args
=
entryPoint
.
parameters
.
filterNot
{
it
.
isOptional
}.
associateBy
(
{
it
},
{
parameter
->
when
{
...
...
@@ -109,4 +110,12 @@ private fun <R> ApplicationEnvironment.callFunctionWithInjection(
}
}
)
)
try
{
return
entryPoint
.
callBy
(
args
)
}
catch
(
cause
:
InvocationTargetException
)
{
throw
cause
.
cause
?:
cause
}
}
internal
class
ReloadingException
(
message
:
String
)
:
RuntimeException
(
message
)
ktor-server/ktor-server-jetty/jvm/test/io/ktor/tests/server/jetty/JettyEngineTest.kt
Просмотр файла @
544372d9
...
...
@@ -72,3 +72,5 @@ class JettyHttpServerTest : HttpServerTestSuite<JettyApplicationEngine, JettyApp
class
JettySustainabilityTest
:
SustainabilityTestSuite
<
JettyApplicationEngine
,
JettyApplicationEngineBase
.
Configuration
>(
Jetty
)
class
JettyConfigTest
:
ConfigTestSuite
(
Jetty
)
ktor-server/ktor-server-netty/jvm/test/io/ktor/tests/server/netty/NettyEngineTest.kt
Просмотр файла @
544372d9
...
...
@@ -50,9 +50,9 @@ class NettyHttp2ServerTest : HttpServerTestSuite<NettyApplicationEngine, NettyAp
}
}
class
NettySustainabilityTest
:
SustainabilityTestSuite
<
NettyApplicationEngine
,
NettyApplicationEngine
.
Configuration
>(
Netty
)
{
class
NettySustainabilityTest
:
SustainabilityTestSuite
<
NettyApplicationEngine
,
NettyApplicationEngine
.
Configuration
>(
Netty
)
{
init
{
enableSsl
=
true
}
...
...
@@ -61,3 +61,5 @@ class NettySustainabilityTest :
configuration
.
shareWorkGroup
=
true
}
}
class
NettyConfigTest
:
ConfigTestSuite
(
Netty
)
ktor-server/ktor-server-test-suites/jvm/src/io/ktor/server/testing/suites/CompressionTestSuite.kt
Просмотр файла @
544372d9
...
...
@@ -21,12 +21,11 @@ import java.io.*
import
java.util.zip.*
import
kotlin.test.*
public
abstract
class
CompressionTestSuite
<
TEngine
:
ApplicationEngine
,
TConfiguration
:
ApplicationEngine
.
Configuration
>(
hostFactory
:
ApplicationEngineFactory
<
TEngine
,
TConfiguration
>)
:
EngineTestBase
<
TEngine
,
TConfiguration
>(
hostFactory
)
{
abstract
class
CompressionTestSuite
<
TEngine
:
ApplicationEngine
,
TConfiguration
:
ApplicationEngine
.
Configuration
>(
hostFactory
:
ApplicationEngineFactory
<
TEngine
,
TConfiguration
>
)
:
EngineTestBase
<
TEngine
,
TConfiguration
>(
hostFactory
)
{
@Test
public
fun
testLocalFileContentWithCompression
()
{
fun
testLocalFileContentWithCompression
()
{
val
file
=
loadTestFile
()
testLog
.
trace
(
"test file is $file"
)
...
...
@@ -45,7 +44,7 @@ public abstract class CompressionTestSuite<TEngine : ApplicationEngine,
}
@Test
public
fun
testStreamingContentWithCompression
()
{
fun
testStreamingContentWithCompression
()
{
val
file
=
loadTestFile
()
testLog
.
trace
(
"test file is $file"
)
...
...
@@ -70,7 +69,7 @@ public abstract class CompressionTestSuite<TEngine : ApplicationEngine,
}
@Test
public
fun
testLocalFileContentRangeWithCompression
()
{
fun
testLocalFileContentRangeWithCompression
()
{
val
file
=
loadTestFile
()
testLog
.
trace
(
"test file is $file"
)
...
...
@@ -103,7 +102,7 @@ public abstract class CompressionTestSuite<TEngine : ApplicationEngine,
}
@Test
public
fun
testCompressionWriteToLarge
()
{
fun
testCompressionWriteToLarge
()
{
val
count
=
655350
fun
Appendable
.
produceText
()
{
for
(
i
in
1
..
count
)
{
...
...
ktor-server/ktor-server-test-suites/jvm/src/io/ktor/server/testing/suites/ConfigTestSuite.kt
0 → 100644
Просмотр файла @
544372d9
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package
io.ktor.server.testing.suites
import
io.ktor.server.engine.*
import
java.util.concurrent.*
import
kotlin.test.*
var
count
=
0
abstract
class
ConfigTestSuite
(
val
engine
:
ApplicationEngineFactory
<
*
,
*
>)
{
@Test
fun
testStartOnceWhenException
()
{
// Please note that it's critical to not capture any variables inside the scope
// It will disable autoreload and change behaviour
val
server
=
embeddedServer
(
engine
)
{
count
++
error
(
"Foo"
)
}
assertFailsWith
<
IllegalStateException
>
{
server
.
start
()
}
assertEquals
(
1
,
count
)
server
.
stop
(
1
,
1
,
TimeUnit
.
SECONDS
)
}
@Test
fun
testStartsOnceWithCapture
()
{
var
counter
=
0
val
server
=
embeddedServer
(
engine
)
{
counter
++
error
(
"Foo"
)
}
assertFailsWith
<
IllegalStateException
>
{
server
.
start
()
}
assertEquals
(
1
,
counter
)
server
.
stop
(
1
,
1
,
TimeUnit
.
SECONDS
)
}
}
ktor-server/ktor-server-tomcat/jvm/test/io/ktor/tests/server/tomcat/TomcatEngineTest.kt
Просмотр файла @
544372d9
...
...
@@ -135,3 +135,5 @@ class TomcatSustainabilityTestSuite :
super
.
testBlockingConcurrency
()
}
}
class
TomcatConfigTest
:
ConfigTestSuite
(
Tomcat
)
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать