[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Part of task-22533: failing test.



commit f18c6ef8b72e52e941a4a37532485ac7b80f5eef
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Wed Jun 7 07:07:49 2017 +0000

    Part of task-22533:  failing test.
---
 .../descriptor/impl/DescriptorImplTest.java        | 10 ------
 .../descriptor/impl/DescriptorParserImplTest.java  | 41 ++++++++++++++++++++++
 .../torproject/descriptor/impl/TestDescriptor.java | 17 +++++++++
 3 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorImplTest.java
index cbe57ff..f1a8935 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorImplTest.java
@@ -132,16 +132,6 @@ public class DescriptorImplTest {
     assertEquals("1bEECw9nT5KRzPG8dAzEFJgSI4OBQfyWn+wjREb8oa8", digest);
   }
 
-  class TestDescriptor extends DescriptorImpl {
-
-    protected TestDescriptor(byte[] rawDescriptorBytes, int[] offsetAndLength,
-        boolean failUnrecognizedDescriptorLines, boolean blankLinesAllowed)
-        throws DescriptorParseException {
-      super(rawDescriptorBytes, offsetAndLength,
-          failUnrecognizedDescriptorLines, blankLinesAllowed);
-    }
-  }
-
 }
 
 
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
new file mode 100644
index 0000000..ef21ce6
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
@@ -0,0 +1,41 @@
+/* Copyright 2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class DescriptorParserImplTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  private TestDescriptor makeTestDesc(byte[] bytes) throws Exception {
+    return new TestDescriptor(bytes, new int[]{0, bytes.length}, false, false);
+  }
+
+  private static final String MICRO =
+      "@type microdescriptor 1.0\n"
+      + "onion-key\n"
+      + "-----BEGIN RSA PUBLIC KEY-----\n"
+      + "MIGJAoGBALzJLYYlkTv6tPet3vusug9judCTrN6MzthV1xVGMSuuWtGHhOJDaIPG\n"
+      + "hKdp99CAIU3sLXYO6zDQRF8PL/Z1GK3c+QHuotzfHotR7fMGtUQWNZRs9glVrVdj\n"
+      + "6KGAHFHo+9qs6NPg7Ux8Minw3wuaHCqoFbQVXo8F+S3wJE6YQ37HAgMBAAE=\n"
+      + "-----END RSA PUBLIC KEY-----\n"
+      + "ntor-onion-key RYjTCjtZRvOyfatfubhOjcEib/yDMsyJcjPT82mf6VA=\n"
+      + "id ed25519 ihsbrlWToq8b01rvfszqqTMUl2ulyPV3TniKuTENCzY\n";
+
+  @Test
+  public void testAnnotation() throws Exception {
+    TestDescriptor des = makeTestDesc(MICRO.getBytes());
+    DescriptorParserImpl dpi = new DescriptorParserImpl();
+    assertEquals(1,
+        dpi.parseDescriptors(des.getRawDescriptorBytes(), "dummy.file").size());
+  }
+
+}
+
diff --git a/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java b/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java
new file mode 100644
index 0000000..84aedee
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/impl/TestDescriptor.java
@@ -0,0 +1,17 @@
+/* Copyright 2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor.impl;
+
+public class TestDescriptor extends DescriptorImpl {
+
+  protected TestDescriptor(byte[] rawDescriptorBytes, int[] offsetAndLength,
+      boolean failUnrecognizedDescriptorLines, boolean blankLinesAllowed)
+      throws DescriptorParseException {
+    super(rawDescriptorBytes, offsetAndLength,
+        failUnrecognizedDescriptorLines, blankLinesAllowed);
+  }
+}
+
+
+



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits