ソースを参照

Add test with limited filter done without the limit

pull/3/head
コミット
cad625431e
1個のファイルの変更25行の追加2行の削除
  1. +25
    -2
      src/test/java/org/cobbzilla/util/io/regex/RegexFilterReaderTest.java

+ 25
- 2
src/test/java/org/cobbzilla/util/io/regex/RegexFilterReaderTest.java ファイルの表示

@@ -67,7 +67,7 @@ public class RegexFilterReaderTest {
+ "\r\n"
+ "<!DOCTYPE html>\n"
+ "<html><meta charset=\"utf-8\">\n"
+ "set-cookie: a=b; Domain=*.wrong.domain\r\n"
+ "set-cookie: a=b; Domain=*.example.com\r\n"
+ "</html>\n";
public static final String EXPECTED_STRING_INCLUDE_MATCH_LIMITED = "HTTP/2 200 OK\r\n"
+ "server: nginx/1.18.0 (Ubuntu)\r\n"
@@ -80,8 +80,20 @@ public class RegexFilterReaderTest {
+ "\r\n"
+ "<!DOCTYPE html>\n"
+ "<html><meta charset=\"utf-8\">\n"
+ "set-cookie: a=b; Domain=*.wrong.domain\r\n"
+ "set-cookie: a=b; Domain=*.example.com\r\n"
+ "</html>\n";
public static final String EXPECTED_STRING_INCLUDE_MATCH_FULL = "HTTP/2 200 OK\r\n"
+ "server: nginx/1.18.0 (Ubuntu)\r\n"
+ "date: Tue, 15 Sep 2020 11:40:14 GMT\r\n"
+ "content-type: application/json\r\n"
+ "content-encoding: UTF-8\r\n"
+ "set-cookie: c=d; Domain=example.com\r\n"
+ "zz-type: java.util.LinkedHashMap\r\n"
+ "X-Firefox-Spdy: h2\r\n"
+ "\r\n"
+ "<!DOCTYPE html>\n"
+ "<html><meta charset=\"utf-8\">\n"
+ "</html>\n";

@Test public void testRegexReaderIncludeMatchLimited() throws Exception {
final Reader reader = new StringReader(TEST_STRING_INCLUDE_MATCH_LIMITED);
@@ -95,6 +107,17 @@ public class RegexFilterReaderTest {
EXPECTED_STRING_INCLUDE_MATCH_LIMITED, result.toString());
}

@Test public void testRegexReaderIncludeMatchLimitedWithoutLimit() throws Exception {
final Reader reader = new StringReader(TEST_STRING_INCLUDE_MATCH_LIMITED);
final RegexStreamFilter regexStreamFilter =
new RegexLimitedReplacementFilter("Set-Cookie:.*; Domain=\\*.*\r?\n", 0, "", "NotExistingBoundary", 0);
final RegexFilterReader regexFilterReader = new RegexFilterReader(reader, 1024, regexStreamFilter);
final StringWriter result = new StringWriter();
IOUtils.copyLarge(regexFilterReader, result);
assertEquals("multi reader failed to get expected output",
EXPECTED_STRING_INCLUDE_MATCH_FULL, result.toString());
}

public static final String TEST_STRING_INCLUDE_MATCH_MIDDLE = "<!DOCTYPE html>\n<html dir=\"ltr\" lang=\"en\">\n<meta charset=\"utf-8\">something</html>\n";
public static final String EXPECTED_STRING_INCLUDE_MATCH_MIDDLE = "<!DOCTYPE html>\nINSERTED_<html dir=\"ltr\" lang=\"en\">DATA\n<meta charset=\"utf-8\">something</html>\n";



読み込み中…
キャンセル
保存