Examples of CSSReadFilter


Examples of freenet.client.filter.CSSReadFilter

  }

  private void getCharsetTest(String charset, String family) throws DataFilterException, IOException, URISyntaxException {
    String original = "@charset \""+charset+"\";\nh2 { color: red;}";
    byte[] bytes = original.getBytes(charset);
    CSSReadFilter filter = new CSSReadFilter();
    ArrayBucket inputBucket = new ArrayBucket(bytes);
    ArrayBucket outputBucket = new ArrayBucket();
    InputStream inputStream = inputBucket.getInputStream();
    OutputStream outputStream = outputBucket.getOutputStream();
    // Detect with original charset.
    String detectedCharset = filter.getCharset(bytes, bytes.length, charset);
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" even when parsing with correct charset", charset.equalsIgnoreCase(detectedCharset));
    BOMDetection bom = filter.getCharsetByBOM(bytes, bytes.length);
    String bomCharset = detectedCharset = bom == null ? null : bom.charset;
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" or \""+family+"\" from getCharsetByBOM", detectedCharset == null || charset.equalsIgnoreCase(detectedCharset) || (family != null && family.equalsIgnoreCase(detectedCharset)));
    detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null);
    assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset.equalsIgnoreCase(detectedCharset));
    FilterStatus filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4oobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), null, null, null);
View Full Code Here

Examples of freenet.client.filter.CSSReadFilter

  }

  private void charsetTestUnsupported(String charset) throws DataFilterException, IOException, URISyntaxException {
    String original = "@charset \""+charset+"\";\nh2 { color: red;}";
    byte[] bytes = original.getBytes(charset);
    CSSReadFilter filter = new CSSReadFilter();
    SimpleReadOnlyArrayBucket inputBucket = new SimpleReadOnlyArrayBucket(bytes);
    Bucket outputBucket = new ArrayBucket();
    InputStream inputStream = inputBucket.getInputStream();
    OutputStream outputStream = outputBucket.getOutputStream();
    String detectedCharset;
    BOMDetection bom = filter.getCharsetByBOM(bytes, bytes.length);
    String bomCharset = detectedCharset = bom == null ? null : bom.charset;
    assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from getCharsetByBOM", detectedCharset == null);
    detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null);
    assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset == null || "utf-8".equalsIgnoreCase(detectedCharset));
    try {
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.