Skip to content

Commit

Permalink
tests: add additional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
credmond-git committed Nov 30, 2023
1 parent e8d3718 commit f3b603c
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package org.github.gestalt.config.reload;

import org.github.gestalt.config.exceptions.GestaltConfigurationException;
import org.github.gestalt.config.exceptions.GestaltException;
import org.github.gestalt.config.source.ConfigSource;
import org.github.gestalt.config.source.FileConfigSource;
import org.github.gestalt.config.source.StringConfigSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.Executors;

class FileChangeReloadStrategyTest {

Expand Down Expand Up @@ -138,6 +141,24 @@ public void changeContentsOfFileWithSymlinkChain() throws GestaltException, IOEx
Assertions.assertEquals(previousCount, listener.count);
}

@Test
public void wrongSourceConstructor() {
GestaltConfigurationException ex = Assertions.assertThrows(GestaltConfigurationException.class,
() -> new FileChangeReloadStrategy(new StringConfigSource("abc=def", "properties")));

Assertions.assertTrue(ex.getMessage().startsWith("Unable to add a File Change reload strategy to a non file source"));
}

@Test
public void wrongSourceSet() throws GestaltConfigurationException {
ConfigReloadStrategy strategy = new FileChangeReloadStrategy(Executors.newSingleThreadExecutor());

GestaltConfigurationException ex = Assertions.assertThrows(GestaltConfigurationException.class,
() -> strategy.setSource(new StringConfigSource("abc=def", "properties")));

Assertions.assertTrue(ex.getMessage().startsWith("Unable to add a File Change reload strategy to a non file source"));
}

private static class ConfigListener implements ConfigReloadListener {

public int count = 0;
Expand Down

0 comments on commit f3b603c

Please sign in to comment.