use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class UserTaskResourceTest method setupAppWith.
private void setupAppWith(String... userLogins) {
final PropertiesProvider propertiesProvider = new PropertiesProvider();
taskManager = new TaskManagerMemory(propertiesProvider);
configure(new CommonMode(new Properties()) {
@Override
protected void configure() {
bind(PropertiesProvider.class).toInstance(propertiesProvider);
bind(PipelineRegistry.class).toInstance(mock(PipelineRegistry.class));
bind(SessionIdStore.class).toInstance(SessionIdStore.inMemory());
bind(TaskManager.class).toInstance(taskManager);
bind(Filter.class).toInstance(new BasicAuthFilter("/", "ds", DatashareUser.users(userLogins)));
bind(TaskFactory.class).toInstance(mock(TaskFactory.class));
bind(Indexer.class).toInstance(mock(Indexer.class));
}
@Override
protected Routes addModeConfiguration(Routes routes) {
return routes.add(TaskResource.class).filter(Filter.class);
}
}.createWebConfiguration());
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class ElasticsearchConfigurationTest method test_create_client_with_user_pass.
@Test
public void test_create_client_with_user_pass() throws Exception {
RestHighLevelClient esClient = ElasticsearchConfiguration.createESClient(new PropertiesProvider(new HashMap<String, String>() {
{
put("elasticsearchAddress", "http://user:pass@elasticsearch:9200");
}
}));
Response response = esClient.getLowLevelClient().performRequest(new Request("GET", TEST_INDEX));
assertThat(EntityUtils.toString(response.getEntity())).contains("settings");
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class ElasticsearchConfigurationTest method test_create_client_creates_mapping.
@Test
public void test_create_client_creates_mapping() throws Exception {
ElasticsearchConfiguration.createESClient(new PropertiesProvider());
Response response = es.client.getLowLevelClient().performRequest(new Request("GET", TEST_INDEX));
assertThat(EntityUtils.toString(response.getEntity())).contains("mapping");
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class ElasticsearchSpewerTest method test_truncated_content.
@Test
public void test_truncated_content() throws Exception {
ElasticsearchSpewer limitedContentSpewer = new ElasticsearchSpewer(es.client, text -> Language.ENGLISH, new FieldNames(), publisher, new PropertiesProvider(new HashMap<String, String>() {
{
put("maxContentLength", "20");
}
})).withRefresh(IMMEDIATE).withIndex("test-datashare");
final TikaDocument document = new DocumentFactory().withIdentifier(new PathIdentifier()).create(get("fake-file.txt"));
final ParsingReader reader = new ParsingReader(new ByteArrayInputStream("this content should be truncated".getBytes()));
document.setReader(reader);
limitedContentSpewer.write(document);
GetResponse documentFields = es.client.get(new GetRequest(TEST_INDEX, document.getId()), RequestOptions.DEFAULT);
assertThat(documentFields.getSourceAsMap()).includes(entry("content", "this content should"));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class StatusResourceTest method test_get_status_with_open_metrics_format_with_platform_name.
@Test
public void test_get_status_with_open_metrics_format_with_platform_name() {
configure(routes -> routes.add(new StatusResource(new PropertiesProvider(new HashMap<String, String>() {
{
put("platform", "platform");
}
}), repository, indexer, dataBus, documentCollectionFactory)));
when(dataBus.getHealth()).thenReturn(true);
get("/api/status?format=openmetrics").should().respond(200).haveType("text/plain;version=0.0.4").contain("" + "# HELP datashare The datashare resources status\n" + "# TYPE datashare gauge\n" + "datashare{environment=\"platform\",status=\"KO\",resource=\"database\"} 0 1593531060000\n" + "datashare{environment=\"platform\",status=\"KO\",resource=\"index\"} 0 1593531060000\n" + "datashare{environment=\"platform\",status=\"OK\",resource=\"databus\"} 1 1593531060000\n" + "datashare{environment=\"platform\",status=\"OK\",resource=\"document_queue_status\"} 1 1593531060000\n" + "datashare{environment=\"platform\",resource=\"document_queue_size\"} 0 1593531060000");
}
Aggregations