/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 9 Ġå¤§ åīį èī¯ ä»ĭ Ġ( OH MA E ĠR y os uke ) Ċ Ġ* Ċ Ġ* ĠThis Ġsoftware Ġis Ġreleased Ġunder Ġthe ĠMIT ĠLicense . Ċ Ġ* Ġhttp :// opensource . org / licenses / MIT Ċ Ġ*/ Ċ Ċ package Ġnet . mm 2 d . up np . internal . server Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġio . mock k .* Ċ import Ġnet . mm 2 d . up np . Http Ċ import Ġnet . mm 2 d . up np . S sdp Message Ċ import Ġnet . mm 2 d . up np . internal . message . S sdp Request Ċ import Ġnet . mm 2 d . up np . internal . thread . Task Executors Ċ import Ġnet . mm 2 d . up np . util . Network Utils Ċ import Ġnet . mm 2 d . up np . util . TestUtils Ċ import Ġnet . mm 2 d . up np . util . create Interface Address Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġjava . io . IOException Ċ import Ġjava . net . Inet Address Ċ Ċ @ Suppress (" Test FunctionName ", Ġ" Non Ascii Characters ") Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠS sdp Notify Server Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtask Executors : ĠTask Executors ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġtask Executors Ġ= ĠTask Executors () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtask Executors . terminate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Notify Listener _ åıĹ ä¿¡ ãĥ¡ ãĥĥãĤ»ãĥ¼ãĤ¸ ãģĮ éĢļçŁ¥ ãģķãĤĮãĤĭ ãģĵãģ¨ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelegate Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Server Delegate ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġdelegate . set Receiver ( mock k ( relax ed Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġval Ġinterface Address Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 2 ", Ġ" 2 5 5 . 2 5 5 . 2 5 5 . 0 ", Ġ 1 6 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns Ġinterface Address ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= Ġspy k ( S sdp Notify Server ( delegate )) ĊĊĠĠĠĠĠĠĠ Ġval Ġslot Ġ= Ġslot < S sdp Request >() ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġlistener . invoke ( capture ( slot )) Ġ} Ġanswers Ġ{ Ġnothing Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= ĠInet Address . get ByName (" 1 9 2 . 0 . 2 . 2 ") ĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( address , Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( slot . captured . uuid ). isEqualTo (" uuid : 0 1 2 3 4 5 6 7 - 8 9 ab - c def - 0 1 2 3 - 4 5 6 7 8 9 abcdef ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ åĲĮ ä¸Ģ ãĤ» ãĤ° ãĥ¡ãĥ³ãĥĪ ãģĭãĤī ãģ® ãĥ¡ ãĥĥãĤ»ãĥ¼ãĤ¸ ãģ¯ éĢļçŁ¥ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ filter ãģ§ false ãģ« ãģªãĤĭ ãģ¨ listener ãĤ³ ãĥ¼ãĥ« ãģķãĤĮ ãģªãģĦ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĠĠĠĠĠĠĠ Ġreceiver . set Filter Ġ{ Ġfalse Ġ} ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ Listener ãģĮ null ãģ§ ãĤĤ ãĤ¯ãĥ© ãĥĥ ãĤ·ãĥ¥ ãģĹãģªãģĦ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ çķ ° ãģªãĤĭ ãĤ» ãĤ° ãĥ¡ãĥ³ãĥĪ ãģĭãĤī ãģ® ãĥ¡ ãĥĥãĤ»ãĥ¼ãĤ¸ ãģ¯ çĦ¡ è¦ĸ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġreceiver . set Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 1 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ M _ SEARCH ãĥĳ ãĤ± ãĥĥãĥĪ ãģ¯ çĦ¡ è¦ĸ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠS sdp Request . create () ĊĠĠĠĠĠĠĠ Ġmessage . set Method ( S sdp Message . M _ SEARCH ) ĊĠĠĠĠĠĠĠ Ġmessage . set Uri ("* ") ĊĠĠĠĠĠĠĠ Ġmessage . setHeader ( Http . HOST , ĠAddress . IP _ V 4 . ss dp Address String ) ĊĠĠĠĠĠĠĠ Ġmessage . setHeader ( Http . MAN , ĠS sdp Message . SS DP _ DIS COVER ) ĊĠĠĠĠĠĠĠ Ġmessage . setHeader ( Http . MX , Ġ" 1 ") ĊĠĠĠĠĠĠĠ Ġmessage . setHeader ( Http . ST , ĠS sdp Search Server . ST _ ALL ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġmessage . message . getMessage String (). toByteArray () ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ By e By e ãĥĳ ãĤ± ãĥĥãĥĪ ãģ¯ éĢļçŁ¥ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - by eb ye 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ Location ãģ¨ Source ãģĮ ä¸į ä¸Ģèĩ´ ãģ® ãĥ¡ ãĥĥãĤ»ãĥ¼ãĤ¸ ãģ¯ çĦ¡ è¦ĸ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 3 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ son y _ tele path y _ service ãģ¯ çĦ¡ è¦ĸ ãģĻãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive - tele path y . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Receive _ IOException ãģĮ çĻº çĶŁ ãģĹãģ¦ ãĤĤ ãĤ¯ãĥ© ãĥĥ ãĤ·ãĥ¥ ãģĹãģªãģĦ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspy k ( S sdp Notify Server ( task Executors , ĠAddress . IP _ V 4 , ĠNetwork Utils . get Available Inet 4 Interfaces ()[ 0 ])) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġcreate Interface Address (" 1 9 2 . 0 . 2 . 1 ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . interface Address Ġ} Ġreturns Ġaddress ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġreceiver . create S sdp Request Message ( any (), Ġany ()) Ġ} Ġthrows ĠIOException () ĊĠĠĠĠĠĠĠ Ġval Ġlistener : Ġ( S sdp Message ) Ġ-> ĠUnit Ġ= Ġspy k Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġreceiver . set Notify Listener ( listener ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= ĠTestUtils . getResource As ByteArray (" ss dp - notify - alive 0 . bin ") ĊĊĠĠĠĠĠĠĠ Ġreceiver . on Receive ( Inet Address . get ByName (" 1 9 2 . 0 . 2 . 2 "), Ġdata , Ġdata . size ) ĊĊĠĠĠĠĠĠĠ Ġverify ( inverse Ġ= Ġtrue ) Ġ{ Ġlistener . invoke ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsend _ delegate ãģĮ ãĤ³ ãĥ¼ãĥ« ãģķãĤĮãĤĭ () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelegate : ĠS sdp Server Delegate Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= Ġspy k ( S sdp Notify Server ( delegate )) ĊĠĠĠĠĠĠĠ Ġval Ġmessage : ĠS sdp Message Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġreceiver . send Ġ{ Ġmessage Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġdelegate . send ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinvalid Address _ IPv 4 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelegate : ĠS sdp Server Delegate Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . address Ġ} Ġreturns ĠAddress . IP _ V 4 ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Interface Address (" 1 9 2 . 1 6 8 . 0 . 1 ", Ġ" 2 5 5 . 2 5 5 . 2 5 5 . 0 ", Ġ 2 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= Ġspy k ( S sdp Notify Server ( delegate )) ĊĊĠĠĠĠĠĠĠ Ġwith ( receiver ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isFalse () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isFalse () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Interface Address (" 1 9 2 . 1 6 8 . 0 . 1 ", Ġ" 2 5 5 . 2 5 5 . 2 5 5 . 1 2 8 ", Ġ 2 5 ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isTrue () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isFalse () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Interface Address (" 1 9 2 . 1 6 8 . 0 . 1 ", Ġ" 2 5 5 . 2 5 5 . 2 5 5 . 0 ", Ġ 2 4 ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 1 . 2 5 5 "). is Invalid Address ()). isTrue () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Interface Address (" 1 9 2 . 1 6 8 . 0 . 1 ", Ġ" 2 5 5 . 2 5 5 . 2 5 4 . 0 ", Ġ 2 3 ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 1 . 2 5 5 "). is Invalid Address ()). isFalse () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" fe 8 0 :: a 8 3 1 : 8 0 1 b : 8 dc 6 : 4 2 1 f "). is Invalid Address ()). isTrue () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" fe 8 0 :: a 8 3 1 : 8 0 1 b : 8 dc 6 : 4 2 1 f "). is Invalid Address ()). isTrue () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinvalid Address _ IPv 6 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelegate : ĠS sdp Server Delegate Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . address Ġ} Ġreturns ĠAddress . IP _ V 6 ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdelegate . interface Address Ġ} Ġreturns ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Interface Address (" fe 8 0 :: a 8 3 1 : 8 0 1 b : 8 dc 6 : 4 2 1 f ", Ġ" 2 5 5 . 2 5 5 . 0 . 0 ", Ġ 1 6 ) ĊĠĠĠĠĠĠĠ Ġval Ġreceiver Ġ= Ġspy k ( S sdp Notify Server ( delegate )) ĊĠĠĠĠĠĠĠ Ġwith ( receiver ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 2 0 0 1 : db 8 :: 1 "). is Invalid Address ()). isFalse () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 2 0 0 1 : db 8 :: 1 "). is Invalid Address ()). isFalse () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isTrue () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Segment Check Enabled ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( Inet Address . get ByName (" 1 9 2 . 1 6 8 . 0 . 2 5 5 "). is Invalid Address ()). isTrue () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ