Skip to content

Commit

Permalink
Remove usage of jUnit 3.x TestCase
Browse files Browse the repository at this point in the history
Align the test suite with junit 4.x APIs.

Convert BenchmarkTest into a junit test.
  • Loading branch information
rhowe authored and spullara committed Feb 26, 2024
1 parent 761f226 commit 5c3735e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.github.mustachejava.util;

import junit.framework.TestCase;
import org.junit.Test;

import java.io.StringWriter;

import static com.github.mustachejava.util.HtmlEscaper.escape;
import static org.junit.Assert.assertEquals;

public class HtmlEscaperTest extends TestCase {
public void testEscape() throws Exception {
public class HtmlEscaperTest {
@Test
public void testEscape() {
{
StringWriter sw = new StringWriter();
escape("Hello, world!", sw);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.github.mustachejavabenchmarks;

import com.github.mustachejava.*;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
Expand All @@ -15,21 +16,21 @@
* Date: 5/14/11
* Time: 9:28 PM
*/
public class BenchmarkTest extends TestCase {
public class BenchmarkTest {
private static final int TIME = 2000;
protected File root;

protected void setUp() throws Exception {
super.setUp();
@Before
public void setUp() throws Exception {
File file = new File("src/test/resources");
root = new File(file, "simple.html").exists() ? file : new File("../src/test/resources");

}

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

@Test
public void testCompiler() {
if (skip()) return;
System.out.println("complex.html compilations per second:");
Expand All @@ -48,6 +49,7 @@ public void testCompiler() {
}
}

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

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

@Test
public void testParallelComplex() throws MustacheException, IOException {
if (skip()) return;
System.out.println("complex.html evaluations per millisecond:");
Expand All @@ -117,6 +121,7 @@ public void testParallelComplex() throws MustacheException, IOException {
}
}

@Test
public void testParallelComplexNoExecutor() throws MustacheException, IOException {
if (skip()) return;
System.out.println("complex.html evaluations per millisecond:");
Expand All @@ -142,14 +147,4 @@ private Writer complextest(Mustache m, Object complexObject) throws MustacheExce
m.execute(sw, complexObject).close();
return sw;
}

public static void main(String[] args) throws Exception {
BenchmarkTest benchmarkTest = new BenchmarkTest();
benchmarkTest.setUp();
benchmarkTest.testComplex();
benchmarkTest.testParallelComplex();
benchmarkTest.testParallelComplexNoExecutor();
System.exit(0);
}

}

0 comments on commit 5c3735e

Please sign in to comment.