[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24690 - in gnunet-java: src/org/gnunet/util test/org/gnune
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24690 - in gnunet-java: src/org/gnunet/util test/org/gnunet/dht |
Date: |
Sun, 4 Nov 2012 18:36:26 +0100 |
Author: dold
Date: 2012-11-04 18:36:26 +0100 (Sun, 04 Nov 2012)
New Revision: 24690
Modified:
gnunet-java/src/org/gnunet/util/Connection.java
gnunet-java/src/org/gnunet/util/Scheduler.java
gnunet-java/test/org/gnunet/dht/DHTTest.java
Log:
added unit test, fix in scheduler
Modified: gnunet-java/src/org/gnunet/util/Connection.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Connection.java 2012-11-04 15:58:55 UTC
(rev 24689)
+++ gnunet-java/src/org/gnunet/util/Connection.java 2012-11-04 17:36:26 UTC
(rev 24690)
@@ -268,6 +268,7 @@
}
if (recvTask != null) {
recvTask.cancel();
+ recvTask = null;
}
}
}
Modified: gnunet-java/src/org/gnunet/util/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Scheduler.java 2012-11-04 15:58:55 UTC
(rev 24689)
+++ gnunet-java/src/org/gnunet/util/Scheduler.java 2012-11-04 17:36:26 UTC
(rev 24690)
@@ -203,6 +203,8 @@
}
public void cancel() {
+ Thread.dumpStack();
+
if (isCanceled) {
throw new AssertionError("task canceled twice");
}
Modified: gnunet-java/test/org/gnunet/dht/DHTTest.java
===================================================================
--- gnunet-java/test/org/gnunet/dht/DHTTest.java 2012-11-04 15:58:55 UTC
(rev 24689)
+++ gnunet-java/test/org/gnunet/dht/DHTTest.java 2012-11-04 17:36:26 UTC
(rev 24690)
@@ -21,6 +21,7 @@
package org.gnunet.dht;
import static org.junit.Assert.*;
+
import org.gnunet.testing.TestingSubsystem;
import org.gnunet.util.*;
import org.junit.Assert;
@@ -61,7 +62,7 @@
TestingSubsystem ts = new TestingSubsystem("dht");
final HashCode hash1 = new HashCode("gnj-test");
- final byte[] data = new byte[]{1,2,3};
+ final byte[] data = new byte[]{1, 2, 3};
final DistributedHashTable dht = new
DistributedHashTable(ts.getConfiguration());
dht.put(hash1, data, 1, EnumSet.noneOf(RouteOption.class),
@@ -85,7 +86,7 @@
@Test(timeout = 500)
- public void test_dht_monitor() {
+ public void test_dht_monitor_put() {
Program.configureLogging();
final Wrapper<Integer> putMonitorCount = new Wrapper<Integer>(0);
@@ -93,9 +94,9 @@
TestingSubsystem ts = new TestingSubsystem("dht");
final HashCode hash = new HashCode("gnj-test");
- final byte[] data1 = new byte[]{1,2,3};
+ final byte[] data1 = new byte[]{1, 2, 3};
- final byte[] data2 = new byte[]{5,4,1,2,6};
+ final byte[] data2 = new byte[]{5, 4, 1, 2, 6};
final DistributedHashTable dht = new
DistributedHashTable(ts.getConfiguration());
@@ -129,5 +130,41 @@
Assert.assertTrue(putMonitorCount.get() == 2);
}
+ @Test(timeout = 500)
+ public void test_dht_monitor_get() {
+ Program.configureLogging("debug");
+
+ final Wrapper<Boolean> ok = new Wrapper<Boolean>(false);
+
+ TestingSubsystem ts = new TestingSubsystem("dht");
+
+ final HashCode hash = new HashCode("gnj-test");
+
+ final DistributedHashTable dht1 = new
DistributedHashTable(ts.getConfiguration());
+ final DistributedHashTable dht2 = new
DistributedHashTable(ts.getConfiguration());
+
+ dht1.startMonitor(BlockType.TEST.val, hash, new MonitorGetHandler() {
+ @Override
+ public void onGet(int options, int type, int hop_count, int
desired_replication_level, PeerIdentity[] getPath, HashCode key) {
+ System.out.println("here!");
+ ok.set(true);
+ dht2.destroy();
+ dht1.destroy();
+ }
+ }, null, null);
+
+ Scheduler.addDelayed(new RelativeTime(50), new Scheduler.Task() {
+ @Override
+ public void run(Scheduler.RunContext ctx) {
+ dht2.startGet(RelativeTime.FOREVER, BlockType.TEST.val, hash,
1, EnumSet.noneOf(RouteOption.class), null, null);
+ }
+ });
+
+
+ Scheduler.run();
+ Assert.assertTrue(ok.get());
+ }
+
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24690 - in gnunet-java: src/org/gnunet/util test/org/gnunet/dht,
gnunet <=