}
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);