예제 #1
0
 private void verifyAssembly(String templateName) throws Exception {
   StringWriter output = new StringWriter();
   assembler.assemble(
       createClassPathUrl("templates/" + templateName + ".xhtml"), namespace, output);
   String expectedOutput = loadText(createClassPathUrl("solutions/" + templateName + ".html"));
   assertEquals(expectedOutput, output.toString());
 }
예제 #2
0
  @Test
  public void testMinimalTemplate() throws Exception {
    final String INPUT = "<html xmlns=\"http://www.w3.org/1999/xhtml\"/>";
    final String EXPECTED_OUTPUT =
        "<!DOCTYPE html>\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\"/>";

    StringWriter output = new StringWriter();
    assembler.assemble(createLiteralUrl(INPUT), output);
    assertEquals(EXPECTED_OUTPUT, output.toString());
  }
예제 #3
0
  @Test
  public void testMissingDocumentElement() throws Exception {
    final String INPUT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

    Throwable error = null;
    try {
      assembler.assemble(createLiteralUrl(INPUT), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    assertNotNull(error);
  }
예제 #4
0
  @Test
  public void testBadInputPath() throws Exception {
    final String BAD_PATH = "no-such";

    Throwable error = null;
    try {
      assembler.assemble(createClassPathUrl(BAD_PATH), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    assertEquals(BAD_PATH, error.getMessage());
  }
예제 #5
0
  @Test
  public void testConflictingIncludeAndContent() throws Exception {
    final String INPUT =
        "<html xmlns=\"http://www.w3.org/1999/xhtml\""
            + " xmlns:dwc=\"http://shopximity.com/schema/dwc\""
            + " dwc:content=\"\""
            + " dwc:include=\"\"/>";

    Throwable error = null;
    try {
      assembler.assemble(createLiteralUrl(INPUT), new StringWriter());
    } catch (AssemblerException e) {
      error = e.getCause();
    }
    // TODO: assert that the error message contains meaningful information.
    assertNotNull(error);
  }