BUG-4521 Support milliseconds in event-time notification format
[controller.git] / opendaylight / netconf / netconf-notifications-impl / src / test / java / org / opendaylight / controller / netconf / notifications / impl / NetconfNotificationManagerTest.java
index 36d2015ab720595dd3ee6317f6a8f9bcbe4eb1e4..34a9cbfa2bcc3fa42c7d48c03c7c24d4749c7b2e 100644 (file)
@@ -15,6 +15,9 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 
+import com.google.common.collect.Lists;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -40,6 +43,25 @@ public class NetconfNotificationManagerTest {
         MockitoAnnotations.initMocks(this);
     }
 
+    @Test public void testEventTime() throws Exception {
+        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
+            NetconfNotification.RFC3339_DATE_FORMAT_BLUEPRINT);
+        final SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(
+            NetconfNotification.RFC3339_DATE_FORMAT_WITH_MILLIS_BLUEPRINT);
+
+        for (String time : Lists.newArrayList("2001-07-04T12:08:56.235-07:00", "2015-10-23T09:42:27.67175+00:00",
+            "1970-01-01T17:17:22.229568+00:00", "1937-01-01T12:00:27.87+00:20", "1990-12-31T15:59:60-08:00",
+            "1990-12-31T23:59:60Z", "1996-12-19T16:39:57-08:00"
+            //          ,"1985-04-12T23:20:50.52Z"
+        )) {
+            try {
+                simpleDateFormat.parse(time);
+            } catch (ParseException e) {
+                simpleDateFormat2.parse(time);
+            }
+        }
+    }
+
     @Test
     public void testNotificationListeners() throws Exception {
         final NetconfNotificationManager netconfNotificationManager = new NetconfNotificationManager();