// -----------------------------------------------------------------------
  @Test
  public void testFormatDurationWords() {
    String text = null;

    text = DurationFormatUtils.formatDurationWords(50 * 1000, true, false);
    assertEquals("50 seconds", text);
    text = DurationFormatUtils.formatDurationWords(65 * 1000, true, false);
    assertEquals("1 minute 5 seconds", text);
    text = DurationFormatUtils.formatDurationWords(120 * 1000, true, false);
    assertEquals("2 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(121 * 1000, true, false);
    assertEquals("2 minutes 1 second", text);
    text = DurationFormatUtils.formatDurationWords(72 * 60 * 1000, true, false);
    assertEquals("1 hour 12 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(24 * 60 * 60 * 1000, true, false);
    assertEquals("1 day 0 hours 0 minutes 0 seconds", text);

    text = DurationFormatUtils.formatDurationWords(50 * 1000, true, true);
    assertEquals("50 seconds", text);
    text = DurationFormatUtils.formatDurationWords(65 * 1000, true, true);
    assertEquals("1 minute 5 seconds", text);
    text = DurationFormatUtils.formatDurationWords(120 * 1000, true, true);
    assertEquals("2 minutes", text);
    text = DurationFormatUtils.formatDurationWords(121 * 1000, true, true);
    assertEquals("2 minutes 1 second", text);
    text = DurationFormatUtils.formatDurationWords(72 * 60 * 1000, true, true);
    assertEquals("1 hour 12 minutes", text);
    text = DurationFormatUtils.formatDurationWords(24 * 60 * 60 * 1000, true, true);
    assertEquals("1 day", text);

    text = DurationFormatUtils.formatDurationWords(50 * 1000, false, true);
    assertEquals("0 days 0 hours 0 minutes 50 seconds", text);
    text = DurationFormatUtils.formatDurationWords(65 * 1000, false, true);
    assertEquals("0 days 0 hours 1 minute 5 seconds", text);
    text = DurationFormatUtils.formatDurationWords(120 * 1000, false, true);
    assertEquals("0 days 0 hours 2 minutes", text);
    text = DurationFormatUtils.formatDurationWords(121 * 1000, false, true);
    assertEquals("0 days 0 hours 2 minutes 1 second", text);
    text = DurationFormatUtils.formatDurationWords(72 * 60 * 1000, false, true);
    assertEquals("0 days 1 hour 12 minutes", text);
    text = DurationFormatUtils.formatDurationWords(24 * 60 * 60 * 1000, false, true);
    assertEquals("1 day", text);

    text = DurationFormatUtils.formatDurationWords(50 * 1000, false, false);
    assertEquals("0 days 0 hours 0 minutes 50 seconds", text);
    text = DurationFormatUtils.formatDurationWords(65 * 1000, false, false);
    assertEquals("0 days 0 hours 1 minute 5 seconds", text);
    text = DurationFormatUtils.formatDurationWords(120 * 1000, false, false);
    assertEquals("0 days 0 hours 2 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(121 * 1000, false, false);
    assertEquals("0 days 0 hours 2 minutes 1 second", text);
    text = DurationFormatUtils.formatDurationWords(72 * 60 * 1000, false, false);
    assertEquals("0 days 1 hour 12 minutes 0 seconds", text);
    text =
        DurationFormatUtils.formatDurationWords(24 * 60 * 60 * 1000 + 72 * 60 * 1000, false, false);
    assertEquals("1 day 1 hour 12 minutes 0 seconds", text);
    text =
        DurationFormatUtils.formatDurationWords(
            2 * 24 * 60 * 60 * 1000 + 72 * 60 * 1000, false, false);
    assertEquals("2 days 1 hour 12 minutes 0 seconds", text);
    for (int i = 2; i < 31; i++) {
      text = DurationFormatUtils.formatDurationWords(i * 24 * 60 * 60 * 1000L, false, false);
      // assertEquals(i + " days 0 hours 0 minutes 0 seconds", text);
      //
      // junit.framework.ComparisonFailure: expected:<25 days 0 hours 0 minutes 0...> but was:<-24
      // days -17 hours
      // -2 minutes -47...>
      // at junit.framework.Assert.assertEquals(Assert.java:81)
      // at junit.framework.Assert.assertEquals(Assert.java:87)
      // at
      // org.apache.commons.lang.time.DurationFormatUtilsTest.testFormatDurationWords(DurationFormatUtilsTest.java:124)
      // at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      // at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      // at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      // at java.lang.reflect.Method.invoke(Method.java:324)
      // at junit.framework.TestCase.runTest(TestCase.java:154)
      // at junit.framework.TestCase.runBare(TestCase.java:127)
      // at junit.framework.TestResult$1.protect(TestResult.java:106)
      // at junit.framework.TestResult.runProtected(TestResult.java:124)
      // at junit.framework.TestResult.run(TestResult.java:109)
      // at junit.framework.TestCase.run(TestCase.java:118)
      // at junit.framework.TestSuite.runTest(TestSuite.java:208)
      // at junit.framework.TestSuite.run(TestSuite.java:203)
      // at
      // org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      // at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      // at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    }
  }
  /** Tests that "1 <unit>s" gets converted to "1 <unit>" but that "11 <unit>s" is left alone. */
  @Test
  public void testFormatDurationPluralWords() {
    final long oneSecond = 1000;
    final long oneMinute = oneSecond * 60;
    final long oneHour = oneMinute * 60;
    final long oneDay = oneHour * 24;
    String text = null;

    text = DurationFormatUtils.formatDurationWords(oneSecond, false, false);
    assertEquals("0 days 0 hours 0 minutes 1 second", text);
    text = DurationFormatUtils.formatDurationWords(oneSecond * 2, false, false);
    assertEquals("0 days 0 hours 0 minutes 2 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneSecond * 11, false, false);
    assertEquals("0 days 0 hours 0 minutes 11 seconds", text);

    text = DurationFormatUtils.formatDurationWords(oneMinute, false, false);
    assertEquals("0 days 0 hours 1 minute 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneMinute * 2, false, false);
    assertEquals("0 days 0 hours 2 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneMinute * 11, false, false);
    assertEquals("0 days 0 hours 11 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneMinute + oneSecond, false, false);
    assertEquals("0 days 0 hours 1 minute 1 second", text);

    text = DurationFormatUtils.formatDurationWords(oneHour, false, false);
    assertEquals("0 days 1 hour 0 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneHour * 2, false, false);
    assertEquals("0 days 2 hours 0 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneHour * 11, false, false);
    assertEquals("0 days 11 hours 0 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneHour + oneMinute + oneSecond, false, false);
    assertEquals("0 days 1 hour 1 minute 1 second", text);

    text = DurationFormatUtils.formatDurationWords(oneDay, false, false);
    assertEquals("1 day 0 hours 0 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneDay * 2, false, false);
    assertEquals("2 days 0 hours 0 minutes 0 seconds", text);
    text = DurationFormatUtils.formatDurationWords(oneDay * 11, false, false);
    assertEquals("11 days 0 hours 0 minutes 0 seconds", text);
    text =
        DurationFormatUtils.formatDurationWords(
            oneDay + oneHour + oneMinute + oneSecond, false, false);
    assertEquals("1 day 1 hour 1 minute 1 second", text);
  }