コード例 #1
0
 @Test
 public void testFromXmlDefault() {
   TimestamperConfig config = fromXml(defaultXml());
   TimestamperConfig defaultConfig = new TimestamperConfig();
   assertThat(
       Arrays.asList(config.getSystemTimeFormat(), config.getElapsedTimeFormat()),
       is(
           Arrays.asList(
               defaultConfig.getSystemTimeFormat(), defaultConfig.getElapsedTimeFormat())));
 }
コード例 #2
0
 @Test
 public void testFromXmlEmptyFormat() {
   TimestamperConfig config = fromXml(xml("", ""));
   assertThat(
       Arrays.asList(config.getSystemTimeFormat(), config.getElapsedTimeFormat()),
       is(Arrays.asList("", "")));
 }
コード例 #3
0
 @Override
 public TimestampFormatter get() {
   TimestamperConfig config = GlobalConfiguration.all().get(TimestamperConfig.class);
   // JENKINS-16778: The request can be null when the slave goes off-line.
   Optional<StaplerRequest> request = Optional.fromNullable(Stapler.getCurrentRequest());
   Optional<String> timeZoneId =
       Optional.fromNullable(System.getProperty(TIME_ZONE_PROPERTY));
   return new TimestampFormatter(
       config.getSystemTimeFormat(), config.getElapsedTimeFormat(), request, timeZoneId);
 }
コード例 #4
0
 @Test
 public void testSetSystemTimeFormat() {
   TimestamperConfig config = new TimestamperConfig();
   config.setSystemTimeFormat(customSystemTimeFormat);
   assertThat(config.getSystemTimeFormat(), is(customSystemTimeFormat));
 }
コード例 #5
0
 @Test
 public void testFromXmlCustomSystemTimeFormat() {
   TimestamperConfig config = fromXml(xml(customSystemTimeFormat, null));
   assertThat(config.getSystemTimeFormat(), is(customSystemTimeFormat));
 }
コード例 #6
0
 @Test
 public void testSetSystemTimeFormatEmpty() {
   TimestamperConfig config = new TimestamperConfig();
   config.setSystemTimeFormat("");
   assertThat(config.getSystemTimeFormat(), is(""));
 }
コード例 #7
0
 @Override
 public TimestampFormatter apply(@Nonnull StaplerRequest request) {
   TimestamperConfig config = GlobalConfiguration.all().get(TimestamperConfig.class);
   return new TimestampFormatterImpl(
       config.getSystemTimeFormat(), config.getElapsedTimeFormat(), request);
 }