66import java .nio .file .Files ;
77import java .nio .file .Path ;
88import java .nio .file .Paths ;
9+ import java .util .List ;
910
1011import net .sharksystem .util .localloop .TCPChannel ;
1112import org .junit .Test ;
@@ -24,40 +25,10 @@ public class BasicTests {
2425 public static final String ALICE2BOB_MESSAGE = "Hi Bob" ;
2526 public static final String BOB2ALICE_MESSAGE = "Hi Alice" ;
2627
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-
5728 @ Test
5829 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
30+ AASPEngineFS . removeFolder (ALICE_FOLDER ); // clean previous version before
31+ AASPEngineFS . removeFolder (BOB_FOLDER ); // clean previous version before
6132
6233 // alice writes a message into chunkStorage
6334 AASPStorage aliceStorage =
@@ -118,7 +89,7 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
11889
11990 // get message alice received
12091 AASPChunkStorage aliceSenderStored =
121- aliceStorage .getReceivedChunkStorage (aliceListener .getSender ());
92+ aliceStorage .getIncomingChunkStorage (aliceListener .getSender ());
12293
12394 AASPChunk aliceReceivedChunk =
12495 aliceSenderStored .getChunk (aliceListener .getUri (),
@@ -131,7 +102,7 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
131102
132103 // get message bob received
133104 AASPChunkStorage bobSenderStored =
134- bobStorage .getReceivedChunkStorage (bobListener .getSender ());
105+ bobStorage .getIncomingChunkStorage (bobListener .getSender ());
135106
136107 AASPChunk bobReceivedChunk =
137108 bobSenderStored .getChunk (bobListener .getUri (),
@@ -141,5 +112,10 @@ public void androidUsage() throws IOException, AASPException, InterruptedExcepti
141112 bobReceivedChunk .getMessages ().next ();
142113
143114 Assert .assertEquals (ALICE2BOB_MESSAGE , bobReceivedMessage );
115+
116+ List <CharSequence > senderList = aliceStorage .getSender ();
117+ // expect bob
118+ Assert .assertEquals (1 , senderList .size ());
119+ Assert .assertTrue (BOB .equalsIgnoreCase (senderList .get (0 ).toString ()));
144120 }
145121}
0 commit comments