Skip to content

Commit f5dc524

Browse files
committed
TS-38628 Migrated most system tests
1 parent d468e4d commit f5dc524

94 files changed

Lines changed: 1343 additions & 1358 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

system-tests/debug-logging-default-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
com.teamscale.`kotlin-convention`
23
com.teamscale.`system-test-convention`
34
}
45

system-tests/debug-logging-default-test/src/main/java/systemundertest/SystemUnderTest.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

system-tests/debug-logging-default-test/src/test/java/com/teamscale/client/DebugLoggingDefaultTest.java

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.teamscale.client
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.jupiter.api.Test
5+
import java.nio.file.Paths
6+
import kotlin.io.path.exists
7+
import kotlin.io.path.readLines
8+
9+
class DebugLoggingDefaultTest {
10+
11+
@Test
12+
fun systemTest() {
13+
val logDirectory = searchForAgentTempDirectory().resolve("logs")
14+
assertThat(logDirectory.exists()).isTrue()
15+
assertThat(logDirectory.resolve("teamscale-jacoco-agent.log").readLines()).isNotEmpty()
16+
}
17+
18+
private fun searchForAgentTempDirectory() =
19+
Paths.get(System.getProperty("java.io.tmpdir"))
20+
.toFile().walk().maxDepth(1)
21+
.firstOrNull { it.name.contains("teamscale-java-profiler") }?.toPath()
22+
?: throw AssertionError("Could not locate agent temp directory")
23+
}

system-tests/debug-logging-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
com.teamscale.`kotlin-convention`
23
com.teamscale.`system-test-convention`
34
}
45

system-tests/debug-logging-test/src/main/java/jul/test/CustomLogManager.java renamed to system-tests/debug-logging-test/src/main/kotlin/jul/test/CustomLogManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package jul.test;
1+
package jul.test
22

3-
import java.util.logging.LogManager;
3+
import java.util.logging.LogManager
44

55
/**
66
* A custom log manager extending the base LogManager class.
@@ -10,8 +10,8 @@
1010
*
1111
* The manager seems unused, but is referenced in the system property of the runWithoutGradleWorker task.
1212
*/
13-
public class CustomLogManager extends LogManager {
14-
public CustomLogManager() {
15-
SystemUnderTest.logManagerInitialized = true;
13+
class CustomLogManager : LogManager() {
14+
init {
15+
SystemUnderTest.logManagerInitialized = true
1616
}
1717
}

system-tests/debug-logging-test/src/main/java/jul/test/SystemUnderTest.java renamed to system-tests/debug-logging-test/src/main/kotlin/jul/test/SystemUnderTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
package jul.test;
1+
package jul.test
22

33
/**
4-
* The {@code SystemUnderTest} class is responsible for asserting that the LogManager is not initialized yet.
4+
* The `SystemUnderTest` class is responsible for asserting that the LogManager is not initialized yet.
55
*/
6-
public class SystemUnderTest {
6+
object SystemUnderTest {
7+
var logManagerInitialized: Boolean = false
78

8-
public static boolean logManagerInitialized = false;
9-
10-
public static void main(String[] args) {
11-
if (logManagerInitialized) {
12-
throw new RuntimeException("Expected the LogManager to not be initialized by the agent. " +
9+
@JvmStatic
10+
fun main(args: Array<String>) {
11+
check(!logManagerInitialized) {
12+
"Expected the LogManager to not be initialized by the agent. " +
1313
"This is required to make the agent work in certain contexts like JBoss Wildfly. " +
1414
"It wants to set it's own LogManager, but cannot do so if our agent has already initialized it " +
1515
"accidentally e.g. by calling `java.util.logging.Logger.getLogger(...)`. " +
1616
"This should be called nowhere, because we transform all class files automatically to use " +
17-
"Logger.global instead which works without initializing the LogManager.");
17+
"Logger.global instead which works without initializing the LogManager."
1818
}
1919
}
2020
}

system-tests/debug-logging-test/src/test/java/com/teamscale/client/DebugLoggingTest.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.teamscale.client
2+
3+
import org.junit.jupiter.api.Test
4+
import java.nio.file.Paths
5+
6+
import org.assertj.core.api.Assertions.assertThat
7+
import org.junit.jupiter.api.Assertions.assertTrue
8+
import kotlin.io.path.exists
9+
import kotlin.io.path.readLines
10+
11+
class DebugLoggingTest {
12+
@Test
13+
@Throws(Exception::class)
14+
fun systemTest() {
15+
assertTrue(LOG_DIRECTORY.exists())
16+
assertThat(LOG_DIRECTORY.resolve("teamscale-jacoco-agent.log").readLines()).isNotEmpty()
17+
}
18+
19+
companion object {
20+
private val LOG_DIRECTORY = Paths.get("logTest").resolve("logs")
21+
}
22+
}

system-tests/default-excludes-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
com.teamscale.`kotlin-convention`
23
com.teamscale.`system-test-convention`
34
}
45

0 commit comments

Comments
 (0)