X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2FTestAuthFileWatcher.java;h=19e18deb5f1b2f06f879a2543319cf27448a01a4;hb=176c445bbeb5e47011ff2ca4816c00dd0f6ea779;hp=15278e51e5f5742048093ae275b182403c425489;hpb=811169825805a7160a6dd28abb281f64a4a56c71;p=aai%2Fbabel.git diff --git a/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java b/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java index 15278e5..19e18de 100644 --- a/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java +++ b/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java @@ -22,13 +22,14 @@ package org.onap.aai.babel; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.io.File; import java.io.IOException; import java.util.TimerTask; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.onap.aai.auth.AAIAuthException; import org.onap.aai.auth.AAIMicroServiceAuth; @@ -45,25 +46,29 @@ public class TestAuthFileWatcher { private TimerTask task; private File mockFile = Mockito.mock(File.class); - @Before + @BeforeEach public void createTask() { task = new AuthFileWatcher(mockFile); } - @Test(expected = Test.None.class /* no exception expected */) + @Test public void testOnChangeDoesNotRun() { - task.run(); + assertDoesNotThrow(() -> { + task.run(); + }); } - @Test(expected = Test.None.class /* no exception expected */) + @Test public void testOnChangeDoesRun() throws IOException, AAIAuthException { - System.setProperty("CONFIG_HOME", "src/test/resources"); - BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig(); - babelServiceAuthConfig.setAuthPolicyFile("auth_policy.json"); - new AAIMicroServiceAuth(babelServiceAuthConfig); + assertDoesNotThrow(() -> { + System.setProperty("CONFIG_HOME", "src/test/resources"); + BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig(); + babelServiceAuthConfig.setAuthPolicyFile("auth_policy.json"); + new AAIMicroServiceAuth(babelServiceAuthConfig); - Mockito.when(mockFile.lastModified()).thenReturn(1000L); - task.run(); + Mockito.when(mockFile.lastModified()).thenReturn(1000L); + task.run(); + }); } @Test