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

[tor-commits] [metrics-lib/master] Add tests for published lines containing milliseconds.



commit 008781b7e51f619e23e08f27e7f760809cb1e979
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Thu Jul 18 14:21:36 2013 +0200

    Add tests for published lines containing milliseconds.
    
    Milliseconds are simply ignored, because SimpleDateFormat only looks at
    "yyyy-MM-dd HH:mm:ss" and ignores everything after that.
    
    Related to #9286 where we discovered that some relays include milliseconds
    in their descriptors.
---
 .../torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java |    7 +++++++
 .../torproject/descriptor/impl/ServerDescriptorImplTest.java    |    7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index 4aa8a44..cd23ab0 100644
--- a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -804,6 +804,13 @@ public class ExtraInfoDescriptorImplTest {
     assertEquals(1328951316000L, descriptor.getPublishedMillis());
   }
 
+  @Test()
+  public void testPublishedMillis() throws DescriptorParseException {
+    ExtraInfoDescriptor descriptor = DescriptorBuilder.
+        createWithPublishedLine("opt published 2012-02-11 09:08:36.123");
+    assertEquals(1328951316000L, descriptor.getPublishedMillis());
+  }
+
   @Test(expected = DescriptorParseException.class)
   public void testWriteHistoryNegativeBytes()
       throws DescriptorParseException {
diff --git a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 9eb38ae..b2160a5 100644
--- a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -538,6 +538,13 @@ public class ServerDescriptorImplTest {
   }
 
   @Test()
+  public void testPublishedMillis() throws DescriptorParseException {
+    ServerDescriptor descriptor = DescriptorBuilder.
+        createWithPublishedLine("opt published 2012-01-01 04:03:19.123");
+    assertEquals(1325390599000L, descriptor.getPublishedMillis());
+  }
+
+  @Test()
   public void testFingerprintNoOpt() throws DescriptorParseException {
     ServerDescriptor descriptor = DescriptorBuilder.
         createWithFingerprintLine("fingerprint D873 3048 FC8E C910 2466 "

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