Skip to content

Commit

Permalink
Fix the test when no value is provided for test url
Browse files Browse the repository at this point in the history
  • Loading branch information
dadoonet committed Jul 19, 2021
1 parent fb3e46c commit 0562a61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,33 @@
import fr.pilato.elasticsearch.crawler.fs.client.ESSearchResponse;
import fr.pilato.elasticsearch.crawler.fs.client.ElasticsearchClient;
import fr.pilato.elasticsearch.crawler.fs.client.ElasticsearchClientUtil;
import fr.pilato.elasticsearch.crawler.fs.framework.FsCrawlerIllegalConfigurationException;
import fr.pilato.elasticsearch.crawler.fs.framework.TimeValue;
import fr.pilato.elasticsearch.crawler.fs.framework.Version;
import fr.pilato.elasticsearch.crawler.fs.service.FsCrawlerDocumentService;
import fr.pilato.elasticsearch.crawler.fs.settings.FsSettings;
import fr.pilato.elasticsearch.crawler.fs.test.integration.AbstractFsCrawlerITCase;
import fr.pilato.elasticsearch.crawler.fs.thirdparty.wpsearch.WPSearchClient;
import org.apache.logging.log4j.Level;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static fr.pilato.elasticsearch.crawler.fs.FsCrawlerImpl.LOOP_INFINITE;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assume.assumeNoException;

public abstract class AbstractWorkplaceSearchITCase extends AbstractFsCrawlerITCase {

private final static String DEFAULT_TEST_WPSEARCH_URL = "http://127.0.0.1:3002";
protected static String testWorkplaceUrl = System.getProperty("tests.workplace.url", DEFAULT_TEST_WPSEARCH_URL);
protected final static String testWorkplaceUser = System.getProperty("tests.workplace.user", testClusterUser);
protected final static String testWorkplacePass = System.getProperty("tests.workplace.pass", testClusterPass);
protected final static String testWorkplaceUrl = getSystemProperty("tests.workplace.url", DEFAULT_TEST_WPSEARCH_URL);
protected final static String testWorkplaceUser = getSystemProperty("tests.workplace.user", testClusterUser);
protected final static String testWorkplacePass = getSystemProperty("tests.workplace.pass", testClusterPass);

@BeforeClass
public static void checkWorkplaceSearchCompatible() throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
<integ.elasticsearch.image>docker.elastic.co/elasticsearch/elasticsearch</integ.elasticsearch.image>
<integ.elasticsearch.version>${elasticsearch.version}</integ.elasticsearch.version>
<integ.elasticsearch.port>9200</integ.elasticsearch.port>
<integ.workplace.image>docker.elastic.co/enterprise-search/enterprise-search</integ.workplace.image>
<integ.workplace.port>3002</integ.workplace.port>
<tests.cluster.url></tests.cluster.url>
<tests.cluster.cloud_id></tests.cluster.cloud_id>
<tests.cluster.user>elastic</tests.cluster.user>
<tests.cluster.pass>changeme</tests.cluster.pass>
<integ.workplace.image>docker.elastic.co/enterprise-search/enterprise-search</integ.workplace.image>
<integ.workplace.port>3002</integ.workplace.port>
<tests.workplace.url></tests.workplace.url>
<tests.workplace.user>${tests.cluster.user}</tests.workplace.user>
<tests.workplace.pass>${tests.cluster.pass}</tests.workplace.pass>
Expand Down Expand Up @@ -218,8 +218,8 @@
<tests.cluster.user>${tests.cluster.user}</tests.cluster.user>
<tests.cluster.pass>${tests.cluster.pass}</tests.cluster.pass>
<tests.workplace.url>${tests.workplace.url}</tests.workplace.url>
<tests.workplace.access_token>${tests.workplace.access_token}</tests.workplace.access_token>
<tests.workplace.key>${tests.workplace.key}</tests.workplace.key>
<tests.workplace.user>${tests.workplace.user}</tests.workplace.user>
<tests.workplace.pass>${tests.workplace.pass}</tests.workplace.pass>
<tests.rest.port>${tests.rest.port}</tests.rest.port>
</systemProperties>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,20 @@ public static <T extends Throwable> T expectThrows(Class<T> exceptionClass, Supp
}
return null;
}

/**
* Get a System Property. If it does not exist or if it's empty, the
* fallback value will be returned.
* @param envName The system property name
* @param defaultValue The fallback value
* @return The property value or its default value
*/
protected static String getSystemProperty(String envName, String defaultValue) {
String property = System.getProperty(envName);
if (property == null || property.isBlank()) {
return defaultValue;
} else {
return property;
}
}
}

0 comments on commit 0562a61

Please sign in to comment.