
5 changed files with 155 additions and 0 deletions
@ -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 |
@ -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(); |
||||
|
} |
||||
|
} |
@ -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); |
||||
|
} |
||||
|
} |
@ -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("================================"); |
||||
|
} |
||||
|
} |
||||
|
|
Loading…
Reference in new issue