Skip to content

Commit 5c3735e

Browse files
rhowespullara
authored andcommitted
Remove usage of jUnit 3.x TestCase
Align the test suite with junit 4.x APIs. Convert BenchmarkTest into a junit test.
1 parent 761f226 commit 5c3735e

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

compiler/src/test/java/com/github/mustachejava/util/HtmlEscaperTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.github.mustachejava.util;
22

3-
import junit.framework.TestCase;
3+
import org.junit.Test;
44

55
import java.io.StringWriter;
66

77
import static com.github.mustachejava.util.HtmlEscaper.escape;
8+
import static org.junit.Assert.assertEquals;
89

9-
public class HtmlEscaperTest extends TestCase {
10-
public void testEscape() throws Exception {
10+
public class HtmlEscaperTest {
11+
@Test
12+
public void testEscape() {
1113
{
1214
StringWriter sw = new StringWriter();
1315
escape("Hello, world!", sw);

compiler/src/test/java/com/github/mustachejavabenchmarks/BenchmarkTest.java

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.github.mustachejavabenchmarks;
22

33
import com.github.mustachejava.*;
4-
import junit.framework.TestCase;
4+
import org.junit.Before;
5+
import org.junit.Test;
56

67
import java.io.File;
78
import java.io.IOException;
@@ -15,21 +16,21 @@
1516
* Date: 5/14/11
1617
* Time: 9:28 PM
1718
*/
18-
public class BenchmarkTest extends TestCase {
19+
public class BenchmarkTest {
1920
private static final int TIME = 2000;
2021
protected File root;
2122

22-
protected void setUp() throws Exception {
23-
super.setUp();
23+
@Before
24+
public void setUp() throws Exception {
2425
File file = new File("src/test/resources");
2526
root = new File(file, "simple.html").exists() ? file : new File("../src/test/resources");
26-
2727
}
2828

2929
public static boolean skip() {
3030
return System.getenv().containsKey("CI") || System.getProperty("CI") != null;
3131
}
3232

33+
@Test
3334
public void testCompiler() {
3435
if (skip()) return;
3536
System.out.println("complex.html compilations per second:");
@@ -48,6 +49,7 @@ public void testCompiler() {
4849
}
4950
}
5051

52+
@Test
5153
public void testComplex() throws MustacheException, IOException {
5254
if (skip()) return;
5355
System.out.println("complex.html evaluations per millisecond:");
@@ -73,6 +75,7 @@ protected DefaultMustacheFactory createMustacheFactory() {
7375
return new DefaultMustacheFactory();
7476
}
7577

78+
@Test
7679
public void testComplexFlapping() throws MustacheException, IOException {
7780
if (skip()) return;
7881
System.out.println("complex.html evaluations with 3 different objects per millisecond:");
@@ -96,6 +99,7 @@ public void testComplexFlapping() throws MustacheException, IOException {
9699
}
97100
}
98101

102+
@Test
99103
public void testParallelComplex() throws MustacheException, IOException {
100104
if (skip()) return;
101105
System.out.println("complex.html evaluations per millisecond:");
@@ -117,6 +121,7 @@ public void testParallelComplex() throws MustacheException, IOException {
117121
}
118122
}
119123

124+
@Test
120125
public void testParallelComplexNoExecutor() throws MustacheException, IOException {
121126
if (skip()) return;
122127
System.out.println("complex.html evaluations per millisecond:");
@@ -142,14 +147,4 @@ private Writer complextest(Mustache m, Object complexObject) throws MustacheExce
142147
m.execute(sw, complexObject).close();
143148
return sw;
144149
}
145-
146-
public static void main(String[] args) throws Exception {
147-
BenchmarkTest benchmarkTest = new BenchmarkTest();
148-
benchmarkTest.setUp();
149-
benchmarkTest.testComplex();
150-
benchmarkTest.testParallelComplex();
151-
benchmarkTest.testParallelComplexNoExecutor();
152-
System.exit(0);
153-
}
154-
155150
}

0 commit comments

Comments
 (0)