@@ -120,6 +120,7 @@ public boolean isOpen() {
120120 public InputStream getInputStream () {
121121 if (alreadyRead )
122122 return null ;
123+
123124 return mockInput ;
124125 }
125126
@@ -221,16 +222,19 @@ public void setUp() throws Exception {
221222 Mockito .doAnswer (new Answer <XBeePacket >() {
222223 @ Override
223224 public XBeePacket answer (InvocationOnMock invocation ) throws Throwable {
224- if (testCI .alreadyRead )
225- return null ;
226-
227- testCI .alreadyRead = true ;
228225 return PACKET_TO_BE_RECEIVED ;
229226 }
230227 }).when (mockParser ).parsePacket (Mockito .eq (mockInput ), Mockito .any (OperatingMode .class ));
231228
232229 mockQueue = Mockito .mock (XBeePacketsQueue .class );
233230 PowerMockito .whenNew (XBeePacketsQueue .class ).withNoArguments ().thenReturn (mockQueue );
231+ Mockito .doAnswer (new Answer <Object >() {
232+ @ Override
233+ public Object answer (InvocationOnMock invocation ) throws Throwable {
234+ testCI .alreadyRead = true ;
235+ return null ;
236+ }
237+ }).when (mockQueue ).addPacket (Mockito .any (XBeePacket .class ));
234238 }
235239
236240 /**
@@ -931,7 +935,7 @@ public Integer answer(InvocationOnMock invocation) throws Throwable {
931935 // Call the method under test.
932936 dataReader .start ();
933937
934- Thread .sleep (200 );
938+ Thread .sleep (150 );
935939 testCI .notifyData ();
936940 while (!testCI .alreadyRead )
937941 Thread .sleep (30 );
@@ -966,7 +970,7 @@ public XBeePacket answer(InvocationOnMock invocation) throws Throwable {
966970 // Call the method under test.
967971 dataReader .start ();
968972
969- Thread .sleep (200 );
973+ Thread .sleep (150 );
970974 testCI .notifyData ();
971975 while (!testCI .alreadyRead )
972976 Thread .sleep (30 );
@@ -1004,7 +1008,7 @@ public final void testDataReaderReceivePacketNotContemplatedPacket() throws Exce
10041008 // Call the method under test.
10051009 dataReader .start ();
10061010
1007- Thread .sleep (200 );
1011+ Thread .sleep (150 );
10081012 testCI .notifyData ();
10091013 while (!testCI .alreadyRead )
10101014 Thread .sleep (30 );
@@ -1046,7 +1050,7 @@ public final void testDataReaderReceivePacketListentoFrameIDNotReceived() throws
10461050 // Call the method under test.
10471051 dataReader .start ();
10481052
1049- Thread .sleep (200 );
1053+ Thread .sleep (150 );
10501054 testCI .notifyData ();
10511055 while (!testCI .alreadyRead )
10521056 Thread .sleep (30 );
@@ -1088,7 +1092,7 @@ public final void testDataReaderReceivePacketListentoFrameIDReceived() throws Ex
10881092 // Call the method under test.
10891093 dataReader .start ();
10901094
1091- Thread .sleep (200 );
1095+ Thread .sleep (150 );
10921096 testCI .notifyData ();
10931097 while (!testCI .alreadyRead )
10941098 Thread .sleep (30 );
@@ -1130,7 +1134,7 @@ public final void testDataReaderReceivePacketATResponse() throws Exception {
11301134 // Call the method under test.
11311135 dataReader .start ();
11321136
1133- Thread .sleep (200 );
1137+ Thread .sleep (150 );
11341138 testCI .notifyData ();
11351139 while (!testCI .alreadyRead )
11361140 Thread .sleep (30 );
@@ -1172,7 +1176,7 @@ public final void testDataReaderReceivePacketRemoteATResponse() throws Exception
11721176 // Call the method under test.
11731177 dataReader .start ();
11741178
1175- Thread .sleep (200 );
1179+ Thread .sleep (150 );
11761180 testCI .notifyData ();
11771181 while (!testCI .alreadyRead )
11781182 Thread .sleep (30 );
@@ -1214,7 +1218,7 @@ public final void testDataReaderReceivePacketRX64DataPacket() throws Exception {
12141218 // Call the method under test.
12151219 dataReader .start ();
12161220
1217- Thread .sleep (200 );
1221+ Thread .sleep (150 );
12181222 testCI .notifyData ();
12191223 while (!testCI .alreadyRead )
12201224 Thread .sleep (30 );
@@ -1256,7 +1260,7 @@ public final void testDataReaderReceivePacketRX16DataPacket() throws Exception {
12561260 // Call the method under test.
12571261 dataReader .start ();
12581262
1259- Thread .sleep (200 );
1263+ Thread .sleep (150 );
12601264 testCI .notifyData ();
12611265 while (!testCI .alreadyRead )
12621266 Thread .sleep (30 );
@@ -1298,7 +1302,7 @@ public final void testDataReaderReceivePacketRXDataPacket() throws Exception {
12981302 // Call the method under test.
12991303 dataReader .start ();
13001304
1301- Thread .sleep (200 );
1305+ Thread .sleep (150 );
13021306 testCI .notifyData ();
13031307 while (!testCI .alreadyRead )
13041308 Thread .sleep (30 );
@@ -1340,7 +1344,7 @@ public final void testDataReaderReceivePacketRXIO64DataPacket() throws Exception
13401344 // Call the method under test.
13411345 dataReader .start ();
13421346
1343- Thread .sleep (200 );
1347+ Thread .sleep (150 );
13441348 testCI .notifyData ();
13451349 while (!testCI .alreadyRead )
13461350 Thread .sleep (30 );
@@ -1382,7 +1386,7 @@ public final void testDataReaderReceivePacketRXIO16DataPacket() throws Exception
13821386 // Call the method under test.
13831387 dataReader .start ();
13841388
1385- Thread .sleep (200 );
1389+ Thread .sleep (150 );
13861390 testCI .notifyData ();
13871391 while (!testCI .alreadyRead )
13881392 Thread .sleep (30 );
@@ -1424,7 +1428,7 @@ public final void testDataReaderReceivePacketRXIOPacket() throws Exception {
14241428 // Call the method under test.
14251429 dataReader .start ();
14261430
1427- Thread .sleep (200 );
1431+ Thread .sleep (150 );
14281432 testCI .notifyData ();
14291433 while (!testCI .alreadyRead )
14301434 Thread .sleep (30 );
@@ -1466,7 +1470,7 @@ public final void testDataReaderReceivePacketModemStatusPacket() throws Exceptio
14661470 // Call the method under test.
14671471 dataReader .start ();
14681472
1469- Thread .sleep (200 );
1473+ Thread .sleep (150 );
14701474 testCI .notifyData ();
14711475 while (!testCI .alreadyRead )
14721476 Thread .sleep (30 );
@@ -1508,7 +1512,7 @@ public final void testDataReaderReceivePacketExplicitIndicatorDigiPacket() throw
15081512 // Call the method under test.
15091513 dataReader .start ();
15101514
1511- Thread .sleep (200 );
1515+ Thread .sleep (150 );
15121516 testCI .notifyData ();
15131517 while (!testCI .alreadyRead )
15141518 Thread .sleep (30 );
@@ -1550,7 +1554,7 @@ public final void testDataReaderReceivePacketExplicitIndicatorPacket() throws Ex
15501554 // Call the method under test.
15511555 dataReader .start ();
15521556
1553- Thread .sleep (200 );
1557+ Thread .sleep (150 );
15541558 testCI .notifyData ();
15551559 while (!testCI .alreadyRead )
15561560 Thread .sleep (30 );
@@ -1589,7 +1593,7 @@ public XBeePacket answer(InvocationOnMock invocation) throws Throwable {
15891593 // Call the method under test.
15901594 dataReader .start ();
15911595
1592- Thread .sleep (200 );
1596+ Thread .sleep (150 );
15931597 testCI .notifyData ();
15941598 while (!testCI .alreadyRead )
15951599 Thread .sleep (30 );
@@ -1622,7 +1626,7 @@ public InputStream getInputStream() {
16221626 // Call the method under test.
16231627 dataReader .start ();
16241628
1625- Thread .sleep (200 );
1629+ Thread .sleep (150 );
16261630 testCI .notifyData ();
16271631 while (!testCI .alreadyRead )
16281632 Thread .sleep (30 );
@@ -1653,7 +1657,7 @@ public InputStream getInputStream() {
16531657 // Call the method under test.
16541658 dataReader .start ();
16551659
1656- Thread .sleep (200 );
1660+ Thread .sleep (150 );
16571661 testCI .notifyData ();
16581662 while (!testCI .alreadyRead )
16591663 Thread .sleep (30 );
0 commit comments