package Ġuk . gov . just ice . digital . h mp ps . send legal mailto pr is ons api . test containers Ċ Ċ import Ġmu . Kotlin Logging Ċ import Ġorg . test containers . containers . local stack . Local Stack Container Ċ import Ġorg . test containers . containers . output . Slf 4 j Log Consumer Ċ import Ġorg . test containers . containers . wait . strategy . Wait Ċ import Ġorg . test containers . utility . Docker Image Name Ċ import Ġjava . io . IOException Ċ import Ġjava . net . Server Socket Ċ Ċ private Ġval Ġlog Ġ= ĠKotlin Logging . logger Ġ{} Ċ Ċ object ĠLocal Stack Container Ġ{ ĊĠ Ġval Ġinstance Ġby Ġlazy Ġ{ Ġstart Local stack IfNot Running () Ġ} ĊĊĠ Ġprivate Ġfun Ġstart Local stack IfNot Running (): ĠLocal Stack Container ? Ġ{ ĊĠĠĠ Ġif Ġ( local stack Is Running ()) Ġreturn Ġnull ĊĠĠĠ Ġval Ġlog Consumer Ġ= ĠS lf 4 j Log Consumer ( log ). with Prefix (" local stack ") ĊĠĠĠ Ġreturn ĠLocal Stack Container ( ĊĠĠĠĠĠ ĠDocker Image Name . parse (" local stack / local stack "). with Tag (" 0 . 1 3 . 1 ") ĊĠĠĠ Ġ). apply Ġ{ ĊĠĠĠĠĠ Ġwith Services ( Local Stack Container . Service . S 3 ) ĊĠĠĠĠĠ Ġwith Env (" HOSTNAME _ EXTERNAL ", Ġ" localhost ") ĊĠĠĠĠĠ Ġwith Env (" DEFAULT _ REGION ", Ġ" eu - west - 2 ") ĊĠĠĠĠĠ Ġwaiting For ( ĊĠĠĠĠĠĠĠ ĠWait . for Log Message (" .* Ready .* ", Ġ 1 ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġstart () ĊĠĠĠĠĠ Ġfollow Output ( log Consumer ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġlocal stack Is Running (): ĠBoolean Ġ= ĊĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠ Ġval Ġserver Socket Ġ= ĠServer Socket ( 4 5 6 6 ) ĊĠĠĠĠĠ Ġserver Socket . local Port Ġ== Ġ 0 ĊĠĠĠ Ġ} Ġcatch Ġ( e : ĠIOException ) Ġ{ ĊĠĠĠĠĠ Ġtrue ĊĠĠĠ Ġ} Ċ } Ċ