/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 6 . ĠK EST I Ġco , Ġl td Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġdeb op 4 k . core . retry . policy Ċ Ċ import Ġdeb op 4 k . core . NotSupportedException Ċ import Ġdeb op 4 k . core . retry . Retry Policy Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . exception . Runtime IOException Ċ import Ġorg . junit . Test Ċ import Ġjava . io . FileNotFoundException Ċ import Ġjava . io . IOException Ċ import Ġjava . net . Connect Exception Ċ import Ġjava . net . Socket Exception Ċ import Ġjava . util . concurrent .* Ċ Ċ /** Ċ Ġ* ĠRetry Policy Black List Kotlin Test Ċ Ġ* Ġ@ author Ġdeb op Ġsun gh you k . bae @ gmail . com Ċ Ġ*/ Ċ class ĠRetry Policy Black List Kotlin Test Ġ: ĠAbstract Retry Policy Kotlin Test () Ġ{ ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Specified Exception () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( Connect Exception :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠConnect Exception ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Retry If Exception Not Abort ing () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( Connect Exception :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠRuntimeException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠIOException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠSocket Exception ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠClass CastException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠIllegalArgumentException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠIllegalStateException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠTimeout Exception ())). isTrue () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġ@ Throws ( Exception :: class ) ĊĠ Ġfun Ġshould Retry If Error Not Abort ing () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( Connect Exception :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠOut Of Memory Error ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠStack Overflow Error ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNo Class Def Found Error ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠRuntime IOException ( D ON _ T _ PAN IC ))). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠIllegalStateException ())). isTrue () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNot Supported Exception ())). isTrue () ĊĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort If Black List ed Exception () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( NullPointerException :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Sub classes Of Black List ed Exception () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( IOException :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠFileNotFoundException ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠSocket Exception ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠConnect Exception ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Any Black List ed Exceptions () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy () ĊĠĠĠĠĠĠĠ Ġ. abort On ( NullPointerException :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. abort On ( OutOf Memory Error :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. abort On ( Stack Overflow Error :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠOut Of Memory Error ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠStack Overflow Error ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Any Black List ed Exceptions In One List () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( NullPointerException :: class . java , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠOut Of Memory Error :: class . java , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStack Overflow Error :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠOut Of Memory Error ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠStack Overflow Error ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Sub classes Of Any Of Black List ed Exceptions () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy () ĊĠĠĠĠĠĠĠ Ġ. abort On ( IOException :: class . java ) ĊĠĠĠĠĠĠĠ Ġ. abort On ( RuntimeException :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠFileNotFoundException ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠConnect Exception ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Abort On Sub classes Of Any Of Black List ed Exceptions In One List () Ġ{ ĊĠĠĠ Ġval Ġpolicy Ġ= ĠRetry Policy (). abort On ( IOException :: class . java , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRuntimeException :: class . java ) ĊĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠFileNotFoundException ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠConnect Exception ())). isFalse () ĊĠĠĠ ĠassertThat ( should Retry On ( policy , ĠNullPointerException ())). isFalse () ĊĠ Ġ} Ċ }