#534 Get default messages from the JAR's messages_en.yml
- Using new File(class.getResource(path)) apparently is the wrong approach for in-JAR files
This commit is contained in:
@@ -7,7 +7,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.mockito.internal.stubbing.answers.ReturnsArgumentAt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -55,17 +56,19 @@ public class NewSettingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnDefaultFile() {
|
||||
public void shouldReturnDefaultFile() throws IOException {
|
||||
// given
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
NewSetting settings = new NewSetting(configuration, null, null);
|
||||
|
||||
// when
|
||||
File defaultFile = settings.getDefaultMessagesFile();
|
||||
String defaultFile = settings.getDefaultMessagesFile();
|
||||
|
||||
// then
|
||||
assertThat(defaultFile, not(nullValue()));
|
||||
assertThat(defaultFile.exists(), equalTo(true));
|
||||
InputStream stream = this.getClass().getResourceAsStream(defaultFile);
|
||||
assertThat(stream, not(nullValue()));
|
||||
assertThat(stream.read(), not(equalTo(0)));
|
||||
}
|
||||
|
||||
private static <T> void setReturnValue(YamlConfiguration config, Property<T> property, T value) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class TestConfiguration implements SettingsClass {
|
||||
newProperty(PropertyType.STRING_LIST, "features.boring.colors");
|
||||
|
||||
public static final Property<Integer> DUST_LEVEL =
|
||||
newProperty(PropertyType.INTEGER, "features.boring.dustLevel", -1);
|
||||
newProperty("features.boring.dustLevel", -1);
|
||||
|
||||
public static final Property<Boolean> USE_COOL_FEATURES =
|
||||
newProperty("features.cool.enabled", false);
|
||||
|
||||
Reference in New Issue
Block a user