Skip to content

Commit e19e65c

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents b236e8d + cb65038 commit e19e65c

5 files changed

Lines changed: 17 additions & 28 deletions

File tree

app/src/androidTest/java/net/sharksystem/asap/android/lora/BasicCommunicationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ public static void setup() throws IOException, InterruptedException {
6161
}
6262

6363
@AfterClass
64-
public static void teardown() throws InterruptedException {
65-
Thread.sleep(10000); //Give the BT Modules some time to stabilize
64+
public static void teardown() throws InterruptedException, IOException {
65+
BasicCommunicationTest.AliceSocket.close();
66+
BasicCommunicationTest.BobSocket.close();
67+
Thread.sleep(2000); //Give the BT Modules some time to stabilize
6668
}
6769
@Test
6870
public void usesAppContext() {

app/src/androidTest/java/net/sharksystem/asap/android/lora/LoRaASAPInputStreamTest.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
package net.sharksystem.asap.android.lora;
22

3-
import android.bluetooth.BluetoothAdapter;
4-
import android.bluetooth.BluetoothDevice;
5-
import android.bluetooth.BluetoothSocket;
3+
64
import android.content.Context;
75

8-
import net.sharksystem.asap.android.lora.exceptions.ASAPLoRaMessageException;
9-
import net.sharksystem.asap.android.lora.messages.ASAPLoRaMessage;
10-
import net.sharksystem.asap.android.lora.messages.AbstractASAPLoRaMessage;
116

12-
import org.junit.AfterClass;
13-
import org.junit.BeforeClass;
147
import org.junit.FixMethodOrder;
158
import org.junit.Test;
169
import org.junit.runner.RunWith;
1710
import org.junit.runners.MethodSorters;
1811

19-
import java.io.BufferedReader;
2012
import java.io.IOException;
21-
import java.io.InputStreamReader;
22-
import java.nio.ByteBuffer;
23-
import java.util.UUID;
2413

2514
import androidx.test.ext.junit.runners.AndroidJUnit4;
2615
import androidx.test.platform.app.InstrumentationRegistry;

app/src/androidTest/java/net/sharksystem/asap/android/lora/LoRaBTInputOutputStreamTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.bluetooth.BluetoothSocket;
66
import android.content.Context;
77

8-
import net.sharksystem.asap.android.lora.exceptions.ASAPLoRaException;
98
import net.sharksystem.asap.android.lora.exceptions.ASAPLoRaMessageException;
109
import net.sharksystem.asap.android.lora.messages.ASAPLoRaMessage;
1110
import net.sharksystem.asap.android.lora.messages.AbstractASAPLoRaMessage;
@@ -62,10 +61,10 @@ public static void setup() throws IOException, InterruptedException {
6261
AliceSocket.connect();
6362
BobSocket.connect();
6463

65-
Thread.sleep(2000); //Give the BT Modules some time to stabilize
6664

6765
Alice = new LoRaBTInputOutputStream(AliceSocket);
6866
Bob = new LoRaBTInputOutputStream(BobSocket);
67+
Thread.sleep(2000); //Give the BT Modules some time to stabilize
6968
}
7069

7170
@AfterClass
@@ -94,19 +93,17 @@ public void testASAPOutputToBTInput() throws IOException, ASAPLoRaMessageExcepti
9493
System.out.print("Test Device Response: ");
9594
System.out.println(deviceResponse);
9695
ASAPLoRaMessage asapMsg = (ASAPLoRaMessage) AbstractASAPLoRaMessage.createASAPLoRaMessage(deviceResponse);
97-
assertEquals(new ASAPLoRaMessage("1000", "Test".getBytes()).toString(), asapMsg.toString());
96+
ASAPLoRaMessage expectedMessage = new ASAPLoRaMessage("1000", "Test".getBytes());
97+
System.out.print("Received Message: ");
98+
System.out.println(asapMsg);
99+
System.out.print("Expected Message: ");
100+
System.out.println(expectedMessage);
101+
assertEquals(expectedMessage.toString(), asapMsg.toString());
98102
break;
99103
}
100104
}
101105
}
102106

103-
/*@Test(timeout = 100000)
104-
public void testMultipleASAPOutputToBTInput() throws IOException, ASAPLoRaMessageException {
105-
for (int i = 0; i < 10; i++) {
106-
this.testASAPOutputToBTInput();
107-
}
108-
}*/
109-
110107
@Test(timeout = 100000)
111108
public void testASAPOutputToBTInputLong() throws IOException, ASAPLoRaMessageException {
112109
Alice.getASAPOutputStream("1001").write(longString.getBytes());

app/src/androidTest/java/net/sharksystem/asap/android/lora/SimultaneousCommunicationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void simultaneousMessageTest() throws IOException {
9393
}
9494
}
9595
}
96-
/*
96+
9797
@Test(timeout = 240000)
9898
public void tenSimultaneousMessageTest() throws IOException {
9999
int rounds = 10;
@@ -130,7 +130,7 @@ public void tenSimultaneousMessageTest() throws IOException {
130130
assertEquals(rounds, AliceCounter);
131131
assertEquals(rounds, BobCounter);
132132
}
133-
*/
133+
134134
@Test(timeout = 240000)
135135
public void tenSimultaneousOrderedMessageTest() throws IOException {
136136
int rounds = 10;

app/src/main/java/net/sharksystem/asap/android/lora/messages/ASAPLoRaMessage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public ASAPLoRaMessage(String address, byte[] message) throws ASAPLoRaMessageExc
3434
throw new ASAPLoRaMessageException("Passed a message that is too long for LoRa Transport");
3535
this.setAddress(address);
3636
this.message = message;
37-
this.base64message = Base64.encodeToString(message, Base64.DEFAULT);
37+
//NO_WRAP to stop the Base64 Util to terminate the string with a newline, as we add our own LF
38+
this.base64message = Base64.encodeToString(message, Base64.NO_WRAP);
3839
}
3940

4041
/**
@@ -46,7 +47,7 @@ public ASAPLoRaMessage(String address, byte[] message) throws ASAPLoRaMessageExc
4647
*/
4748
public ASAPLoRaMessage(String address, String base64message) throws ASAPLoRaMessageException {
4849
this.setAddress(address);
49-
this.base64message = base64message.trim(); //whitespaces are ignored, according to RFC2045
50+
this.base64message = base64message.trim(); //whitespaces can be ignored, according to RFC2045
5051
this.message = Base64.decode(this.base64message, Base64.DEFAULT);
5152
}
5253

0 commit comments

Comments
 (0)