#813 Move test resources to conform to package structure

This commit is contained in:
ljacqu 2016-07-02 10:57:30 +02:00
parent de3f3a42ab
commit 70226f7ddb
21 changed files with 16 additions and 13 deletions

View File

@ -72,7 +72,7 @@ public class AuthMeInitializationTest {
public void initAuthMe() throws IOException {
dataFolder = temporaryFolder.newFolder();
settingsFile = new File(dataFolder, "config.yml");
Files.copy(TestHelper.getJarFile("/initialization/config.test.yml"), settingsFile);
Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "config.test.yml"), settingsFile);
// Mock / wire various Bukkit components
given(server.getLogger()).willReturn(mock(Logger.class));

View File

@ -28,6 +28,8 @@ import static org.mockito.Mockito.verify;
*/
public final class TestHelper {
public static final String PROJECT_ROOT = "/fr/xephi/authme/";
private TestHelper() {
}

View File

@ -45,7 +45,7 @@ public class CrazyLoginConverterTest {
private NewSetting settings;
@DataFolder
private File dataFolder = TestHelper.getJarFile("/converter/");
private File dataFolder = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "converter/");
@BeforeClass
public static void initializeLogger() {

View File

@ -41,7 +41,7 @@ public class ForceFlatToSqliteTest {
@Before
public void copyFile() throws IOException {
File source = TestHelper.getJarFile("/datasource-integration/flatfile-test.txt");
File source = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "datasource/flatfile-test.txt");
File destination = temporaryFolder.newFile();
Files.copy(source, destination);
flatFile = new FlatFile(destination);

View File

@ -35,7 +35,7 @@ public class FlatFileIntegrationTest {
@Before
public void copyFileToTemporaryFolder() throws IOException {
File originalFile = TestHelper.getJarFile("/datasource-integration/flatfile-test.txt");
File originalFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "datasource/flatfile-test.txt");
File copy = temporaryFolder.newFile();
Files.copy(originalFile, copy);
dataSource = new FlatFile(copy);

View File

@ -54,7 +54,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
set(DatabaseSettings.MYSQL_TABLE, "authme");
TestHelper.setupLogger();
Path sqlInitFile = TestHelper.getJarPath("/datasource-integration/sql-initialize.sql");
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
sqlInitialize = new String(Files.readAllBytes(sqlInitFile));
}

View File

@ -53,7 +53,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
set(DatabaseSettings.MYSQL_TABLE, "authme");
TestHelper.setupLogger();
Path sqlInitFile = TestHelper.getJarPath("/datasource-integration/sql-initialize.sql");
Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql");
// Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split
// the SQL file by ";\n" as to get the individual statements
sqlInitialize = new String(Files.readAllBytes(sqlInitFile)).split(";(\\r?)\\n");

View File

@ -33,8 +33,8 @@ import static org.mockito.Mockito.verify;
*/
public class MessagesIntegrationTest {
private static final String YML_TEST_FILE = "/messages_test.yml";
private static final String YML_DEFAULT_TEST_FILE = "/messages_default.yml";
private static final String YML_TEST_FILE = TestHelper.PROJECT_ROOT + "output/messages_test.yml";
private static final String YML_DEFAULT_TEST_FILE = TestHelper.PROJECT_ROOT + "output/messages_default.yml";
private Messages messages;
@BeforeClass
@ -255,7 +255,8 @@ public class MessagesIntegrationTest {
// assumption: message comes back as defined in messages_test.yml
assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!"));
NewSetting settings = mock(NewSetting.class);
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile("/messages_test2.yml"));
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));
// when
messages.loadSettings(settings);

View File

@ -32,11 +32,11 @@ import static org.junit.Assert.assertThat;
public class NewSettingIntegrationTest {
/** File name of the sample config including all {@link TestConfiguration} values. */
private static final String COMPLETE_FILE = "/config-sample-values.yml";
private static final String COMPLETE_FILE = TestHelper.PROJECT_ROOT + "settings/config-sample-values.yml";
/** File name of the sample config missing certain {@link TestConfiguration} values. */
private static final String INCOMPLETE_FILE = "/config-incomplete-sample.yml";
private static final String INCOMPLETE_FILE = TestHelper.PROJECT_ROOT + "settings/config-incomplete-sample.yml";
/** File name for testing difficult values. */
private static final String DIFFICULT_FILE = "/config-difficult-values.yml";
private static final String DIFFICULT_FILE = TestHelper.PROJECT_ROOT + "settings/config-difficult-values.yml";
private static PropertyMap propertyMap = TestConfiguration.generatePropertyMap();

View File

@ -54,7 +54,7 @@ public class SpawnLoaderTest {
public void setup() throws IOException {
// Copy test config into a new temporary folder
testFolder = temporaryFolder.newFolder();
File source = TestHelper.getJarFile("/spawn/spawn-firstspawn.yml");
File source = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "settings/spawn-firstspawn.yml");
File destination = new File(testFolder, "spawn.yml");
Files.copy(source, destination);