Skip to content

Commit

Permalink
sync with ASAPJava project - two new bugs are to be handled - see tes…
Browse files Browse the repository at this point in the history
…t suite 1
  • Loading branch information
thsc42 committed May 30, 2024
1 parent ba9602b commit d850f79
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 54 deletions.
Binary file modified libs/ASAPJava.jar
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

9 changes: 0 additions & 9 deletions local_mvn_repo/net/sharksystem/asapjava/0.8/asapjava-0.8.pom

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions local_mvn_repo/net/sharksystem/asapjava/maven-metadata-local.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package net.sharksystem.hub.peerside;

import net.sharksystem.asap.ASAPEncounterManager;
import net.sharksystem.asap.ASAPException;
import net.sharksystem.asap.ASAPPeer;
import net.sharksystem.asap.EncounterConnectionType;
import net.sharksystem.asap.*;
import net.sharksystem.hub.Connector;
import net.sharksystem.utils.AlarmClock;
import net.sharksystem.utils.AlarmClockListener;
Expand Down Expand Up @@ -275,7 +272,7 @@ public void notifySynced(Connector connector, boolean changed) {
Log.writeLog(this, this.toString(), "got peerIDs: " + peerIDs);
if (peerIDs != null && !peerIDs.isEmpty()) for (CharSequence peerID : peerIDs) {
if (this.asapEncounterManager.shouldCreateConnectionToPeer(
peerID, EncounterConnectionType.ASAP_HUB)) {
peerID, ASAPEncounterConnectionType.ASAP_HUB)) {
hubConnector.connectPeer(peerID);
}
}
Expand All @@ -291,7 +288,7 @@ public void notifySynced(Connector connector, boolean changed) {
@Override
public void notifyPeerConnected(CharSequence targetPeerID, StreamPair streamPair) {
try {
this.asapEncounterManager.handleEncounter(streamPair, EncounterConnectionType.ASAP_HUB);
this.asapEncounterManager.handleEncounter(streamPair, ASAPEncounterConnectionType.ASAP_HUB);
} catch (IOException e) {
Log.writeLogErr(this, this.toString(), "cannot handle peer encounter: "
+ e.getLocalizedMessage());
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/sharksystem/hub/peerside/HubTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ public class HubTester {
private final CharSequence format;
private PrintStream printStream;

public HubTester(String peerId, CharSequence format) throws IOException, ASAPException {
public HubTester(String peerId, CharSequence format) throws IOException, SharkException {
String ROOT_FOLDER = "./testPeerFS" + "/" + peerId;
FSUtils.removeFolder(ROOT_FOLDER);
this.asapPeer = new ASAPTestPeerFS(peerId, new ArrayList<>(Collections.singletonList(format)));
this.format = format;
this.hubConnectionManager = new HubConnectionManagerImpl(new ASAPEncounterManagerImpl(asapPeer), asapPeer);
this.hubConnectionManager = new HubConnectionManagerImpl(
new ASAPEncounterManagerImpl(asapPeer, asapPeer.getPeerID()), asapPeer);
printStream = System.out;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public void setUp() throws Exception {
hubPort = TestHelper.getPortNumber();
localHostHubDescription = new TCPHubConnectorDescriptionImpl("localhost", hubPort, multiChannel);
ASAPPeerFS asapPeer = new ASAPTestPeerFS(ALICE_ID, Collections.singletonList(FORMAT));
hubConnectionManager = new HubConnectionManagerImpl(new ASAPEncounterManagerImpl(asapPeer), asapPeer);
hubConnectionManager = new HubConnectionManagerImpl(
new ASAPEncounterManagerImpl(asapPeer, asapPeer.getPeerID()), asapPeer);
asapHub = ASAPTCPHub.startTCPHubThread(hubPort, multiChannel, MAX_IDLE_IN_SECONDS);
}

Expand Down
5 changes: 3 additions & 2 deletions src/test/java/net/sharksystem/hub/HubManagerTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sharksystem.hub;

import net.sharksystem.SharkException;
import net.sharksystem.asap.ASAPEncounterManagerImpl;
import net.sharksystem.asap.ASAPException;
import net.sharksystem.asap.apps.testsupport.ASAPTestPeerFS;
Expand All @@ -22,7 +23,7 @@ public class HubManagerTests {


@Test
public void test1() throws IOException, ASAPException, InterruptedException {
public void test1() throws IOException, SharkException, InterruptedException {
// launch hub
int specificPort = TestHelper.getPortNumber();
CharSequence host = "localhost";
Expand Down Expand Up @@ -60,7 +61,7 @@ public void test1() throws IOException, ASAPException, InterruptedException {
Thread.sleep(maxTimeOutMillis*2);

// add to hub manager
ASAPEncounterManagerImpl asapEncounterManager = new ASAPEncounterManagerImpl(alicePeer);
ASAPEncounterManagerImpl asapEncounterManager = new ASAPEncounterManagerImpl(alicePeer, alicePeer.getPeerID());
ASAPHubManagerImpl asapASAPHubManager = new ASAPHubManagerImpl(asapEncounterManager);
asapASAPHubManager.setTimeOutInMillis(maxTimeOutMillis);
asapASAPHubManager.addHub(aliceHubConnector);
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/net/sharksystem/hub/HubUsageTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sharksystem.hub;

import net.sharksystem.SharkException;
import net.sharksystem.asap.ASAPEncounterManagerImpl;
import net.sharksystem.asap.ASAPException;
import net.sharksystem.asap.apps.testsupport.ASAPTestPeerFS;
Expand Down Expand Up @@ -169,16 +170,16 @@ public void runUsageTest(
}

@Test
public void usageHubManagerAndTwoPeers_MultiChannel_True() throws IOException, InterruptedException, ASAPException {
public void usageHubManagerAndTwoPeers_MultiChannel_True() throws IOException, InterruptedException, SharkException {
this.usageHubManagerAndTwoPeers(true);
}

@Test
public void usageHubManagerAndTwoPeers_MultiChannel_False() throws IOException, InterruptedException, ASAPException {
public void usageHubManagerAndTwoPeers_MultiChannel_False() throws IOException, InterruptedException, SharkException {
this.usageHubManagerAndTwoPeers(false);
}

public void usageHubManagerAndTwoPeers(boolean multichannel) throws IOException, InterruptedException, ASAPException {
public void usageHubManagerAndTwoPeers(boolean multichannel) throws IOException, InterruptedException, SharkException {
int hubPort = TestHelper.getPortNumber();
HubConnectorDescription localHostHubDescription =
new TCPHubConnectorDescriptionImpl("localhost", hubPort, multichannel);
Expand Down Expand Up @@ -210,7 +211,7 @@ public void usageHubManagerAndTwoPeers(boolean multichannel) throws IOException,
///////////////////// connect to hub - Alice
// setup encounter manager with a connection handler
ASAPEncounterManagerImpl aliceEncounterManager =
new ASAPEncounterManagerImpl(aliceASAPPeer);
new ASAPEncounterManagerImpl(aliceASAPPeer, aliceASAPPeer.getPeerID());

// setup hub manager
// ASAPHubManager aliceHubManager = ASAPHubManagerImpl.startASAPHubManager(aliceEncounterManager);
Expand All @@ -223,7 +224,7 @@ public void usageHubManagerAndTwoPeers(boolean multichannel) throws IOException,
///////////////////// connect to hub - Bob
// setup encounter manager with a connection handler
ASAPEncounterManagerImpl bobEncounterManager =
new ASAPEncounterManagerImpl(bobASAPPeer);
new ASAPEncounterManagerImpl(bobASAPPeer, bobASAPPeer.getPeerID());

// setup hub manager
// ASAPHubManager bobHubManager = ASAPHubManagerImpl.startASAPHubManager(bobEncounterManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class KnownBugsHubConnectionManagerTest {
public void setUp() throws Exception {
hubPort = TestHelper.getPortNumber();
ASAPPeerFS asapPeer = new ASAPTestPeerFS(ALICE_ID, Collections.singletonList(FORMAT));
hubConnectionManager = new HubConnectionManagerImpl(new ASAPEncounterManagerImpl(asapPeer), asapPeer);
hubConnectionManager = new HubConnectionManagerImpl(
new ASAPEncounterManagerImpl(asapPeer, asapPeer.getPeerID()), asapPeer);
asapHub = ASAPTCPHub.startTCPHubThread(hubPort, multiChannel, MAX_IDLE_IN_SECONDS);
}

Expand Down

0 comments on commit d850f79

Please sign in to comment.