Skip to content

Commit

Permalink
Add tests for AliasConfigSource. IQSS#7457
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Dec 7, 2020
1 parent ebf83e2 commit e1cb339
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package edu.harvard.iq.dataverse.settings.source;

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Properties;

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

class AliasConfigSourceTest {

AliasConfigSource source = new AliasConfigSource();

@Test
void getValue() {
// given
System.setProperty("dataverse.hello.foobar", "test");
Properties aliases = new Properties();
aliases.setProperty("dataverse.goodbye.foobar", "dataverse.hello.foobar");

// when
source.importAliases(aliases);

// then
assertEquals("test", source.getValue("dataverse.goodbye.foobar"));
}

@Test
void readImportTestAliasesFromFile() throws IOException {
// given
System.setProperty("dataverse.old.example", "test");
String filePath = "test-microprofile-aliases.properties";

// when
Properties aliases = source.readAliases(filePath);
source.importAliases(aliases);

// then
assertEquals("test", source.getValue("dataverse.new.example"));
}
}
1 change: 1 addition & 0 deletions src/test/resources/test-microprofile-aliases.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dataverse.new.example=dataverse.old.example

0 comments on commit e1cb339

Please sign in to comment.