6
6
import java .io .*;
7
7
import java .util .HashMap ;
8
8
import java .util .Map ;
9
- import java .util .concurrent .ExecutionException ;
10
9
11
10
import static com .github .mustachejava .TestUtil .getContents ;
12
- import static junit .framework .Assert .fail ;
13
11
import static org .junit .Assert .assertEquals ;
12
+ import static org .junit .Assert .assertThrows ;
14
13
15
14
public class FallbackTest {
16
15
17
16
private static File rootDefault ;
18
17
private static File rootOverride ;
19
18
20
19
@ Test
21
- public void testDefaultPage1 () throws MustacheException , IOException , ExecutionException , InterruptedException {
20
+ public void testDefaultPage1 () throws MustacheException , IOException {
22
21
MustacheFactory c = new FallbackMustacheFactory (rootDefault , rootDefault ); // no override
23
22
Mustache m = c .compile ("page1.html" );
24
23
StringWriter sw = new StringWriter ();
@@ -29,7 +28,7 @@ public void testDefaultPage1() throws MustacheException, IOException, ExecutionE
29
28
}
30
29
31
30
@ Test
32
- public void testOverridePage1 () throws MustacheException , IOException , ExecutionException , InterruptedException {
31
+ public void testOverridePage1 () throws MustacheException , IOException {
33
32
MustacheFactory c = new FallbackMustacheFactory (rootOverride , rootDefault );
34
33
Mustache m = c .compile ("page1.html" );
35
34
StringWriter sw = new StringWriter ();
@@ -40,7 +39,7 @@ public void testOverridePage1() throws MustacheException, IOException, Execution
40
39
}
41
40
42
41
@ Test
43
- public void testOverridePage2 () throws MustacheException , IOException , ExecutionException , InterruptedException {
42
+ public void testOverridePage2 () throws MustacheException , IOException {
44
43
MustacheFactory c = new FallbackMustacheFactory (rootOverride , rootDefault );
45
44
Mustache m = c .compile ("page2.html" );
46
45
StringWriter sw = new StringWriter ();
@@ -53,13 +52,11 @@ public void testOverridePage2() throws MustacheException, IOException, Execution
53
52
@ Test
54
53
public void testMustacheNotFoundException () {
55
54
String nonExistingMustache = "404" ;
56
- try {
55
+ MustacheNotFoundException e = assertThrows ( MustacheNotFoundException . class , () -> {
57
56
MustacheFactory c = new FallbackMustacheFactory (rootOverride , rootDefault );
58
57
c .compile (nonExistingMustache );
59
- fail ("Didn't throw an exception" );
60
- } catch (MustacheNotFoundException e ) {
61
- assertEquals (nonExistingMustache , e .getName ());
62
- }
58
+ });
59
+ assertEquals (nonExistingMustache , e .getName ());
63
60
}
64
61
65
62
@ BeforeClass
0 commit comments