Skip to content

Commit cd3a6a5

Browse files
committed
Trying to adapt test to new UdpNetCat implementation but failed.
It seems like Robolectric problem - ShadowAsyncTask move into undefined state after cancellation (neither onPostExecute() nor onCancelled() aren't called).
1 parent cd93a7b commit cd3a6a5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

netcat/src/test/java/com/github/dddpaul/netcat/UdpNetCatTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ public void run()
7777
// Start NetCat listener
7878
listen( port );
7979

80+
// Stop receiving after some delay required for NetCat to receive test data
81+
new Thread( new Runnable()
82+
{
83+
@Override
84+
public void run()
85+
{
86+
try {
87+
Thread.sleep( 1000 );
88+
netCat.cancel();
89+
} catch( Exception e ) {
90+
e.printStackTrace();
91+
}
92+
}
93+
} ).start();
94+
8095
receive();
8196
send();
8297
}

0 commit comments

Comments
 (0)