aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/gnunet/core
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-08-27 17:16:18 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-08-27 17:16:18 +0000
commita942ffadee0fe9fd385decdf818ad6baae8c99b3 (patch)
treed500fbdba7379631b0591a19417c7c3f3df29194 /src/test/java/org/gnunet/core
parent6be9a1ed1b7847c795cb700e3e0bd87824fc0573 (diff)
downloadgnunet-java-a942ffadee0fe9fd385decdf818ad6baae8c99b3.tar.gz
gnunet-java-a942ffadee0fe9fd385decdf818ad6baae8c99b3.zip
- adapted source tree structure to gradle/maven conventions
- added gradle wrapper - fixes to adapt to GNUnet changes (new time unit, ...) - helper process in util - started implementing testbed - skeleton for voting tools - use new mq api - implemented some more transport api - mesh
Diffstat (limited to 'src/test/java/org/gnunet/core')
-rw-r--r--src/test/java/org/gnunet/core/CoreTest.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/test/java/org/gnunet/core/CoreTest.java b/src/test/java/org/gnunet/core/CoreTest.java
new file mode 100644
index 0000000..0cb7817
--- /dev/null
+++ b/src/test/java/org/gnunet/core/CoreTest.java
@@ -0,0 +1,111 @@
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
21package org.gnunet.core;
22
23
24import org.gnunet.testing.TestingFixture;
25import org.gnunet.testing.TestingSetup;
26import org.gnunet.testing.TestingSubsystem;
27import org.gnunet.util.*;
28import org.grothoff.Runabout;
29import org.junit.Assert;
30import org.junit.Test;
31
32import static org.junit.Assert.assertTrue;
33
34public class CoreTest extends TestingFixture {
35 @Test(timeout = 10000)
36 public void test_core_init() {
37 Program.configureLogging("DEBUG");
38 TestingSubsystem ts = new TestingSubsystem("core");
39
40 final Wrapper<Boolean> res = new Wrapper<Boolean>(false);
41
42 final Core core = new Core(ts.getConfiguration());
43 core.observeConnect(new ConnectHandler() {
44 @Override
45 public void onConnect(PeerIdentity peerIdentity) {
46 }
47 });
48 core.init(new InitCallback() {
49 @Override
50 public void onInit(PeerIdentity myIdentity) {
51 res.value = true;
52 System.out.println("in core init");
53 assertTrue(myIdentity != null);
54 core.disconnect();
55 }
56 });
57
58 Scheduler.run();
59
60 ts.destroy();
61
62 assertTrue(res.value);
63 }
64
65
66 @Test(timeout = 10000)
67 public void test_core_echo() {
68 Program.configureLogging("DEBUG");
69 new TestingSubsystem("core");
70 new TestingSubsystem("core");
71 new TestingSubsystem("core");
72 new TestingSubsystem("core");
73 TestingSubsystem ts = new TestingSubsystem("core");
74
75 final Wrapper<Boolean> gotResponse = new Wrapper<Boolean>(false);
76
77 final Core core = new Core(ts.getConfiguration());
78 core.setMessageHandler(new Runabout() {
79 public void visit(TestMessage t) {
80 gotResponse.set(true);
81 core.disconnect();
82 }
83 });
84
85 core.init(new InitCallback() {
86 @Override
87 public void onInit(PeerIdentity myIdentity) {
88 System.out.println("in core init");
89 core.notifyTransmitReady(0, RelativeTime.FOREVER, myIdentity, 4, new MessageTransmitter() {
90 @Override
91 public void transmit(Connection.MessageSink sink) {
92 System.out.println("ntr called, calling send");
93 sink.send(new TestMessage());
94 }
95
96 @Override
97 public void handleError() {
98 Assert.fail();
99 }
100 });
101 }
102 });
103
104 Scheduler.run();
105
106 ts.destroy();
107
108 assertTrue(gotResponse.get());
109
110 }
111}