Update FreeMarker template for windows testing
@@ -20,7 +20,6 @@ import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.file.FileSystemOptions;
import io.vertx.core.json.JsonObject;
-import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.ext.web.common.template.TemplateEngine;
@@ -51,37 +50,28 @@ public class FreeMarkerTemplateNoCacheTest {
System.setProperty("vertxweb.environment", "development");
TemplateEngine engine = FreeMarkerTemplateEngine.create(vertx);
- final Async test = should.async();
-
- PrintWriter out;
File temp = File.createTempFile("template", ".ftl", new File("target/classes"));
temp.deleteOnExit();
- out = new PrintWriter(temp);
+ try (PrintWriter out = new PrintWriter(temp)) {
out.print("before");
out.flush();
- out.close();
+ }
- engine.render(new JsonObject(), temp.getName(), render -> {
- should.assertTrue(render.succeeded());
- should.assertEquals("before", render.result().toString());
+ engine.render(new JsonObject(), temp.getName(), should.asyncAssertSuccess(render -> {
+ should.assertEquals("before", FreeMarkerTemplateTest.normalizeCRLF(render.toString()));
// cache is enabled so if we change the content that should not affect the result
- try {
- PrintWriter out2 = new PrintWriter(temp);
+ try (PrintWriter out2 = new PrintWriter(temp)) {
out2.print("after");
out2.flush();
- out2.close();
} catch (IOException e) {
should.fail(e);
}
- engine.render(new JsonObject(), temp.getName(), render2 -> {
- should.assertTrue(render2.succeeded());
- should.assertEquals("after", render2.result().toString());
- test.complete();
- });
- });
- test.await();
+ engine.render(new JsonObject(), temp.getName(), should.asyncAssertSuccess(render2 -> {
+ should.assertEquals("after", FreeMarkerTemplateTest.normalizeCRLF(render2.toString()));
+ }));
+ }));
}
}
