Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/435#discussion_r209442336
  
    --- Diff: 
solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
 ---
    @@ -896,13 +899,125 @@ public void testCascadingParsers() throws Exception {
         assertTrue(mixedDates.isEmpty());
       }
     
    -  private Date parse(DateTimeFormatter dateTimeFormatter, String 
dateString) {
    +  // TestsExtractionDateUtil that mimic TestExtractionDateUtil
    +  public void testISO8601() throws IOException {
    +    // dates with atypical years
    +    // This test tries to mimic TestExtractionDateUtil#testISO8601
    +
    +    String[] dateStrings = {
    +        "0001-01-01T01:01:01Z", "+12021-12-01T03:03:03Z",
    +        "0000-04-04T04:04:04Z", "-0005-05-05T05:05:05Z",
    +        "-2021-12-01T04:04:04Z", "-12021-12-01T02:02:02Z"
    +    };
    +
    +    int id = 1;
    +
    +    // ensure strings are parsed
    +    for(String notInFormatDateString: dateStrings) {
    +      IndexSchema schema = h.getCore().getLatestSchema();
    +      assertNotNull(schema.getFieldOrNull("date_dt")); // should match 
"*_dt" dynamic field
    +      SolrInputDocument d = 
processAdd("parse-date-extraction-util-formats", doc(f("id", id), f("date_dt", 
notInFormatDateString)));
    +      assertNotNull(d);
    +      assertTrue("Date string: " + notInFormatDateString + " was not 
parsed as a date", d.getFieldValue("date_dt") instanceof Date);
    +      assertEquals(notInFormatDateString, ((Date) 
d.getField("date_dt").getFirstValue()).toInstant().toString());
    +      assertU(commit());
    +      assertQ(req("id:" + id), "//date[@name='date_dt'][.='" + 
notInFormatDateString + "']");
    +      ++id;
    +    }
    +
    +    // odd values are date strings, even values are expected strings
    +    String[] lenientDateStrings = {
    +        "10995-12-31T23:59:59.990Z", "+10995-12-31T23:59:59.990Z",
    +        "995-1-2T3:4:5Z", "0995-01-02T03:04:05Z",
    +        "2021-01-01t03:04:05", "2021-01-01T03:04:05Z",
    +        "2021-12-01 04:04:04", "2021-12-01T04:04:04Z"
    +    };
    +
    +    // ensure sure strings that should be parsed using lenient resolver 
are properly parsed
    +    for(int i = 0; i < lenientDateStrings.length; ++i) {
    +      String lenientDateString = lenientDateStrings[i];
    +      String expectedString = lenientDateStrings[++i];
    +      IndexSchema schema = h.getCore().getLatestSchema();
    +      assertNotNull(schema.getFieldOrNull("date_dt")); // should match 
"*_dt" dynamic field
    +      SolrInputDocument d = 
processAdd("parse-date-extraction-util-formats", doc(f("id", id), f("date_dt", 
lenientDateString)));
    +      assertNotNull(d);
    +      assertTrue("Date string: " + lenientDateString + " was not parsed as 
a date",
    +          d.getFieldValue("date_dt") instanceof Date);
    +      assertEquals(expectedString, ((Date) 
d.getField("date_dt").getFirstValue()).toInstant().toString());
    +      ++id;
    +    }
    +  }
    +
    +  // this test has had problems when the JDK timezone is 
Americas/Metlakatla
    +  public void testAKSTZone() throws IOException {
    +    final String inputString = "Thu Nov 13 04:35:51 AKST 2008";
    +
    +    final long expectTs = 1226583351000L;
    +    assertEquals(expectTs,
    +        DateTimeFormatter.ofPattern("EEE MMM d HH:mm:ss z yyyy", 
Locale.ENGLISH)
    +            .withZone(ZoneId.of("UTC")).parse(inputString, 
Instant::from).toEpochMilli());
    +
    +    assertParsedDate(inputString, 
Date.from(Instant.ofEpochMilli(expectTs)), 
"parse-date-extraction-util-formats");
    +  }
    +
    +  public void testNoTime() throws IOException {
    +    Instant instant = instant(2005, 10, 7, 0, 0, 0);
    +    String inputString = "2005-10-07";
    +    assertParsedDate(inputString, Date.from(instant), 
"parse-date-extraction-util-formats");
    +  }
    +
    +  public void testRfc1123() throws IOException {
    +    assertParsedDate("Fri, 07 Oct 2005 13:14:15 GMT", 
Date.from(inst20051007131415()), "parse-date-extraction-util-formats");
    +  }
    +
    +  public void testRfc1036() throws IOException {
    +    assertParsedDate("Friday, 07-Oct-05 13:14:15 GMT", 
Date.from(inst20051007131415()), "parse-date-extraction-util-formats");
    +  }
    +
    +  @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-12593";)
    --- End diff --
    
    This annotation should not be present.  It was not present in 
`SOLR-12561.patch`.  It is present today in TestExtractionDateUtil for the 
string "Thu Nov 13 04:35:51 AKST 2008" and you already have a test for that -- 
testAKSTZone.  Since the URP is not afflicted with the bug causing me to add 
that AwaitsFix, we don't need the annotation here in this test class at all.  
If you want to try to see if the bug is gone, you need to set this system 
property like so: `-Dtests.timezone=America/Metlakatla`.  If you don't, 
Lucene/Solr tests choose a random timezone and it's not particularly likely to 
get this specific one.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to