Minor - fix incorrect javadoc and add unit test for Messages#reload
This commit is contained in:
@@ -12,7 +12,7 @@ public final class TestHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link File} to an existing file from the main (non-test) resources folder.
|
||||
* Return a {@link File} to a file in the JAR's resources (main or test).
|
||||
*
|
||||
* @param path The absolute path to the file
|
||||
* @return The project file
|
||||
|
||||
@@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.arrayWithSize;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -249,4 +250,21 @@ public class MessagesIntegrationTest {
|
||||
// then
|
||||
assertThat(message, containsString("Error retrieving message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldLoadOtherFile() {
|
||||
// given
|
||||
MessageKey key = MessageKey.WRONG_PASSWORD;
|
||||
// assumption: message comes back as defined in messages_test.yml
|
||||
assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!"));
|
||||
|
||||
// when
|
||||
messages.reload(TestHelper.getJarFile("/messages_test2.yml"));
|
||||
|
||||
// then
|
||||
assertThat(messages.retrieveSingle(key), equalTo("test2 - wrong password"));
|
||||
// check that default message handling still works
|
||||
assertThat(messages.retrieveSingle(MessageKey.MUST_REGISTER_MESSAGE),
|
||||
equalTo("Message from default file"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Sample messages file
|
||||
|
||||
unknown_user: 'Message from test2'
|
||||
unsafe_spawn: 'test2 - unsafe spawn'
|
||||
not_logged_in: 'test2 - not logged in'
|
||||
wrong_pwd: 'test2 - wrong password'
|
||||
Reference in New Issue
Block a user