Package org.apache.wookie.util.html

Examples of org.apache.wookie.util.html.HtmlCleaner.process()


    String out = "";
    StringWriter writer = new StringWriter();
    try {
      cleaner.setReader(new StringReader(content));
      cleaner.injectScript("inject.js");
      cleaner.process(writer);
      out = writer.getBuffer().toString();
      assertEquals("<html><head><script type=\"text/javascript\" src=\"inject.js\"></script><script type=\"text/javascript\" src=\"user.js\"></script></head><body></body></html>", out);
    } catch (IOException e) {
      fail();
    }
View Full Code Here


    String out = "";
    StringWriter writer = new StringWriter();
    try {
      cleaner.setReader(new StringReader(content));
      cleaner.injectScript("inject.js");
      cleaner.process(writer);
      out = writer.getBuffer().toString();
      assertEquals("<html><head><script type=\"text/javascript\" src=\"inject.js\"></script><script type=\"text/javascript\" src=\"user.js\"></script><script type=\"text/javascript\">google.load(\"dojo\", \"1.4.1\");</script></head><body></body></html>", out);
    } catch (IOException e) {
      fail();
    }
View Full Code Here

    String out = "";
    StringWriter writer = new StringWriter();
    try {
      cleaner.setReader(new StringReader(content));
      cleaner.injectStylesheet("test.css");
      cleaner.process(writer);
      out = writer.getBuffer().toString();
      assertEquals("<html><head><link type=\"text/css\" rel=\"stylesheet\" href=\"test.css\" /></head><body></body></html>", out);
    } catch (IOException e) {
      fail();
    }
View Full Code Here

  public void nullReader() throws IOException{
    HtmlCleaner cleaner = new HtmlCleaner();
    StringWriter writer = new StringWriter();
    cleaner.setReader(null);
    cleaner.injectStylesheet("test.css");
    cleaner.process(writer);
    fail();
  }
 
  @Test (expected = IOException.class)
  public void nullReader2() throws IOException{
View Full Code Here

 
  @Test (expected = IOException.class)
  public void nullReader2() throws IOException{
    HtmlCleaner cleaner = new HtmlCleaner();
    StringWriter writer = new StringWriter();
    cleaner.process(writer);
    fail();
  }
 
  @Test (expected = IOException.class)
  public void nullContentInReader() throws IOException{
View Full Code Here

  public void nullContentInReader() throws IOException{
    HtmlCleaner cleaner = new HtmlCleaner();
    StringWriter writer = new StringWriter();
    cleaner.setReader(new FileReader("bogus.html"));
    cleaner.injectStylesheet("test.css");
    cleaner.process(writer);
  }

  @Test  (expected = IOException.class)
  public void nullWriter() throws IOException{
    HtmlCleaner cleaner = new HtmlCleaner();
View Full Code Here

  public void nullWriter() throws IOException{
    HtmlCleaner cleaner = new HtmlCleaner();
    FileWriter writer = null;
    cleaner.setReader(new StringReader("test"));
    cleaner.injectStylesheet("test.css");
    cleaner.process(writer);
  }

  @Test
  public void setharset() throws IOException{
    String in = "";
View Full Code Here

    String in = "";
    StringWriter out = new StringWriter();
    HtmlCleaner cleaner = new HtmlCleaner();
    cleaner.setReader(new StringReader(in));
    cleaner.setTypeAndCharset("text/html", "UTF-8");
    cleaner.process(out);   
    assertEquals("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /></head><body></body></html>", out.toString());   
  }
 
  @Test
  public void overrideCharset() throws IOException{
View Full Code Here

    String in = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=ASCII\" /></head><body></body></html>";
    StringWriter out = new StringWriter();
    HtmlCleaner cleaner = new HtmlCleaner();
    cleaner.setReader(new StringReader(in));
    cleaner.setTypeAndCharset("text/html", "UTF-8");
    cleaner.process(out);   
    assertEquals("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /></head><body></body></html>", out.toString());   
  }


}
View Full Code Here

    //
    // Process Features
    //
    addFlattenedFeatures(startFile.getParentFile(), engine, model);
    FileWriter writer = new FileWriter(startFile);
    engine.process(writer);
  }

  /**
   * Adds features to widget start file by injecting javascript and stylesheets
   * required by each supported feature in the model.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.