"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/hudson/util/RetrierTest.java" between
jenkins-jenkins-2.302.tar.gz and jenkins-jenkins-2.303.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

RetrierTest.java  (jenkins-jenkins-2.302):RetrierTest.java  (jenkins-jenkins-2.303)
skipping to change at line 13 skipping to change at line 13
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static junit.framework.TestCase.fail; import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class RetrierTest { public class RetrierTest {
private static Logger LOG = Logger.getLogger(RetrierTest.class.getName()); private static final Logger LOG = Logger.getLogger(RetrierTest.class.getName ());
@Test @Test
public void performedAtThirdAttemptTest() throws Exception { public void performedAtThirdAttemptTest() throws Exception {
final int SUCCESSFUL_ATTEMPT = 3; final int SUCCESSFUL_ATTEMPT = 3;
final String ACTION = "print"; final String ACTION = "print";
RingBufferLogHandler handler = new RingBufferLogHandler(20); RingBufferLogHandler handler = new RingBufferLogHandler(20);
Logger.getLogger(Retrier.class.getName()).addHandler(handler); Logger.getLogger(Retrier.class.getName()).addHandler(handler);
Retrier<Boolean> r = new Retrier.Builder<> Retrier<Boolean> r = new Retrier.Builder<>
skipping to change at line 309 skipping to change at line 309
) )
// Set the optional parameters // Set the optional parameters
.withAttempts(ATTEMPTS) .withAttempts(ATTEMPTS)
// Exceptions allowed (not the one raised) // Exceptions allowed (not the one raised)
.withDuringActionExceptions(new Class[]{IndexOutOfBoundsExceptio n.class}) .withDuringActionExceptions(new Class[]{IndexOutOfBoundsExceptio n.class})
// Construct the object // Construct the object
.build(); .build();
// Begin the process that raises an unexpected exception // Begin the process that raises an unexpected exception
try { assertThrows("The process should be exited with an unexpected exception"
r.start(); , IOException.class, r::start);
fail("The process should be exited with an unexpected exception"); String testFailure = Messages.Retrier_ExceptionThrown(ATTEMPTS, ACTION);
} catch (IOException e) { assertTrue(String.format("The log should contain '%s'", testFailure), ha
String testFailure = Messages.Retrier_ExceptionThrown(ATTEMPTS, ACTI ndler.getView().stream().anyMatch(m -> m.getMessage().contains(testFailure)));
ON);
assertTrue(String.format("The log should contain '%s'", testFailure)
, handler.getView().stream().anyMatch(m -> m.getMessage().contains(testFailure))
);
} catch (Exception e) {
fail(String.format("Unexpected exception: %s", e));
}
} }
} }
 End of changes. 3 change blocks. 
14 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)