Skip to content

Commit c99fa6e

Browse files
committed
bug fix- thanks for telling and implementing the bug report.
1 parent c53f928 commit c99fa6e

File tree

8 files changed

+42
-23
lines changed

8 files changed

+42
-23
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
<artifactId>jaxb-impl</artifactId>
4848
<version>3.0.2</version>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.junit.platform</groupId>
52+
<artifactId>junit-platform-suite-api</artifactId>
53+
<version>1.8.1</version>
54+
<scope>test</scope>
55+
</dependency>
5056

5157
</dependencies>
5258

src/main/java/net/sharksystem/asap/engine/ASAPEngine.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ private void sendChunks(CharSequence sender, String encounteredPeer, ASAPChunkSt
754754

755755
boolean lastRound = false; // assume more than one round
756756
do {
757-
boolean goAhead = true; // to avoid deep if-if-if-if structures
758757
lastRound = workingEra == lastEra;
759758

760759
List<ASAPInternalChunk> chunks = chunkStorage.getChunks(workingEra);
@@ -767,16 +766,19 @@ private void sendChunks(CharSequence sender, String encounteredPeer, ASAPChunkSt
767766
//>>>>>>>>>>>>>>>>>>>debug
768767

769768
for(ASAPInternalChunk chunk : chunks) {
769+
boolean goAhead = true; // to avoid deep if-if-if-if structures
770+
770771
//<<<<<<<<<<<<<<<<<<debug
771772
b = new StringBuilder();
772-
b.append(this.getLogStart());
773773
b.append("chunkUrl: ");
774774
b.append(chunk.getUri());
775775
b.append(" | isPublic: ");
776776
b.append(this.isPublic(chunk));
777777
b.append(" | len: ");
778778
b.append(chunk.getLength());
779-
System.out.println(b.toString());
779+
b.append(" | recipients: ");
780+
b.append(chunk.getRecipients());
781+
Log.writeLog(this, this.owner, b.toString());
780782
//>>>>>>>>>>>>>>>>>>>debug
781783

782784
if(chunk.getLength() < 1) {

src/test/java/bugreports/BugReportASAPPeerFS.java renamed to src/test/java/junit5Tests/release_1/MultipleEncounterTests.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package bugreports;
1+
package junit5Tests.release_1;
22

33
import net.sharksystem.TestConstants;
44
import net.sharksystem.TestHelper;
@@ -16,8 +16,8 @@
1616
import java.util.ArrayList;
1717
import java.util.Collection;
1818

19-
public class BugReportASAPPeerFS {
20-
private static final String TEST_FOLDER = "SemanticTests";
19+
public class MultipleEncounterTests {
20+
private static final String TEST_FOLDER = "MultipleEncounterTests";
2121
public static final String ANIMAL = "animal";
2222
public static final String WATER = "water";
2323
public static final String ICE_CREAM = "ice_cream";
@@ -43,7 +43,7 @@ public class BugReportASAPPeerFS {
4343
private static int port = 0;
4444

4545
/* clear folder before launching tests */
46-
public BugReportASAPPeerFS() {
46+
public MultipleEncounterTests() {
4747
ASAPEngineFS.removeFolder(TEST_FOLDER);
4848
}
4949

@@ -155,10 +155,10 @@ public void multiEncounter_sameURIs() throws InterruptedException, IOException,
155155
@Test
156156
public void multiEncounter_partiallyDifferentURIs() throws InterruptedException, IOException, ASAPException {
157157
// sending different uris back and forth now breaks it
158-
simpleEncounterWithMessageExchange(TIGER_URI, ICE_CREAM);
159-
simpleEncounterWithMessageExchange(ICE_CREAM, ELEPHANT_URI);
160-
simpleEncounterWithMessageExchange(HELLO_URI, ICE_CREAM);
161-
simpleEncounterWithMessageExchange(ICE_CREAM, HELLO_URI);
158+
simpleEncounterWithMessageExchange(TIGER_URI, ICE_CREAM, 1);
159+
simpleEncounterWithMessageExchange(ICE_CREAM, ELEPHANT_URI, 2);
160+
simpleEncounterWithMessageExchange(HELLO_URI, ICE_CREAM, 3);
161+
simpleEncounterWithMessageExchange(ICE_CREAM, HELLO_URI, 4);
162162

163163
int era = 0;
164164
// encounter #1: Alice (TIGER_URI) < - > Bob (ICE_CREAM)
@@ -216,7 +216,7 @@ public void multiEncounter_completelyDifferentURIs() throws InterruptedException
216216

217217
// run encounter
218218
for(int i = 0; i < numberEncounter; i++) {
219-
simpleEncounterWithMessageExchange(exchangedUris[i][0], exchangedUris[i][1]);
219+
simpleEncounterWithMessageExchange(exchangedUris[i][0], exchangedUris[i][1], i);
220220
}
221221

222222
// test
@@ -247,13 +247,19 @@ public void multiEncounter_completelyDifferentURIs() throws InterruptedException
247247
*/
248248
}
249249

250+
public void simpleEncounterWithMessageExchange(String uriAlice, String uriBob)
251+
throws IOException, ASAPException, InterruptedException {
252+
this.simpleEncounterWithMessageExchange(uriAlice, uriBob, 0);
253+
}
254+
255+
250256
// sends messages with given uri, starts and then stops the encounter
251257
// message content is irrelevant, we don't test for it
252-
public void simpleEncounterWithMessageExchange(String uriAlice, String uriBob)
258+
public void simpleEncounterWithMessageExchange(String uriAlice, String uriBob, int encounterNumber)
253259
throws IOException, ASAPException, InterruptedException {
254260

255261
// simulate ASAP first encounter with full ASAP protocol stack and engines
256-
System.out.println("+++++++++++++++++++ 1st encounter starts soon ++++++++++++++++++++");
262+
System.out.println("+++++++++++++++++++ encounter #" + encounterNumber + " starts soon ++++++++++++++++++++");
257263
Thread.sleep(50);
258264

259265
// setup message received listener - this should be replaced with your code - you implement a listener.

src/test/java/net/sharksystem/TestConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.sharksystem;
22

33
public interface TestConstants {
4-
String ROOT_DIRECTORY = "playground/";
4+
String ROOT_DIRECTORY = "testResultsRootFolder/";
55
String ALICE_ID = "Alice_42";
66
String ALICE_NAME = "Alice";
77
String BOB_ID = "Bob_43";

src/test/java/net/sharksystem/TestHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ public static int getPortNumber() {
1212

1313
public static String getFullTempFolderName(String fullRootFolderName, boolean increment) {
1414
// String retVal = fullRootFolderName + "_" + testNumber;
15-
String retVal = fullRootFolderName + "/test_" + testNumber;
15+
String retVal = TestConstants.ROOT_DIRECTORY + "/" + fullRootFolderName + "/test_" + testNumber;
1616
if(increment) testNumber++;
1717
return retVal;
1818
}
1919

2020
public static String getFullRootFolderName(String peerID, Class testClass) {
21-
return TestConstants.ROOT_DIRECTORY
22-
+ testClass.getSimpleName()
21+
return testClass.getSimpleName()
2322
+ "/"
2423
+ peerID;
2524
}

src/test/java/net/sharksystem/V1TestSuite.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sharksystem;
22

33
import net.sharksystem.asap.crypto.CryptoUsage;
4+
import junit5Tests.release_1.MultipleEncounterTests;
45
import net.sharksystem.asap.engine.*;
56
import net.sharksystem.asap.helper.HelperTester;
67
import net.sharksystem.asap.protocol.PDUTests;
@@ -22,7 +23,8 @@
2223
CryptoUsage.class,
2324
HelperTester.class,
2425
MultihopTests.class,
25-
CommandlineTests.class
26+
CommandlineTests.class,
27+
MultipleEncounterTests.class
2628
//E2EStreamPairLinkTestVersion2.class TODO
2729
})
2830
public class V1TestSuite {

src/test/java/net/sharksystem/asap/engine/CryptoTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.engine;
22

3+
import net.sharksystem.TestConstants;
34
import net.sharksystem.asap.ASAPException;
45
import net.sharksystem.asap.engine.ASAPEngine;
56
import net.sharksystem.asap.engine.ASAPEngineFS;
@@ -15,7 +16,7 @@
1516
import java.util.List;
1617

1718
public class CryptoTests {
18-
public static final String WORKING_SUB_DIRECTORY = "cryptoTests/";
19+
public static final String WORKING_SUB_DIRECTORY = TestConstants.ROOT_DIRECTORY + "cryptoTests/";
1920
public static final String ALICE_PEER_NAME = "Alice";
2021
public static final String BOB_PEER_NAME = "Bob";
2122
public static final String CLARA_PEER_NAME = "Clara";

src/test/java/net/sharksystem/asap/engine/LongerMessages.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.sharksystem.asap.engine;
22

3+
import net.sharksystem.TestConstants;
34
import net.sharksystem.asap.ASAPException;
45
import net.sharksystem.asap.ASAPChunkStorage;
56
import net.sharksystem.asap.engine.*;
@@ -20,12 +21,14 @@
2021
public class LongerMessages {
2122
public static final String ALICE_BOB_CHAT_URL = "content://aliceAndBob.talk";
2223
public static final String CHAT_FORMAT = "application/x-sn2-makan";
23-
public static final String ALICE_ROOT_FOLDER = "longmessage/Alice";
24-
public static final String ALICE_APP_FOLDER = ALICE_ROOT_FOLDER + "/appFolder";
25-
public static final String BOB_ROOT_FOLDER = "longmessage/Bob";
24+
public static String ALICE_ROOT_FOLDER = TestConstants.ROOT_DIRECTORY + "longmessage/Alice";
25+
public static String ALICE_APP_FOLDER = ALICE_ROOT_FOLDER + "/appFolder";
26+
public static final String BOB_ROOT_FOLDER = TestConstants.ROOT_DIRECTORY + "longmessage/Bob";
2627
public static final String BOB_APP_FOLDER = BOB_ROOT_FOLDER + "/appFolder";
2728
public static final String ALICE = "Alice";
2829
public static final String BOB = "Bob";
30+
31+
2932
// 200
3033
public static final String ALICE2BOB_MESSAGE = "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
3134
//public static final String ALICE2BOB_MESSAGE = "Hi Bob";

0 commit comments

Comments
 (0)