Browse Source

JNI-85 Try to reproduce it - without success

JNI-88
Hussein Kasem 6 years ago
parent
commit
a46cbfafa8
  1. 26
      test/JNI_85/Makefile
  2. 57
      test/JNI_85/Step1.java
  3. 43
      test/JNI_85/Step2.java
  4. 24
      test/JNI_85/SyncCallbacks.java
  5. 5
      test/Makefile

26
test/JNI_85/Makefile

@ -0,0 +1,26 @@
include ../../Makefile.conf
#TODO: Remove when successufuly reproduce the error, and then use it to avoid regression
$(info This is to be run using pEpJNIAdapter 626)
CLASSPATH=.:../../src
VM=java -Xcheck:jni -Djava.library.path=../../src
#VM=lldb java -- -Xcheck:jni -Djava.library.path=../src
.PHONY: test clean
test: SyncCallbacks.class Step1.class Step2.class
-HOME=$(PWD) CLASSPATH=$(CLASSPATH) time $(VM) Step1
HOME=$(PWD) CLASSPATH=$(CLASSPATH) time $(VM) Step2
%.class: %.java
CLASSPATH=$(CLASSPATH) javac $<
clean:
rm -f *.class
rm -f *.log
rm -f .pEp_*
rm -Rf .pEp
rm -Rf .gnupg
rm -Rf .lldb

57
test/JNI_85/Step1.java

@ -0,0 +1,57 @@
import foundation.pEp.jniadapter.*;
import java.util.Vector;
import java.net.URL;
import java.net.URLClassLoader;
import java.lang.Thread;
import java.lang.InterruptedException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
class Step1 {
public static void main(String[] args) {
new Thread(() -> {
Engine e = null;
// load
try {
e = new Engine();
SyncCallbacks callbacks = new SyncCallbacks();
//e.setNotifyHandshakeCallback(callbacks);
e.setMessageToSendCallback(callbacks);
}
catch (pEpException ex) {
System.out.println("Cannot load");
System.exit(-1);
}
System.out.println("Test loaded");
// Keygen
Engine en = new Engine();
System.out.println("Generating keys: ");
Identity user2 = new Identity();
user2.user_id = "pEp_own_userId";
user2.me = true;
user2.username = "Test User 2";
user2.address = "jniTestUser2@peptest.ch";
user2 = en.myself(user2);
System.out.print("Keys generated: ");
System.out.println(user2.fpr);
// it's not necessary - you can just shutdown Sync and that's it
// but for this test give sync a chance to process all messages
try {
Thread.sleep(200);
System.out.println("End wait");
}
catch (InterruptedException ex) { }
}).start();
throw new RuntimeException();
}
}

43
test/JNI_85/Step2.java

@ -0,0 +1,43 @@
import foundation.pEp.jniadapter.*;
import java.util.Vector;
import java.net.URL;
import java.net.URLClassLoader;
import java.lang.Thread;
import java.lang.InterruptedException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
class Step2 {
public static void main(String[] args) {
Engine e = null;
// load
try {
e = new Engine();
SyncCallbacks callbacks = new SyncCallbacks();
//e.setNotifyHandshakeCallback(callbacks);
e.setMessageToSendCallback(callbacks);
}
catch (pEpException ex) {
System.out.println("Cannot load");
System.exit(-1);
}
System.out.println("Test loaded");
e.startSync();
//It should crash here.
try {
Thread.sleep(200);
}
catch (InterruptedException ex) { }
System.exit(0);
}
}

24
test/JNI_85/SyncCallbacks.java

@ -0,0 +1,24 @@
import foundation.pEp.jniadapter.*;
public class SyncCallbacks implements Sync.MessageToSendCallback, Sync.NotifyHandshakeCallback {
public void messageToSend(Message message)
{
System.out.println("================================");
System.out.println("Message to send called");
System.out.println("From: " + message.getFrom());
System.out.println("To: " + message.getTo());
System.out.println("Subject: " + message.getShortmsg());
System.out.println("================================");
}
public void notifyHandshake(Identity myself, Identity partner, SyncHandshakeSignal signal)
{
System.out.println("================================");
System.out.println("Notify handshake called");
System.out.println("Myself: " + myself);
System.out.println("Partner: " + partner);
System.out.println("Signal: " + signal);
System.out.println("================================");
}
}

5
test/Makefile

@ -23,12 +23,17 @@ VM=java -Xcheck:jni -Djava.library.path=../src
test: Testing.class SyncCallbacks.class
HOME=$(PWD) CLASSPATH=$(CLASSPATH) time $(VM) Testing
test-JNI-85:
$(MAKE) -C JNI_85
%.class: %.java
CLASSPATH=$(CLASSPATH) javac $<
clean:
$(MAKE) -C JNI_85 clean
rm -f *.class
rm -f *.log
rm -f .pEp_*
rm -Rf .pEp
rm -Rf .gnupg
rm -Rf .lldb

Loading…
Cancel
Save