-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #455 from twicksell/handleMissingFileInTestPropert…
…yOverride @TestPropertyOverride now throws FileNotFoundException for missing files
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
archaius2-test/src/test/java/com/netflix/archaius/test/Archaius2RuleFailureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.netflix.archaius.test; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
|
||
public class Archaius2RuleFailureTest { | ||
|
||
@Test(expected = TestConfigException.class) | ||
public void testFileNotFoundExceptionThrownWhenNoPropFileFound() throws Throwable { | ||
|
||
Archaius2TestConfig conf = new Archaius2TestConfig(); | ||
|
||
// Annotation instance pointing to non-existent prop file | ||
Annotation testAnnotation = new TestPropertyOverride() { | ||
|
||
@Override | ||
public Class<? extends Annotation> annotationType() { | ||
return TestPropertyOverride.class; | ||
} | ||
|
||
@Override | ||
public String[] value() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String[] propertyFiles() { | ||
return new String[] { "doesNotExist.properties" }; | ||
} | ||
}; | ||
|
||
//No-op statement | ||
Statement base = new Statement() { | ||
@Override | ||
public void evaluate() throws Throwable { | ||
} | ||
}; | ||
|
||
Statement rule = conf.apply(base, Description.createTestDescription(getClass(), "test", testAnnotation)); | ||
rule.evaluate(); | ||
fail("Should've thrown an exception"); | ||
} | ||
} |