Skip to content

Commit b7b999a

Browse files
build: junit 5
- migrate tests to use junit 5 platform
1 parent 5ba0ea0 commit b7b999a

File tree

271 files changed

+1220
-1286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+1220
-1286
lines changed

.travis.yml

-9
This file was deleted.

handlebars-caffeine/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
</dependency>
5151

5252
<dependency>
53-
<groupId>junit</groupId>
54-
<artifactId>junit</artifactId>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-engine</artifactId>
5555
<scope>test</scope>
5656
</dependency>
5757

handlebars-caffeine/src/test/java/com/github/jknack/handlebars/cache/CaffeineTemplateCacheTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
package com.github.jknack.handlebars.cache;
77

8-
import static org.junit.Assert.assertEquals;
9-
import static org.junit.Assert.fail;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.fail;
1010
import static org.mockito.ArgumentMatchers.eq;
1111
import static org.mockito.Mockito.mock;
1212
import static org.mockito.Mockito.verify;
@@ -15,7 +15,7 @@
1515
import java.io.IOException;
1616
import java.util.function.Function;
1717

18-
import org.junit.Test;
18+
import org.junit.jupiter.api.Test;
1919
import org.mockito.ArgumentCaptor;
2020

2121
import com.github.benmanes.caffeine.cache.Cache;

handlebars-guava-cache/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
</dependency>
5252

5353
<dependency>
54-
<groupId>junit</groupId>
55-
<artifactId>junit</artifactId>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-engine</artifactId>
5656
<scope>test</scope>
5757
</dependency>
5858

handlebars-guava-cache/src/test/java/com/github/jknack/handlebars/cache/GuavaTemplateCacheTest.java

+39-25
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
package com.github.jknack.handlebars.cache;
77

8-
import static org.junit.Assert.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
99
import static org.mockito.ArgumentMatchers.any;
1010
import static org.mockito.ArgumentMatchers.eq;
1111
import static org.mockito.ArgumentMatchers.same;
@@ -17,7 +17,8 @@
1717
import java.util.concurrent.Callable;
1818
import java.util.concurrent.ExecutionException;
1919

20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2122

2223
import com.github.jknack.handlebars.HandlebarsException;
2324
import com.github.jknack.handlebars.Parser;
@@ -108,50 +109,63 @@ public void clear() throws IOException {
108109
}
109110

110111
@SuppressWarnings("unchecked")
111-
@Test(expected = IllegalStateException.class)
112+
@Test
112113
public void executionExceptionWithRuntimeException() throws IOException, ExecutionException {
113-
TemplateSource source = mock(TemplateSource.class);
114+
Assertions.assertThrows(
115+
IllegalStateException.class,
116+
() -> {
117+
TemplateSource source = mock(TemplateSource.class);
114118

115-
Parser parser = mock(Parser.class);
119+
Parser parser = mock(Parser.class);
116120

117-
Cache<TemplateSource, Template> cache = mock(Cache.class);
118-
when(cache.get(eq(source), any(Callable.class)))
119-
.thenThrow(new ExecutionException(new IllegalStateException()));
121+
Cache<TemplateSource, Template> cache = mock(Cache.class);
122+
when(cache.get(eq(source), any(Callable.class)))
123+
.thenThrow(new ExecutionException(new IllegalStateException()));
120124

121-
new GuavaTemplateCache(cache).get(source, parser);
125+
new GuavaTemplateCache(cache).get(source, parser);
122126

123-
verify(cache).get(eq(source), any(Callable.class));
127+
verify(cache).get(eq(source), any(Callable.class));
128+
});
124129
}
125130

126131
@SuppressWarnings("unchecked")
127-
@Test(expected = Error.class)
132+
@Test
128133
public void executionExceptionWithError() throws IOException, ExecutionException {
129-
TemplateSource source = mock(TemplateSource.class);
134+
Assertions.assertThrows(
135+
Error.class,
136+
() -> {
137+
TemplateSource source = mock(TemplateSource.class);
130138

131-
Parser parser = mock(Parser.class);
139+
Parser parser = mock(Parser.class);
132140

133-
Cache<TemplateSource, Template> cache = mock(Cache.class);
134-
when(cache.get(eq(source), any(Callable.class))).thenThrow(new ExecutionException(new Error()));
141+
Cache<TemplateSource, Template> cache = mock(Cache.class);
142+
when(cache.get(eq(source), any(Callable.class)))
143+
.thenThrow(new ExecutionException(new Error()));
135144

136-
new GuavaTemplateCache(cache).get(source, parser);
145+
new GuavaTemplateCache(cache).get(source, parser);
137146

138-
verify(cache).get(eq(source), any(Callable.class));
147+
verify(cache).get(eq(source), any(Callable.class));
148+
});
139149
}
140150

141151
@SuppressWarnings("unchecked")
142-
@Test(expected = HandlebarsException.class)
152+
@Test
143153
public void executionExceptionWithCheckedException() throws IOException, ExecutionException {
144-
TemplateSource source = mock(TemplateSource.class);
154+
Assertions.assertThrows(
155+
HandlebarsException.class,
156+
() -> {
157+
TemplateSource source = mock(TemplateSource.class);
145158

146-
Parser parser = mock(Parser.class);
159+
Parser parser = mock(Parser.class);
147160

148-
Cache<TemplateSource, Template> cache = mock(Cache.class);
149-
when(cache.get(eq(source), any(Callable.class)))
150-
.thenThrow(new ExecutionException(new IOException()));
161+
Cache<TemplateSource, Template> cache = mock(Cache.class);
162+
when(cache.get(eq(source), any(Callable.class)))
163+
.thenThrow(new ExecutionException(new IOException()));
151164

152-
new GuavaTemplateCache(cache).get(source, parser);
165+
new GuavaTemplateCache(cache).get(source, parser);
153166

154-
verify(cache).get(eq(source), any(Callable.class));
167+
verify(cache).get(eq(source), any(Callable.class));
168+
});
155169
}
156170

157171
private TemplateSource source(final String filename) throws IOException {

handlebars-guava-cache/src/test/java/com/github/jknack/handlebars/i371/Issue371.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.github.jknack.handlebars.AbstractTest;
1313
import com.google.common.collect.ImmutableList;

handlebars-guava-cache/src/test/java/com/github/jknack/handlebars/io/GuavaCachedTemplateLoaderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
package com.github.jknack.handlebars.io;
77

88
import static java.lang.System.out;
9-
import static org.junit.Assert.assertNotNull;
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1010

1111
import java.io.File;
1212
import java.util.concurrent.TimeUnit;
1313

14-
import org.junit.Test;
14+
import org.junit.jupiter.api.Test;
1515

1616
import com.google.common.base.Stopwatch;
1717

handlebars-helpers/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
</dependency>
5858

5959
<dependency>
60-
<groupId>junit</groupId>
61-
<artifactId>junit</artifactId>
60+
<groupId>org.junit.jupiter</groupId>
61+
<artifactId>junit-jupiter-engine</artifactId>
6262
<scope>test</scope>
6363
</dependency>
6464

handlebars-helpers/src/test/java/com/github/jknack/handlebars/helper/AssignHelperTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
package com.github.jknack.handlebars.helper;
77

8-
import static org.junit.Assert.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
99

1010
import java.io.IOException;
1111

12-
import org.junit.Test;
12+
import org.junit.jupiter.api.Test;
1313

1414
import com.github.jknack.handlebars.AbstractTest;
1515
import com.github.jknack.handlebars.Context;

handlebars-helpers/src/test/java/com/github/jknack/handlebars/helper/IncludeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.github.jknack.handlebars.AbstractTest;
1313
import com.github.jknack.handlebars.Handlebars;

handlebars-helpers/src/test/java/com/github/jknack/handlebars/helper/JodaHelperTest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*/
66
package com.github.jknack.handlebars.helper;
77

8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.fail;
10+
811
import java.io.IOException;
912

1013
import org.joda.time.DateTime;
1114
import org.joda.time.DateTimeZone;
12-
import org.junit.Assert;
13-
import org.junit.Test;
15+
import org.junit.jupiter.api.Test;
1416

1517
import com.github.jknack.handlebars.AbstractTest;
1618
import com.github.jknack.handlebars.Handlebars;
@@ -44,10 +46,10 @@ public void testBadPattern() throws IOException {
4446
DateTime dateTime = new DateTime().withDate(1995, 7, 4).withTime(14, 32, 12, 0);
4547
try {
4648
shouldCompileTo("{{jodaPatternHelper this \"qwerty\"}}", dateTime, "1995-Jul-4 14:32:12");
47-
Assert.fail("Exception should have thrown!");
49+
fail("Exception should have thrown!");
4850
} catch (HandlebarsException e) {
4951
Throwable t = e.getCause();
50-
Assert.assertEquals("Illegal pattern component: q", t.getMessage());
52+
assertEquals("Illegal pattern component: q", t.getMessage());
5153
}
5254
}
5355

@@ -69,7 +71,7 @@ public void testBadStyle() throws IOException {
6971
shouldCompileTo("{{jodaStyleHelper this \"QS\"}}", dateTime, "");
7072
} catch (HandlebarsException e) {
7173
Throwable t = e.getCause();
72-
Assert.assertEquals("Invalid style character: Q", t.getMessage());
74+
assertEquals("Invalid style character: Q", t.getMessage());
7375
}
7476
}
7577

handlebars-helpers/src/test/java/com/github/jknack/handlebars/helper/NumberHelperTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.github.jknack.handlebars.AbstractTest;
1313
import com.github.jknack.handlebars.Handlebars;

handlebars-jackson2/pom.xml

+9-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
</dependency>
5050

5151
<dependency>
52-
<groupId>junit</groupId>
53-
<artifactId>junit</artifactId>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-engine</artifactId>
5454
<scope>test</scope>
5555
</dependency>
5656

@@ -59,6 +59,13 @@
5959
<artifactId>mockito-core</artifactId>
6060
<scope>test</scope>
6161
</dependency>
62+
63+
<dependency>
64+
<groupId>org.hamcrest</groupId>
65+
<artifactId>hamcrest</artifactId>
66+
<version>2.2</version>
67+
<scope>test</scope>
68+
</dependency>
6269
</dependencies>
6370

6471
</project>

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/Issue260.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.fasterxml.jackson.databind.JsonNode;
1313
import com.fasterxml.jackson.databind.ObjectMapper;

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/Issue412.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.fasterxml.jackson.databind.JsonNode;
1313
import com.fasterxml.jackson.databind.ObjectMapper;

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/Issue598.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.fasterxml.jackson.databind.JsonNode;
1313
import com.fasterxml.jackson.databind.ObjectMapper;

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/Jackson2HelperTest.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import java.util.HashMap;
1313
import java.util.Map;
1414

15-
import org.junit.Test;
15+
import org.junit.jupiter.api.Assertions;
16+
import org.junit.jupiter.api.Test;
1617

1718
import com.fasterxml.jackson.databind.MapperFeature;
1819
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -107,20 +108,24 @@ public void toJSONAliasViewExclusive() throws IOException {
107108
equalsToStringIgnoringWindowsNewLine("{\"title\":\"First Post\"}"));
108109
}
109110

110-
@Test(expected = HandlebarsException.class)
111+
@Test
111112
public void jsonViewNotFound() throws IOException {
112-
Handlebars handlebars = new Handlebars();
113+
Assertions.assertThrows(
114+
HandlebarsException.class,
115+
() -> {
116+
Handlebars handlebars = new Handlebars();
113117

114-
ObjectMapper mapper = new ObjectMapper();
115-
mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
118+
ObjectMapper mapper = new ObjectMapper();
119+
mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
116120

117-
handlebars.registerHelper("@json", new Jackson2Helper(mapper));
121+
handlebars.registerHelper("@json", new Jackson2Helper(mapper));
118122

119-
Template template = handlebars.compileInline("{{@json this view=\"missing.ViewClass\"}}");
123+
Template template = handlebars.compileInline("{{@json this view=\"missing.ViewClass\"}}");
120124

121-
assertThat(
122-
template.apply(new Blog("First Post", "...")),
123-
equalsToStringIgnoringWindowsNewLine("{\"title\":\"First Post\"}"));
125+
assertThat(
126+
template.apply(new Blog("First Post", "...")),
127+
equalsToStringIgnoringWindowsNewLine("{\"title\":\"First Post\"}"));
128+
});
124129
}
125130

126131
@Test

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/JsonNodeValueResolverTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
package com.github.jknack.handlebars;
77

8-
import static org.junit.Assert.assertEquals;
9-
import static org.junit.Assert.assertNotNull;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1010
import static org.mockito.Mockito.mock;
1111
import static org.mockito.Mockito.verify;
1212
import static org.mockito.Mockito.when;
@@ -20,7 +20,7 @@
2020
import java.util.Map.Entry;
2121
import java.util.Set;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
import com.fasterxml.jackson.databind.JsonNode;
2626
import com.fasterxml.jackson.databind.ObjectMapper;

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/i280/Issue280.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
package com.github.jknack.handlebars.i280;
77

8-
import org.junit.Test;
8+
import org.junit.jupiter.api.Test;
99

1010
import com.fasterxml.jackson.databind.JsonNode;
1111
import com.fasterxml.jackson.databind.ObjectMapper;

handlebars-jackson2/src/test/java/com/github/jknack/handlebars/i368/Issue368.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.io.IOException;
99

10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
import com.fasterxml.jackson.databind.JsonNode;
1313
import com.fasterxml.jackson.databind.ObjectMapper;

0 commit comments

Comments
 (0)