[Major] RuntimeMock now also copies data

This commit is contained in:
Robert von Burg 2013-12-25 19:04:49 +01:00
parent edce1aaba4
commit f8ce5f22ec
1 changed files with 15 additions and 1 deletions

View File

@ -53,7 +53,7 @@ public final class RuntimeMock {
return this.container.getComponent(PersistenceHandler.class);
}
public void mockRuntime(File rootPathF, File configSrc) {
public void mockRuntime(File rootPathF, File rootSrc) {
if (!rootPathF.getParentFile().getName().equals(TARGET)) {
String msg = "Mocking path must be in a maven target: {0}"; //$NON-NLS-1$
@ -61,6 +61,9 @@ public final class RuntimeMock {
throw new RuntimeException(msg);
}
File configSrc = new File(rootSrc, RuntimeConfiguration.PATH_CONFIG);
File dataSrc = new File(rootSrc, RuntimeConfiguration.PATH_DATA);
if (!configSrc.isDirectory() || !configSrc.canRead()) {
String msg = "Could not find config source in: {0}"; //$NON-NLS-1$
msg = MessageFormat.format(msg, configSrc.getAbsolutePath());
@ -90,6 +93,17 @@ public final class RuntimeMock {
msg = MessageFormat.format(msg, configSrc.getAbsolutePath(), configPathF.getAbsolutePath());
throw new RuntimeException(msg);
}
if (dataSrc.exists()) {
File dataPathF = new File(rootPathF, RuntimeConfiguration.PATH_DATA);
dataPathF.mkdir();
if (!FileHelper.copy(dataSrc.listFiles(), dataPathF, false)) {
String msg = "Failed to copy source data from {0} to {1}"; //$NON-NLS-1$
msg = MessageFormat.format(msg, configSrc.getAbsolutePath(), configPathF.getAbsolutePath());
throw new RuntimeException(msg);
}
}
}
public void startContainer(File rootPathF) {