Skip to content

Commit

Permalink
Increase the socket and connection timeouts for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markozajc committed Apr 14, 2024
1 parent cc57745 commit 45d596a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static synchronized void shutdownInstance() {
* @return the {@link UnirestInstance} you passed, used for chaining
*/
@Nonnull
public static UnirestInstance configureInstance(@Nonnull UnirestInstance unirest) {
public static UnirestInstance configureInstance(UnirestInstance unirest) {
unirest.config()
.addDefaultHeader("User-Agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:86.0) Gecko/20100101 Firefox/86.0")
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/eu/zajc/akiwrapper/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
import org.eu.zajc.akiwrapper.Akiwrapper.*;
import org.eu.zajc.akiwrapper.core.entities.Question;
import org.eu.zajc.akiwrapper.core.exceptions.*;
import org.eu.zajc.akiwrapper.core.utils.UnirestUtils;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;
import org.opentest4j.TestAbortedException;
import org.slf4j.Logger;

import static org.junit.jupiter.api.Assertions.*;

import kong.unirest.*;

class IntegrationTest {

private static final String THEME_MISMATCH = "The requested and actual theme don't match";
Expand All @@ -46,15 +49,21 @@ class IntegrationTest {
private static final String QUESTION_INITIAL_NO_MATCH =
"Initial question text does not match the one after an equal amount of answers and undoes";

private static final UnirestInstance UNIREST = UnirestUtils.configureInstance(Unirest.spawnInstance());
static {
UNIREST.config().connectTimeout(300000).socketTimeout(300000);
}

@ParameterizedTest
@MethodSource("generateTestAkiwrapper")
void testAkiwrapper(@Nonnull Language language, @Nonnull Theme theme) {

Logger log = getLogger(format("%s-%s", language, theme));
try {
log.info("Establishing connection");
Akiwrapper api;
try {
api = new AkiwrapperBuilder().setLanguage(language).setTheme(theme).build();
api = new AkiwrapperBuilder().setUnirestInstance(UNIREST).setLanguage(language).setTheme(theme).build();
} catch (LanguageThemeCombinationException e) {
abort("Language-theme combination not supported.");
return;
Expand Down

0 comments on commit 45d596a

Please sign in to comment.