1 package civitas.util;
2
3 import java.nio.charset.StandardCharsets;
4
5 import org.bouncycastle.jce.provider.BouncyCastleProvider;
6
7 import io.github.magwas.konveyor.annotations.Glue;
8
9 @Glue
10 public class InitialTests {
11
12 static {
13 try {
14 doTests();
15 } catch (Exception e) {
16 throw new SecurityException("self- and external entity test failed:", e);
17 }
18 }
19
20 public static void doTests() {
21 testUTF8Support();
22 checkBouncyCastle();
23 }
24
25 public static byte[] testUTF8Support() {
26 return "árvíztűrő tükörfúrógép".getBytes(StandardCharsets.UTF_8);
27 }
28
29 public static void checkBouncyCastle() {
30 String info = new BouncyCastleProvider().getInfo();
31 if (!"BouncyCastle Security Provider v1.82".equals(info)) {
32 throw new SecurityException("unexpected crypto provider: " + info);
33 }
34 }
35 }