Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2625

ServerDescriptionTest failed due to character used for decimal separator

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 3.6.0
    • Affects Version/s: 3.0.0
    • Component/s: Test Coverage
    • None

      Hello,

      ServerDescriptionTest.testShortDescription() failed due to character used for decimal separator :

      expected = roundTripTime=5000.0 ms
      actual = 5000,0 ms

      In my region, locale decimal separator is ',' and not '.'.

      org.junit.ComparisonFailure: expected:<..., roundTripTime=5000[.]0 ms, state=CONNECTE...> but was:<..., roundTripTime=5000[,]0 ms, state=CONNECTE...>
      	at org.junit.Assert.assertEquals(Assert.java:115)
      	at org.junit.Assert.assertEquals(Assert.java:144)
      	at com.mongodb.connection.ServerDescriptionTest.testShortDescription(ServerDescriptionTest.java:316)
      
      

      More details :
      https://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html
      https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormatSymbols.html

      I have fixed this issue by using a locale decimal separator instead of '.'
      I will do a pull request.

       public void testShortDescription() throws UnknownHostException {
              final char decimalSeparator = new DecimalFormatSymbols().getDecimalSeparator();
              assertEquals("{address=127.0.0.1:27017, type=UNKNOWN, TagSet{[Tag{name='dc', value='ny'}, Tag{name='rack', value='1'}]}, "
                           + "roundTripTime=5000" + decimalSeparator + "0 ms, "
      
      }
      

      Farès

        1. passedTest.png
          passedTest.png
          97 kB
        2. failedTest.png
          failedTest.png
          50 kB

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            fares.hassak@gmail.com Farès Hassak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: