Skip to content

Commit 01054a7

Browse files
rhowespullara
authored andcommitted
Replace hamcrest assertions with jUnit assertions
Hamcrest isn't really adding anything here, so we may as well just use the junit assertion APIs
1 parent 5c3735e commit 01054a7

2 files changed

Lines changed: 37 additions & 41 deletions

File tree

compiler/src/test/java/com/github/mustachejava/resolver/ClasspathResolverTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,56 @@
44

55
import java.io.Reader;
66

7-
import static org.hamcrest.CoreMatchers.notNullValue;
8-
import static org.hamcrest.CoreMatchers.nullValue;
9-
import static org.hamcrest.core.Is.is;
10-
import static org.junit.Assert.assertThat;
7+
import static org.junit.Assert.assertNotNull;
8+
import static org.junit.Assert.assertNull;
119

1210
public class ClasspathResolverTest {
1311

1412
@Test
1513
public void getReaderNullRootAndResourceHasRelativePath() throws Exception {
1614
ClasspathResolver underTest = new ClasspathResolver();
1715
try (Reader reader = underTest.getReader("nested_partials_template.html")) {
18-
assertThat(reader, is(notNullValue()));
16+
assertNotNull(reader);
1917
}
2018
}
2119

2220
@Test
2321
public void getReaderWithRootAndResourceHasRelativePath() throws Exception {
2422
ClasspathResolver underTest = new ClasspathResolver("templates");
2523
try (Reader reader = underTest.getReader("absolute_partials_template.html")) {
26-
assertThat(reader, is(notNullValue()));
24+
assertNotNull(reader);
2725
}
2826
}
2927

3028
@Test
3129
public void getReaderWithRootThatHasTrailingForwardSlashAndResourceHasRelativePath() throws Exception {
3230
ClasspathResolver underTest = new ClasspathResolver("templates/");
3331
try (Reader reader = underTest.getReader("absolute_partials_template.html")) {
34-
assertThat(reader, is(notNullValue()));
32+
assertNotNull(reader);
3533
}
3634
}
3735

3836
@Test
3937
public void getReaderWithRootAndResourceHasAbsolutePath() throws Exception {
4038
ClasspathResolver underTest = new ClasspathResolver("templates");
4139
try (Reader reader = underTest.getReader("/absolute_partials_template.html")) {
42-
assertThat(reader, is(notNullValue()));
40+
assertNotNull(reader);
4341
}
4442
}
4543

4644
@Test
4745
public void getReaderWithRootThatHasTrailingForwardSlashAndResourceHasAbsolutePath() throws Exception {
4846
ClasspathResolver underTest = new ClasspathResolver("templates/");
4947
try (Reader reader = underTest.getReader("/absolute_partials_template.html")) {
50-
assertThat(reader, is(notNullValue()));
48+
assertNotNull(reader);
5149
}
5250
}
5351

5452
@Test
5553
public void getReaderNullRootDoesNotFindFileWithAbsolutePath() throws Exception {
5654
ClasspathResolver underTest = new ClasspathResolver();
5755
try (Reader reader = underTest.getReader("/nested_partials_template.html")) {
58-
assertThat(reader, is(nullValue()));
56+
assertNull(reader);
5957
}
6058
}
6159

@@ -75,15 +73,15 @@ public void getReaderNullRootAndNullResourceThrowsNullPointer() throws Exception
7573
public void getReaderWithRootAndResourceHasDoubleDotRelativePath() throws Exception {
7674
ClasspathResolver underTest = new ClasspathResolver("templates");
7775
try (Reader reader = underTest.getReader("absolute/../absolute_partials_template.html")) {
78-
assertThat(reader, is(notNullValue()));
76+
assertNotNull(reader);
7977
}
8078
}
8179

8280
@Test
8381
public void getReaderWithRootAndResourceHasDotRelativePath() throws Exception {
8482
ClasspathResolver underTest = new ClasspathResolver("templates");
8583
try (Reader reader = underTest.getReader("absolute/./nested_partials_sub.html")) {
86-
assertThat(reader, is(notNullValue()));
84+
assertNotNull(reader);
8785
}
8886
}
8987

@@ -106,7 +104,7 @@ public void getReaderWithRootAndResourceHasInvalidPathThrows() throws Exception
106104
public void getReaderNullRootAndResourceIsDirectory() throws Exception {
107105
ClasspathResolver underTest = new ClasspathResolver();
108106
try (Reader reader = underTest.getReader("templates/absolute")) {
109-
assertThat(reader, is(nullValue()));
107+
assertNull(reader);
110108
}
111109
}
112110

@@ -115,7 +113,7 @@ public void getReaderNullRootAndResourceIsDirectory() throws Exception {
115113
public void getReaderWithRootAndResourceIsDirectory() throws Exception {
116114
ClasspathResolver underTest = new ClasspathResolver("templates");
117115
try (Reader reader = underTest.getReader("absolute")) {
118-
assertThat(reader, is(nullValue()));
116+
assertNull(reader);
119117
}
120118
}
121119

@@ -124,7 +122,7 @@ public void getReaderWithRootAndResourceIsDirectory() throws Exception {
124122
public void getReaderWithRootAndResourceAboveRoot() throws Exception {
125123
ClasspathResolver underTest = new ClasspathResolver("templates/absolute");
126124
try (Reader reader = underTest.getReader("../absolute_partials_template.html")) {
127-
assertThat(reader, is(notNullValue()));
125+
assertNotNull(reader);
128126
}
129127
}
130128
}

compiler/src/test/java/com/github/mustachejava/resolver/FileSystemResolverTest.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
import java.nio.file.Path;
1111
import java.nio.file.Paths;
1212

13-
import static org.hamcrest.CoreMatchers.notNullValue;
14-
import static org.hamcrest.CoreMatchers.nullValue;
15-
import static org.hamcrest.core.Is.is;
16-
import static org.junit.Assert.assertThat;
13+
import static org.junit.Assert.assertNotNull;
14+
import static org.junit.Assert.assertNull;
1715

1816
public class FileSystemResolverTest {
1917

@@ -23,7 +21,7 @@ public class FileSystemResolverTest {
2321
public void getReaderDefaultRootAndResourceHasRelativePath() throws Exception {
2422
FileSystemResolver underTest = new FileSystemResolver();
2523
try (Reader reader = underTest.getReader(resources + "/nested_partials_template.html")) {
26-
assertThat(reader, is(notNullValue()));
24+
assertNotNull(reader);
2725
}
2826
}
2927

@@ -32,7 +30,7 @@ public void getReaderFileRootAndResourceHasRelativePath() throws Exception {
3230
File fileRoot = new File(resources + "/templates_filepath");
3331
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
3432
try (Reader reader = underTest.getReader("absolute_partials_template.html")) {
35-
assertThat(reader, is(notNullValue()));
33+
assertNotNull(reader);
3634
}
3735
}
3836

@@ -41,15 +39,15 @@ public void getReaderPathRootAndResourceHasRelativePath() throws Exception {
4139
Path pathRoot = Paths.get(resources + "/templates_filepath");
4240
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
4341
try (Reader reader = underTest.getReader("absolute_partials_template.html")) {
44-
assertThat(reader, is(notNullValue()));
42+
assertNotNull(reader);
4543
}
4644
}
4745

4846
@Test
4947
public void getReaderDefaultRootDoesNotFindFileWithAbsolutePath() throws Exception {
5048
FileSystemResolver underTest = new FileSystemResolver();
5149
try (Reader reader = underTest.getReader("/" + resources + "/nested_partials_template.html")) {
52-
assertThat(reader, is(nullValue()));
50+
assertNull(reader);
5351
}
5452
}
5553

@@ -58,7 +56,7 @@ public void getReaderFileRootAndResourceHasAbsolutePath() throws Exception {
5856
File fileRoot = new File(resources + "/templates_filepath");
5957
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
6058
try (Reader reader = underTest.getReader("/absolute_partials_template.html")) {
61-
assertThat(reader, is(notNullValue()));
59+
assertNotNull(reader);
6260
}
6361
}
6462

@@ -67,7 +65,7 @@ public void getReaderPathRootAndResourceHasAbsolutePath() throws Exception {
6765
Path pathRoot = Paths.get(resources + "/templates_filepath");
6866
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
6967
try (Reader reader = underTest.getReader("/absolute_partials_template.html")) {
70-
assertThat(reader, is(notNullValue()));
68+
assertNotNull(reader);
7169
}
7270
}
7371

@@ -95,7 +93,7 @@ public void getReaderPathRootAndNullResourceThrowsNullPointer() throws Exception
9593
public void getReaderDefaultRootAndResourceHasDoubleDotRelativePath() throws Exception {
9694
FileSystemResolver underTest = new FileSystemResolver();
9795
try (Reader reader = underTest.getReader(resources + "/templates_filepath/../nested_partials_template.html")) {
98-
assertThat(reader, is(notNullValue()));
96+
assertNotNull(reader);
9997
}
10098
}
10199

@@ -104,7 +102,7 @@ public void getReaderFileRootAndResourceHasDoubleDotRelativePath() throws Except
104102
File fileRoot = new File(resources + "/templates_filepath");
105103
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
106104
try (Reader reader = underTest.getReader("absolute/../absolute_partials_template.html")) {
107-
assertThat(reader, is(notNullValue()));
105+
assertNotNull(reader);
108106
}
109107
}
110108

@@ -113,15 +111,15 @@ public void getReaderPathRootAndResourceHasDoubleDotRelativePath() throws Except
113111
Path pathRoot = Paths.get(resources + "/templates_filepath");
114112
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
115113
try (Reader reader = underTest.getReader("absolute/../absolute_partials_template.html")) {
116-
assertThat(reader, is(notNullValue()));
114+
assertNotNull(reader);
117115
}
118116
}
119117

120118
@Test
121119
public void getReaderDefaultRootAndResourceHasDotRelativePath() throws Exception {
122120
FileSystemResolver underTest = new FileSystemResolver();
123121
try (Reader reader = underTest.getReader(resources + "/templates_filepath/./absolute_partials_template.html")) {
124-
assertThat(reader, is(notNullValue()));
122+
assertNotNull(reader);
125123
}
126124
}
127125

@@ -130,7 +128,7 @@ public void getReaderFileRootAndResourceHasDotRelativePath() throws Exception {
130128
File fileRoot = new File(resources + "/templates_filepath");
131129
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
132130
try (Reader reader = underTest.getReader("absolute/./nested_partials_sub.html")) {
133-
assertThat(reader, is(notNullValue()));
131+
assertNotNull(reader);
134132
}
135133
}
136134

@@ -139,15 +137,15 @@ public void getReaderPathRootAndResourceHasDotRelativePath() throws Exception {
139137
Path pathRoot = Paths.get(resources + "/templates_filepath");
140138
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
141139
try (Reader reader = underTest.getReader("absolute/./nested_partials_sub.html")) {
142-
assertThat(reader, is(notNullValue()));
140+
assertNotNull(reader);
143141
}
144142
}
145143

146144
@Test
147145
public void getReaderDefaultRootAndResourceHasInvalidPath() throws Exception {
148146
FileSystemResolver underTest = new FileSystemResolver();
149147
try (Reader reader = underTest.getReader("\0")) {
150-
assertThat(reader, is(nullValue()));
148+
assertNull(reader);
151149
}
152150
}
153151

@@ -156,7 +154,7 @@ public void getReaderFileRootAndResourceHasInvalidPath() throws Exception {
156154
File fileRoot = new File(resources + "/templates_filepath");
157155
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
158156
try (Reader reader = underTest.getReader("\0")) {
159-
assertThat(reader, is(nullValue()));
157+
assertNull(reader);
160158
}
161159
}
162160

@@ -165,7 +163,7 @@ public void getReaderPathRootAndResourceHasInvalidPath() throws Exception {
165163
Path pathRoot = Paths.get(resources + "/templates_filepath");
166164
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
167165
try (Reader reader = underTest.getReader("\0")) {
168-
assertThat(reader, is(nullValue()));
166+
assertNull(reader);
169167
}
170168
}
171169

@@ -176,7 +174,7 @@ public void getReaderPathRootAndNonDefaultFileSystem() throws Exception {
176174
Path pathRoot = zipFileSystem.getPath("templates");
177175
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
178176
try (Reader reader = underTest.getReader("absolute_partials_template.html")) {
179-
assertThat(reader, is(notNullValue()));
177+
assertNotNull(reader);
180178
}
181179
}
182180
}
@@ -185,7 +183,7 @@ public void getReaderPathRootAndNonDefaultFileSystem() throws Exception {
185183
public void getReaderDefaultRootAndResourceIsDirectory() throws Exception {
186184
FileSystemResolver underTest = new FileSystemResolver();
187185
try (Reader reader = underTest.getReader(resources + "/templates_filepath")) {
188-
assertThat(reader, is(nullValue()));
186+
assertNull(reader);
189187
}
190188
}
191189

@@ -194,7 +192,7 @@ public void getReaderFileRootAndResourceIsDirectory() throws Exception {
194192
File fileRoot = new File(resources);
195193
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
196194
try (Reader reader = underTest.getReader("templates_filepath")) {
197-
assertThat(reader, is(nullValue()));
195+
assertNull(reader);
198196
}
199197
}
200198

@@ -203,7 +201,7 @@ public void getReaderPathRootAndResourceIsDirectory() throws Exception {
203201
Path pathRoot = Paths.get(resources);
204202
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
205203
try (Reader reader = underTest.getReader("templates_filepath")) {
206-
assertThat(reader, is(nullValue()));
204+
assertNull(reader);
207205
}
208206
}
209207

@@ -214,7 +212,7 @@ public void getReaderPathRootAndResourceIsDirectory() throws Exception {
214212
public void getReaderDefaultRootAndResourceAboveRootNotFound() throws Exception {
215213
FileSystemResolver underTest = new FileSystemResolver();
216214
try (Reader reader = underTest.getReader("../this_file_does_not_exist.html")) {
217-
assertThat(reader, is(nullValue()));
215+
assertNull(reader);
218216
}
219217
}
220218

@@ -230,7 +228,7 @@ public void getReaderFileRootAndResourceAboveRootNotFound() throws Exception {
230228
File fileRoot = new File(resources + "/templates_filepath");
231229
FileSystemResolver underTest = new FileSystemResolver(fileRoot);
232230
try (Reader reader = underTest.getReader("../this_file_does_not_exist.html")) {
233-
assertThat(reader, is(nullValue()));
231+
assertNull(reader);
234232
}
235233
}
236234

@@ -246,7 +244,7 @@ public void getReaderPathRootAndResourceAboveRootNotFound() throws Exception {
246244
Path pathRoot = Paths.get(resources + "/templates_filepath");
247245
FileSystemResolver underTest = new FileSystemResolver(pathRoot);
248246
try (Reader reader = underTest.getReader("../this_file_does_not_exist.html")) {
249-
assertThat(reader, is(nullValue()));
247+
assertNull(reader);
250248
}
251249
}
252250
}

0 commit comments

Comments
 (0)