-
Notifications
You must be signed in to change notification settings - Fork 676
Expand file tree
/
Copy pathIndexControllerTest.java
More file actions
107 lines (81 loc) · 2.39 KB
/
IndexControllerTest.java
File metadata and controls
107 lines (81 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package guru.springframework.sfgpetclinic.controllers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.*;
import java.time.Duration;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
class IndexControllerTest {
IndexController controller;
@BeforeEach
void setUp() {
controller = new IndexController();
}
@DisplayName("Test Proper View name is returned for index page")
@Test
void index() {
assertEquals("index", controller.index());
assertEquals("index", controller.index(), "Wrong View Returned");
assertEquals("index", controller.index(), () -> "Another Expensive Message " +
"Make me only if you have to");
assertThat(controller.index()).isEqualTo("index");
}
@Test
@DisplayName("Test exception")
void oupsHandler() {
assertThrows(ValueNotFoundException.class, () -> {
controller.oopsHandler();
});
}
@Disabled("Demo of timeout")
@Test
void testTimeOut() {
assertTimeout(Duration.ofMillis(100), () -> {
Thread.sleep(5000);
System.out.println("I got here");
});
}
@Disabled("Demo of timeout")
@Test
void testTimeOutPrempt() {
assertTimeoutPreemptively(Duration.ofMillis(100), () -> {
Thread.sleep(5000);
System.out.println("I got here 2342342342342");
});
}
@Test
void testAssumptionTrue() {
assumeTrue("GURU".equalsIgnoreCase(System.getenv("GURU_RUNTIME")));
}
@Test
void testAssumptionTrueAssumptionIsTrue() {
assumeTrue("GURU".equalsIgnoreCase("GURU"));
}
@EnabledOnOs(OS.MAC)
@Test
void testMeOnMacOS() {
}
@EnabledOnOs(OS.WINDOWS)
@Test
void testMeOnWindows() {
}
@EnabledOnJre(JRE.JAVA_8)
@Test
void testMeOnJava8() {
}
@EnabledOnJre(JRE.JAVA_11)
@Test
void testMeOnJava11() {
}
@EnabledIfEnvironmentVariable(named = "USER", matches = "jt")
@Test
void testIfUserJT() {
}
@EnabledIfEnvironmentVariable(named = "USER", matches = "fred")
@Test
void testIfUserFred() {
}
}