Skip to content
Snippets Groups Projects
Commit 592c8c82 authored by buczekp's avatar buczekp
Browse files

[LMS-2142] simple remote implementation of folder comparison

SVN: 20464
parent 112edce7
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,7 @@ public final class LocalDataSetFileOperationsExcecutor implements IDataSetFileOp
if (destination.isDirectory())
{
FileFilter nullFilter = null;
// TODO ignore symlinks?
List<File> storeFiles = FileUtilities.listFiles(dataSet, nullFilter, true);
List<File> destFiles = FileUtilities.listFiles(destination, nullFilter, true);
......
......@@ -175,8 +175,16 @@ public final class RemoteDataSetFileOperationsExecutor implements IDataSetFileOp
public BooleanStatus checkSame(File dataSet, File destination)
{
// TODO Auto-generated method stub
return null;
if (false == dataSet.exists())
{
return BooleanStatus.createFalse("Data set location '" + dataSet + "' doesn't exist");
}
// else if (false == fileOperations.exists(destination))
// {
// return BooleanStatus.createFalse("Destination location '" + destination
// + "' doesn't exist");
// }
return executor.exists(destination.getPath(), DataSetCopier.SSH_TIMEOUT_MILLIS);
}
}
\ No newline at end of file
......@@ -184,11 +184,7 @@ public class DataSetFileOperationsManager
public BooleanStatus isPresentInDestination(File originalData, DatasetDescription dataset)
{
File destinationFolder = new File(destination, dataset.getDataSetLocation());
BooleanStatus resultStatus = executor.exists(destinationFolder);
if (resultStatus.isSuccess())
{
resultStatus = executor.checkSame(originalData, destinationFolder);
}
BooleanStatus resultStatus = executor.checkSame(originalData, destinationFolder);
String message = resultStatus.tryGetMessage(); // if there is a message something went wrong
if (message != null)
{
......
......@@ -607,9 +607,8 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
context.assertIsSatisfied();
}
@Test(groups = "broken")
// FIXME
public void testRemoteViaSshIsPresentInDestination()
@Test
public void testRemoteViaSshIsPresentInDestinationSimpleCheck()
{
Properties properties = createRemoteViaSshDestinationProperties();
prepareRemoteCreateAndCheckCopier(HOST, null, true);
......@@ -619,13 +618,13 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
{
{
/*
* ds1: present
* ds1: error
*/
one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createTrue()));
will(returnValue(BooleanStatus.createError(DUMMY_ERROR_MESSAGE)));
/*
* ds2: not present
* ds2: not present - directory doesn't exist
*/
one(sshExecutor).exists(ds2ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createFalse()));
......@@ -633,12 +632,43 @@ public class DataSetFileOperationsManagerTest extends AbstractFileSystemTestCase
});
BooleanStatus status1 = dataSetCopier.isPresentInDestination(ds1Location, ds1);
BooleanStatus status2 = dataSetCopier.isPresentInDestination(ds2Location, ds2);
assertTrue(status1);
assertError(status1, DUMMY_ERROR_MESSAGE);
assertFalse(status2);
context.assertIsSatisfied();
}
@Test
public void testRemoteViaSshIsPresentInDestinationAdvancedCheck()
{
Properties properties = createRemoteViaSshDestinationProperties();
prepareRemoteCreateAndCheckCopier(HOST, null, true);
DataSetFileOperationsManager dataSetCopier =
new DataSetFileOperationsManager(properties, copierFactory, sshFactory);
context.checking(new Expectations()
{
{
/*
* ds1: TODO directory is present but content is different
*/
one(sshExecutor).exists(ds1ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createTrue()));
/*
* ds2: directory is present and content is OK
*/
one(sshExecutor).exists(ds2ArchivedLocationFile.getPath(), SSH_TIMEOUT_MILLIS);
will(returnValue(BooleanStatus.createTrue()));
}
});
BooleanStatus status1 = dataSetCopier.isPresentInDestination(ds1Location, ds1);
BooleanStatus status2 = dataSetCopier.isPresentInDestination(ds2Location, ds2);
assertTrue(status1);
assertTrue(status2);
context.assertIsSatisfied();
}
@Test
public void testRemoteViaSshIsPresentInDestinationWithError()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment