11package net .sharksystem .aasp ;
22
3- import java .io .File ;
43import java .io .IOException ;
5- import java .nio .file .DirectoryStream ;
6- import java .nio .file .Files ;
7- import java .nio .file .Path ;
8- import java .nio .file .Paths ;
4+ import java .util .List ;
95
6+ import net .sharksystem .aasp .util .AASPChunkReceiverTester ;
7+ import net .sharksystem .aasp .util .AASPEngineThread ;
108import net .sharksystem .util .localloop .TCPChannel ;
119import org .junit .Test ;
1210import org .junit .Assert ;
@@ -24,40 +22,10 @@ public class BasicTests {
2422 public static final String ALICE2BOB_MESSAGE = "Hi Bob" ;
2523 public static final String BOB2ALICE_MESSAGE = "Hi Alice" ;
2624
27- private void removeDirectory (String dirname ) {
28- Path dir = Paths .get (dirname );
29-
30- DirectoryStream <Path > entries = null ;
31- try {
32- entries = Files .newDirectoryStream (dir );
33- }
34- catch (IOException ioe ) {
35- // directory does not exist - ok, nothing to drop
36- return ;
37- }
38-
39- for (Path path : entries ) {
40- File file = path .toFile ();
41- if (file .isDirectory ()) {
42- this .removeDirectory (file .getAbsolutePath ());
43- boolean deleted = file .delete ();
44- } else {
45- boolean deleted = file .delete ();
46- }
47- }
48-
49- // finally remove directory itself
50- File dirFile = new File (dirname );
51- if (dirFile .exists ()) {
52- boolean deleted = dirFile .delete ();
53- int i = 42 ;
54- }
55- }
56-
5725 @ Test
5826 public void androidUsage () throws IOException , AASPException , InterruptedException {
59- this . removeDirectory (ALICE_FOLDER ); // clean previous version before
60- this . removeDirectory (BOB_FOLDER ); // clean previous version before
27+ AASPEngineFS . removeFolder (ALICE_FOLDER ); // clean previous version before
28+ AASPEngineFS . removeFolder (BOB_FOLDER ); // clean previous version before
6129
6230 // alice writes a message into chunkStorage
6331 AASPStorage aliceStorage =
@@ -91,7 +59,7 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
9159 bobChannel .waitForConnection ();
9260
9361 // run engine as thread
94- AASPEngineThread aliceEngineThread = new AASPEngineThread (aliceEngine ,
62+ AASPEngineThread aliceEngineThread = new AASPEngineThread (aliceEngine ,
9563 aliceChannel .getInputStream (),
9664 aliceChannel .getOutputStream (),
9765 aliceListener );
@@ -118,7 +86,7 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
11886
11987 // get message alice received
12088 AASPChunkStorage aliceSenderStored =
121- aliceStorage .getReceivedChunkStorage (aliceListener .getSender ());
89+ aliceStorage .getIncomingChunkStorage (aliceListener .getSender ());
12290
12391 AASPChunk aliceReceivedChunk =
12492 aliceSenderStored .getChunk (aliceListener .getUri (),
@@ -131,7 +99,7 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
13199
132100 // get message bob received
133101 AASPChunkStorage bobSenderStored =
134- bobStorage .getReceivedChunkStorage (bobListener .getSender ());
102+ bobStorage .getIncomingChunkStorage (bobListener .getSender ());
135103
136104 AASPChunk bobReceivedChunk =
137105 bobSenderStored .getChunk (bobListener .getUri (),
@@ -141,5 +109,10 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
141109 bobReceivedChunk .getMessages ().next ();
142110
143111 Assert .assertEquals (ALICE2BOB_MESSAGE , bobReceivedMessage );
112+
113+ List <CharSequence > senderList = aliceStorage .getSender ();
114+ // expect bob
115+ Assert .assertEquals (1 , senderList .size ());
116+ Assert .assertTrue (BOB .equalsIgnoreCase (senderList .get (0 ).toString ()));
144117 }
145118}
0 commit comments