diff options
Diffstat (limited to 'test/org/gnunet/dht/DHTTest.java')
-rw-r--r-- | test/org/gnunet/dht/DHTTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/org/gnunet/dht/DHTTest.java b/test/org/gnunet/dht/DHTTest.java new file mode 100644 index 0000000..ec56834 --- /dev/null +++ b/test/org/gnunet/dht/DHTTest.java | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.dht; | ||
22 | |||
23 | import junit.framework.Assert; | ||
24 | import org.gnunet.util.*; | ||
25 | import org.junit.Test; | ||
26 | |||
27 | import java.util.EnumSet; | ||
28 | |||
29 | public class DHTTest { | ||
30 | @Test | ||
31 | public void test_dht_put() { | ||
32 | final Wrapper<Boolean> putFinished = new Wrapper<Boolean>(true); | ||
33 | new Program(new String[0]) { | ||
34 | @Override | ||
35 | public void run() { | ||
36 | final DistributedHashTable dht = new DistributedHashTable(getConfiguration()); | ||
37 | dht.put(new HashCode("gnj-test"), new byte[]{1,2,3}, 1, EnumSet.noneOf(RouteOption.class), | ||
38 | BlockType.TEST.val, RelativeTime.HOUR.toAbsolute(), RelativeTime.FOREVER, new Continuation() { | ||
39 | @Override | ||
40 | public void cont(boolean success) { | ||
41 | putFinished.set(true); | ||
42 | dht.destroy(); | ||
43 | } | ||
44 | }); | ||
45 | } | ||
46 | }.start(); | ||
47 | Assert.assertTrue(putFinished.get()); | ||
48 | } | ||
49 | } | ||