MCPcopy Create free account
hub / github.com/xmlet/HtmlFlow / FlowifierTest

Class FlowifierTest

flowifier/src/test/java/htmlflow/flowifier/FlowifierTest.java:31–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29import static org.junit.Assert.assertEquals;
30
31public class FlowifierTest {
32
33 /**
34 * A file object used to represent source coming from a string.
35 */
36 private static final class JavaSourceFromString extends SimpleJavaFileObject {
37 /**
38 * The source code of this "file".
39 */
40 private final String code;
41
42 /**
43 * Constructs a new JavaSourceFromString.
44 *
45 * @param name
46 * the name of the compilation unit represented by this file
47 * object
48 * @param code
49 * the source code for the compilation unit represented by
50 * this file object
51 */
52 private JavaSourceFromString(String name, String code) {
53 super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
54 this.code = code;
55 }
56
57 @Override
58 public CharSequence getCharContent(boolean ignoreEncodingErrors) {
59 return code;
60 }
61 }
62
63 @Test
64 public void testFlowifierWithGamboa() throws Exception {
65 testFlowifier("https://gamboa.pt/");
66 }
67
68 @Test
69 public void testFlowifierWithEclemmaOrg() throws Exception {
70 testFlowifier("https://www.eclemma.org/");
71 }
72
73 @Test
74 public void testSample05ForFlowifier() {
75 String src = "<!DOCTYPE html>" +
76 "<html>" +
77 "<head><title>HtmlFlow</title></head>" +
78 "<body>" +
79 "<div class=\"container\">" +
80 "<h1>My first page with HtmlFlow</h1>" +
81 "<img src=\"https://avatars1.githubusercontent.com/u/35267172\">" +
82 "<p>Typesafe is awesome! :-)</p>" +
83 "</div>" +
84 "</body>" +
85 "</html>";
86 String actual = Flowifier.fromHtml(src);
87 Iterator<String> iter = Arrays.asList(actual.split("\n")).iterator();
88 Assert.assertEquals(true, iter.hasNext());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected