package j2html;

import j2html.utils.SimpleEscaper;
import j2html.utils.TextEscaper;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;

public class TextEscaperTest {

    @Test
    public void testTextEscaper() throws Exception  {
        assertThat("default text escaper is SimpleEscaper",
                Config.textEscaper, is(instanceOf(SimpleEscaper.class)));

        String expected = "&lt;div&gt;&lt;/div&gt;";
        assertThat("default text escaper works",
                Config.textEscaper.escape("<div></div>"), is(expected));

        Config.textEscaper = new NoOpEscaper();
        assertThat("user can change text escaper implementation",
                Config.textEscaper, is(instanceOf(NoOpEscaper.class)));

        expected = "<div></div>";
        assertThat("user provided text escaper actually works",
                Config.textEscaper.escape("<div></div>"), is(expected));
    }

    private static class NoOpEscaper implements TextEscaper {

        @Override
        public String escape(String text) {
            return text;
        }

    }

}

@@ -10,16 +10,40 @@
 2html;%0A%0A
+import org.junit.Test;%0A%0A
 import j
@@ -101,39 +101,16 @@
 Escaper;
-%0Aimport org.junit.Test;
 %0A%0Aimport
@@ -144,26 +144,17 @@
 rAssert.
-assertThat
+*
 ;%0Aimport
@@ -187,58 +187,9 @@
 ers.
-instanceOf;%0Aimport static org.hamcrest.Matchers.is
+*
 ;%0A%0Ap
@@ -280,17 +280,16 @@
 ception 
- 
 %7B%0A      
@@ -342,16 +342,19 @@
 caper%22,%0A
+   
         
@@ -530,32 +530,35 @@
                 
+   
 Config.textEscap
@@ -721,32 +721,35 @@
                 
+   
 Config.textEscap
@@ -895,32 +895,35 @@
                 
+   
 Config.textEscap
@@ -963,16 +963,83 @@
 cted));%0A
+        Config.textEscaper = new SimpleEscaper(); // reset escaper%0A
     %7D%0A%0A 

Fix escaper-test