1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tools.logging.jdk;
12
13 import java.io.File;
14 import java.io.IOException;
15 import java.nio.file.Files;
16 import java.nio.file.Path;
17 import java.util.logging.FileHandler;
18
19 import org.assertj.core.api.Assertions;
20 import org.junit.jupiter.api.Test;
21
22 import psiprobe.model.Application;
23
24
25
26
27 class Jdk14FileHandlerAccessorTest {
28
29
30
31
32
33
34 @Test
35 void getFile() throws IOException {
36 Jdk14FileHandlerAccessor handlerAccessor = new Jdk14FileHandlerAccessor();
37 handlerAccessor.setLoggerAccessor(new Jdk14LoggerAccessor());
38
39 Path testPath = Files.createTempDirectory("psi-probe");
40 testPath.toFile().deleteOnExit();
41 FileHandler target = new FileHandler(testPath.toString() + "test-%g.log", 1024, 3);
42
43 handlerAccessor.setTarget(target);
44 handlerAccessor.setIndex(Integer.toString(0));
45 Application testApplication = new Application();
46 handlerAccessor.setApplication(testApplication);
47
48 File file = handlerAccessor.getFile();
49
50 Assertions.assertThat(file.getAbsolutePath()).isEqualTo(testPath + "test-0.log");
51
52 }
53
54 }