aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2012-01-26 07:36:44 +0000
committerFlorian Dold <florian.dold@gmail.com>2012-01-26 07:36:44 +0000
commit74a9f1f2a09bf52207ad5e4ff8458c64586f85d1 (patch)
tree3785cede18ae13252fbbcfc531fbe28d5b611139 /test
parent88d4dca74c31a3599c9e993defa6f03fe8fe9983 (diff)
downloadgnunet-java-74a9f1f2a09bf52207ad5e4ff8458c64586f85d1.tar.gz
gnunet-java-74a9f1f2a09bf52207ad5e4ff8458c64586f85d1.zip
implemented message unions, parameter parsing
Diffstat (limited to 'test')
-rw-r--r--test/org/gnunet/construct/ByteFillMessage.java8
-rw-r--r--test/org/gnunet/construct/UnionTest.java44
-rw-r--r--test/org/gnunet/services/NetworkSizeEstimationServiceTest.java2
3 files changed, 46 insertions, 8 deletions
diff --git a/test/org/gnunet/construct/ByteFillMessage.java b/test/org/gnunet/construct/ByteFillMessage.java
index 3eb6d73..55b0e89 100644
--- a/test/org/gnunet/construct/ByteFillMessage.java
+++ b/test/org/gnunet/construct/ByteFillMessage.java
@@ -1,12 +1,6 @@
1package org.gnunet.construct; 1package org.gnunet.construct;
2 2
3/** 3
4 * Created by IntelliJ IDEA.
5 * User: dold
6 * Date: 1/17/12
7 * Time: 10:20 PM
8 * To change this template use File | Settings | File Templates.
9 */
10public class ByteFillMessage implements Message { 4public class ByteFillMessage implements Message {
11 @Nested 5 @Nested
12 public MessageHeader header; 6 public MessageHeader header;
diff --git a/test/org/gnunet/construct/UnionTest.java b/test/org/gnunet/construct/UnionTest.java
new file mode 100644
index 0000000..ba74a8b
--- /dev/null
+++ b/test/org/gnunet/construct/UnionTest.java
@@ -0,0 +1,44 @@
1package org.gnunet.construct;
2
3
4import org.junit.Test;
5
6public class UnionTest {
7 public static interface TestUnion extends MessageUnion {}
8
9 @UnionCase(0)
10 public static class TestUnionCase0 implements TestUnion {
11 @Int8
12 public int val;
13 }
14
15 @UnionCase(1)
16 public static class TestUnionCase1 implements TestUnion{
17 @ZeroTerminatedString
18 public String str;
19 }
20
21 public static class UnionTestMessage implements Message {
22 @Int16
23 public int tag;
24 @Union(tag = "tag")
25 public TestUnion instance;
26 }
27
28
29
30 @Test
31 public void test_Union() {
32 UnionTestMessage utm = new UnionTestMessage();
33 utm.tag = 0;
34 utm.instance = new TestUnionCase0();
35 ((TestUnionCase0)utm.instance).val = 20;
36
37 byte[] a = Construct.toBinary(utm);
38
39 System.out.println(a.length);
40
41 UnionTestMessage utm2 = Construct.parseAs(a, 0, UnionTestMessage.class);
42
43 }
44}
diff --git a/test/org/gnunet/services/NetworkSizeEstimationServiceTest.java b/test/org/gnunet/services/NetworkSizeEstimationServiceTest.java
index eb8e01e..e98db4e 100644
--- a/test/org/gnunet/services/NetworkSizeEstimationServiceTest.java
+++ b/test/org/gnunet/services/NetworkSizeEstimationServiceTest.java
@@ -11,7 +11,7 @@ import java.io.File;
11import java.io.IOError; 11import java.io.IOError;
12import java.io.IOException; 12import java.io.IOException;
13 13
14public class NetworkSizeEstimationServiceTest{ 14public class NetworkSizeEstimationServiceTest {
15 class TestSubscriber implements NetworkSizeEstimation.NSE_Subscriber { 15 class TestSubscriber implements NetworkSizeEstimation.NSE_Subscriber {
16 public boolean success = false; 16 public boolean success = false;
17 NetworkSizeEstimation svc; 17 NetworkSizeEstimation svc;