Пример #1
0
  @Issue("JENKINS-26777")
  @SuppressWarnings({"unchecked", "rawtypes"})
  @Test
  public void getDurationString() throws IOException {
    LocaleProvider providerToRestore = LocaleProvider.getProvider();
    try {
      // This test expects English texts.
      LocaleProvider.setProvider(
          new LocaleProvider() {
            @Override
            public Locale get() {
              return Locale.ENGLISH;
            }
          });

      Run r = new Run(new StubJob(), 0) {};
      assertEquals("Not started yet", r.getDurationString());
      r.onStartBuilding();
      String msg;
      msg = r.getDurationString();
      assertTrue(msg, msg.endsWith(" and counting"));
      r.onEndBuilding();
      msg = r.getDurationString();
      assertFalse(msg, msg.endsWith(" and counting"));
    } finally {
      LocaleProvider.setProvider(providerToRestore);
    }
  }