Skip to content

Commit

Permalink
DCPERF-432 Add test showing JDK fails without fonts
Browse files Browse the repository at this point in the history
TDD: red

running `java FontTest` exits with non zero status code and error output
```
Exception in thread "main" java.lang.UnsatisfiedLinkError: /root/jdk-17.0.11/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
```
  • Loading branch information
mgrzaslewicz committed Jun 19, 2024
1 parent 480537f commit 99420df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.atlassian.performance.tools.infrastructure.api.jvm
import com.atlassian.performance.tools.infrastructure.toSsh
import com.atlassian.performance.tools.sshubuntu.api.SshUbuntuContainer
import org.assertj.core.api.Assertions.assertThat
import java.io.File

class JdkSupport(
private val jdk: VersionedJavaDevelopmentKit
Expand All @@ -18,4 +19,19 @@ class JdkSupport(
}
}
}

fun shouldLoadFont() {
SshUbuntuContainer.Builder().build().start().use { ubuntu ->
val ssh = ubuntu.toSsh()
ssh.newConnection().use { connection ->
jdk.install(connection)
connection.upload(
File(javaClass.getResource("FontTest.java").toURI()),
"FontTest.java"
)
connection.execute("${jdk.use()}; javac FontTest.java")
connection.execute("${jdk.use()}; java FontTest")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ class VersionedOracleJdkIT {
).shouldHaveJavaHomeSet("/jdk-21.0.2")
}

@Test
fun shouldLoadFont() {
JdkSupport(VersionedOracleJdk.Builder().build()).shouldLoadFont()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import java.awt.*;

public class FontTest {
public static void main(String[] args) {
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
fonts[0].canDisplay('a');
}
}

0 comments on commit 99420df

Please sign in to comment.