package Ġai . plat on . pulsar . crawl . parse Ċ Ċ import Ġai . plat on . pulsar . common . config . Mutable Config Ċ import Ġai . plat on . pulsar . common . urls . Urls Ċ import Ġai . plat on . pulsar . common . urls . Urls . reverse Url Ċ import Ġai . plat on . pulsar . crawl . filter . C rawl Filters Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġjava . io . IOException Ċ import Ġjava . net . Malformed URLException Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertFalse Ċ import Ġkotlin . test . assertNot Equals Ċ import Ġkotlin . test . assertTrue Ċ Ċ @ Ignore Ċ @ RunWith ( Spring Runner :: class ) Ċ @ Context Configuration ( locations Ġ= Ġ[" classpath :/ test - context / filter - beans . xml "]) Ċ class ĠTest C rawl Filter Ġ{ ĊĠĠĠ Ġprivate Ġval Ġdetail Urls Ġ= ĠarrayOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" http :// mall . j ume i . com / product _ 2 0 0 9 1 8 . html ? from = store _ lan come _ list _ items _ 7 _ 4 " ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġconf : ĠMutable Config ĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġlateinit Ġvar Ġcrawl Filters : ĠC rawl Filters ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġ@ Throws ( IOException :: class ) ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcrawl Filter Rules Ġ= Ġ"{} " ĊĠĠĠĠĠĠĠ Ġconf [ C rawl Filters . CR AW L _ FILTER _ R ULES ] Ġ= Ġcrawl Filter Rules ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Malformed URLException :: class ) ĊĠĠĠ Ġfun Ġtest Key Range () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġkey Range Ġ= Ġcrawl Filters . reversed Key Ranges ĊĠĠĠĠĠĠĠ Ġprintln ( key Range ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" com . j ume i . mall : http /\ u FFFF ", Ġkey Range [" com . j ume i . mall : http "]) ĊĠĠĠĠĠĠĠ ĠassertEquals (" com . j ume i . lan come : http / search . html \ u FFFF ", Ġkey Range [" com . j ume i . lan come : http / search . html "]) ĊĠĠĠĠĠĠĠ Ġassert Not Equals (" com . j ume i . lan come : http / search . html \\ u FFFF ", Ġkey Range [" com . j ume i . lan come : http / search . html "]) ĊĠĠĠĠĠĠĠ Ġfor Ġ( detail Url Ġin Ġdetail Urls ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( crawl Filters . test Key Range Satisf ied ( reverse Url ( detail Url ))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Malformed URLException :: class ) ĊĠĠĠ Ġfun Ġtest Max Key Range () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġkey Range Ġ= ĠarrayOf ("\ u 0 0 0 0 ", Ġ"\ u FFFF ") ĊĠĠĠĠĠĠĠ Ġprintln ( key Range [ 0 ]. toString () Ġ+ Ġ", Ġ" Ġ+ Ġkey Range [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 6 5 4 3 8 , Ġ'\ u FFFF ' Ġ- Ġ' a ') ĊĠĠĠĠĠĠĠ Ġfor Ġ( url Ġin Ġdetail Urls ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreversed Url Ġ= ĠUrl s . reverse Url ( url ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue (" com . j ume i . lan come : http / search . html " Ġ< Ġreversed Url ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue (" com . j ume i . mall : http /\ u FFFF " Ġ> Ġreversed Url ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠNote Ġ: Ġ\ u FFFF , Ġnot Ġ\\ u FFFF ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertFalse (" com . j ume i . mall : http / \\ u FFFF " Ġ> Ġreversed Url ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( url Ġin Ġdetail Urls ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreversed Url Ġ= ĠUrl s . reverse Url ( url ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln ( reversed Url ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( key Range [ 0 ] Ġ< Ġreversed Url ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( key Range [ 1 ] Ġ> Ġreversed Url ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ