From b8334c5aee32e960e4f0dd0b10784d210a75c0ab Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Tue, 8 Sep 2009 17:18:39 +0000
Subject: [PATCH] Fix remaining tests. Re #767

---
 .../DataHandling/test/LoadMappingTableTest.h  |  5 ++--
 Code/Mantid/DataHandling/test/LoadRKHTest.h   |  4 ++-
 Code/Mantid/DataHandling/test/LoadRaw2Test.h  |  3 ++-
 Code/Mantid/DataHandling/test/LoadRawTest.h   |  3 ++-
 .../test/ManagedRawFileWorkspace2DTest.h      |  4 ++-
 Code/Mantid/DataHandling/test/SaveCSVTest.h   |  6 +++--
 Code/Mantid/Kernel/src/FileProperty.cpp       |  2 +-
 Code/Mantid/Nexus/test/LoadMuonNexusTest.h    |  2 +-
 Code/Mantid/Nexus/test/LoadNexusTest.h        |  2 +-
 Code/Mantid/Nexus/test/SaveNeXusTest.h        |  5 ++--
 .../Nexus/test/SaveNexusProcessedTest.h       | 25 +++++++++++--------
 11 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/Code/Mantid/DataHandling/test/LoadMappingTableTest.h b/Code/Mantid/DataHandling/test/LoadMappingTableTest.h
index 27efba83732..182c62c067c 100644
--- a/Code/Mantid/DataHandling/test/LoadMappingTableTest.h
+++ b/Code/Mantid/DataHandling/test/LoadMappingTableTest.h
@@ -12,6 +12,7 @@
 #include "MantidKernel/ConfigService.h"
 #include "MantidKernel/TimeSeriesProperty.h"
 #include "MantidAPI/SpectraDetectorMap.h"
+#include "Poco/Path.h"
 
 using namespace Mantid::API;
 using namespace Mantid::Kernel;
@@ -23,8 +24,8 @@ class LoadMappingTableTest : public CxxTest::TestSuite
 public:
 	LoadMappingTableTest()
 	{
-		//
-		 inputFile = "../../../../Test/Data/HET15869.RAW";
+	  //
+	  inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/HET15869.RAW").toString();
 		 outputSpace = "outerWS";
 		//initialise framework manager to allow logging
 		Mantid::API::FrameworkManager::Instance();
diff --git a/Code/Mantid/DataHandling/test/LoadRKHTest.h b/Code/Mantid/DataHandling/test/LoadRKHTest.h
index 0f45901ab4d..08a27553957 100644
--- a/Code/Mantid/DataHandling/test/LoadRKHTest.h
+++ b/Code/Mantid/DataHandling/test/LoadRKHTest.h
@@ -8,14 +8,16 @@
 
 #include "MantidDataHandling/LoadRKH.h"
 #include "MantidDataObjects/Workspace1D.h"
+#include "Poco/Path.h"
 
 class LoadRKHTest : public CxxTest::TestSuite
 {
 public:
 
   // A sample file is in the repository
-  LoadRKHTest() : inputFile("../../../../Test/Data/DIRECT.041")
+  LoadRKHTest() : inputFile("")
   {    
+    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/DIRECT.041").toString();
   }
 
   void testInit()
diff --git a/Code/Mantid/DataHandling/test/LoadRaw2Test.h b/Code/Mantid/DataHandling/test/LoadRaw2Test.h
index 3a1eae594c4..4dc45fdc6db 100644
--- a/Code/Mantid/DataHandling/test/LoadRaw2Test.h
+++ b/Code/Mantid/DataHandling/test/LoadRaw2Test.h
@@ -11,6 +11,7 @@
 #include "MantidKernel/ConfigService.h"
 #include "MantidKernel/TimeSeriesProperty.h"
 #include "MantidAPI/SpectraDetectorMap.h"
+#include "Poco/Path.h"
 
 using namespace Mantid::API;
 using namespace Mantid::Kernel;
@@ -24,7 +25,7 @@ public:
   LoadRaw2Test()
   {
     // Path to test input file assumes Test directory checked out from SVN
-    inputFile = "../../../../Test/Data/HET15869.RAW";
+    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/HET15869.RAW").toString();
   }
 
   void testInit()
diff --git a/Code/Mantid/DataHandling/test/LoadRawTest.h b/Code/Mantid/DataHandling/test/LoadRawTest.h
index 5697d5567d4..820c8bf6ae1 100644
--- a/Code/Mantid/DataHandling/test/LoadRawTest.h
+++ b/Code/Mantid/DataHandling/test/LoadRawTest.h
@@ -12,6 +12,7 @@
 #include "MantidKernel/ConfigService.h"
 #include "MantidKernel/TimeSeriesProperty.h"
 #include "MantidAPI/SpectraDetectorMap.h"
+#include "Poco/Path.h"
 
 using namespace Mantid::API;
 using namespace Mantid::Kernel;
@@ -25,7 +26,7 @@ public:
   LoadRawTest()
   {
     // Path to test input file assumes Test directory checked out from SVN
-    inputFile = "../../../../Test/Data/HET15869.RAW";
+    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/HET15869.RAW").toString();
   }
 
   void testInit()
diff --git a/Code/Mantid/DataHandling/test/ManagedRawFileWorkspace2DTest.h b/Code/Mantid/DataHandling/test/ManagedRawFileWorkspace2DTest.h
index 2467122bceb..6872650597b 100644
--- a/Code/Mantid/DataHandling/test/ManagedRawFileWorkspace2DTest.h
+++ b/Code/Mantid/DataHandling/test/ManagedRawFileWorkspace2DTest.h
@@ -8,6 +8,7 @@
 #include "MantidDataHandling/LoadRaw2.h"
 #include "MantidKernel/TimeSeriesProperty.h"
 #include "MantidAPI/SpectraDetectorMap.h"
+#include "Poco/Path.h"
 
 using namespace Mantid::API;
 using namespace Mantid::Kernel;
@@ -98,7 +99,8 @@ public:
     // Should fail because mandatory parameter has not been set
     TS_ASSERT_THROWS(loader.execute(),std::runtime_error);
 
-    std::string inputFile = "../../../../Test/Data/HET15869.RAW";
+      std::string    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/HET15869.RAW").toString();
+
     // Now set it...
     loader.setPropertyValue("Filename", inputFile);
 
diff --git a/Code/Mantid/DataHandling/test/SaveCSVTest.h b/Code/Mantid/DataHandling/test/SaveCSVTest.h
index 1ed8b02bc1e..7866a20a1e1 100644
--- a/Code/Mantid/DataHandling/test/SaveCSVTest.h
+++ b/Code/Mantid/DataHandling/test/SaveCSVTest.h
@@ -59,14 +59,16 @@ public:
     algToBeTested.setPropertyValue("InputWorkspace", "SAVECSVTEST-testSpace");     
     
     // Should fail because mandatory parameter has not been set
-    TS_ASSERT_THROWS(algToBeTested.execute(),std::runtime_error);
+    algToBeTested.execute();
+    TS_ASSERT_EQUALS(algToBeTested.isExecuted(), false)
         
     
     // Now set it...
     // specify name of file to save 1D-workspace to
     outputFile = "testOfSaveCSV.csv";
     algToBeTested.setPropertyValue("Filename", outputFile);
-    
+    outputFile = algToBeTested.getPropertyValue("Filename");
+
     std::string result;
     TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("Filename") )
     TS_ASSERT( ! result.compare(outputFile)); 
diff --git a/Code/Mantid/Kernel/src/FileProperty.cpp b/Code/Mantid/Kernel/src/FileProperty.cpp
index 57f6a2cb23d..a331a2c30b9 100644
--- a/Code/Mantid/Kernel/src/FileProperty.cpp
+++ b/Code/Mantid/Kernel/src/FileProperty.cpp
@@ -43,7 +43,7 @@ bool FileProperty::isLoadProperty() const
 std::string FileProperty::setValue(const std::string & filename)
 {
   // If the path is absolute then don't do any searching
-  if( Poco::Path(filename).isAbsolute() )
+  if( filename.empty() || Poco::Path(filename).isAbsolute())
   {
     return PropertyWithValue<std::string>::setValue(filename);
   }
diff --git a/Code/Mantid/Nexus/test/LoadMuonNexusTest.h b/Code/Mantid/Nexus/test/LoadMuonNexusTest.h
index d4739239511..6b6f5a11177 100644
--- a/Code/Mantid/Nexus/test/LoadMuonNexusTest.h
+++ b/Code/Mantid/Nexus/test/LoadMuonNexusTest.h
@@ -165,7 +165,7 @@ public:
   {
     //test for multi period
     // Now set required filename and output workspace name
-    inputFile2 = "../../../../Test/Nexus/emu00006475.nxs";
+    inputFile2 = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Nexus/emu00006475.nxs").toString();
     nxLoad.setPropertyValue("FileName", inputFile2);
 
     outputSpace="outer2";
diff --git a/Code/Mantid/Nexus/test/LoadNexusTest.h b/Code/Mantid/Nexus/test/LoadNexusTest.h
index a06105fc237..a3875b2c6fc 100644
--- a/Code/Mantid/Nexus/test/LoadNexusTest.h
+++ b/Code/Mantid/Nexus/test/LoadNexusTest.h
@@ -89,7 +89,7 @@ public:
     alg2.setPropertyValue("OutputWorkspace", outputSpace);     
     
     // specify name of file to load workspace from
-    inputFile = "../../../../Test/Nexus/emu00006475.nxs";
+    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Nexus/emu00006475.nxs").toString();
     alg2.setPropertyValue("FileName", inputFile);
    
     std::string result;
diff --git a/Code/Mantid/Nexus/test/SaveNeXusTest.h b/Code/Mantid/Nexus/test/SaveNeXusTest.h
index 81d6c4ec45c..8e8825011c0 100644
--- a/Code/Mantid/Nexus/test/SaveNeXusTest.h
+++ b/Code/Mantid/Nexus/test/SaveNeXusTest.h
@@ -44,7 +44,7 @@ void testExecOnMuon()
     nxLoad.initialize();
     // Now set required filename and output workspace name
     inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Nexus/emu00006473.nxs").toString();
-    nxLoad.setPropertyValue("FileName", inputFile);
+    nxLoad.setPropertyValue("Filename", inputFile);
     outputSpace="outer";
     nxLoad.setPropertyValue("OutputWorkspace", outputSpace);     
     //
@@ -64,7 +64,8 @@ void testExecOnMuon()
     // specify parameters to algorithm
     algToBeTested.setPropertyValue("InputWorkspace", outputSpace);
     outputFile = "testOfSaveNexus.nxs";
-    algToBeTested.setPropertyValue("FileName", outputFile);
+    algToBeTested.setPropertyValue("Filename", outputFile);
+    outputFile = algToBeTested.getPropertyValue("Filename");
     title="Testing SaveNexus with Muon data";
     algToBeTested.setPropertyValue("Title", title);
     // comment line below to check the contents of the o/p file manually
diff --git a/Code/Mantid/Nexus/test/SaveNexusProcessedTest.h b/Code/Mantid/Nexus/test/SaveNexusProcessedTest.h
index cc41bee4563..70808df87d9 100644
--- a/Code/Mantid/Nexus/test/SaveNexusProcessedTest.h
+++ b/Code/Mantid/Nexus/test/SaveNexusProcessedTest.h
@@ -19,6 +19,7 @@
 #include "MantidNexus/LoadNeXus.h"
 #include "MantidKernel/UnitFactory.h"
 #include "Poco/File.h"
+#include "Poco/Path.h"
 #include "MantidDataHandling/LoadRaw3.h"
 
 using namespace Mantid::API;
@@ -79,13 +80,14 @@ public:
     //entryName = "test";
     dataName = "spectra";
     title = "A simple workspace saved in Processed Nexus format";
-    TS_ASSERT_THROWS_NOTHING(algToBeTested.setPropertyValue("FileName", outputFile));
+    TS_ASSERT_THROWS_NOTHING(algToBeTested.setPropertyValue("Filename", outputFile));
+    outputFile = algToBeTested.getPropertyValue("Filename");
     //algToBeTested.setPropertyValue("EntryName", entryName);
     algToBeTested.setPropertyValue("Title", title);
     if( Poco::File(outputFile).exists() ) Poco::File(outputFile).remove();
 
     std::string result;
-    TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("FileName") )
+    TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("Filename") )
     TS_ASSERT( ! result.compare(outputFile));
     //TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("EntryName") )
     //TS_ASSERT( ! result.compare(entryName));
@@ -104,8 +106,8 @@ void testExecOnMuon()
     std::string outputSpace,inputFile;
     nxLoad.initialize();
     // Now set required filename and output workspace name
-    inputFile = "../../../../Test/Nexus/emu00006473.nxs";
-    nxLoad.setPropertyValue("FileName", inputFile);
+    inputFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Nexus/emu00006473.nxs").toString();
+    nxLoad.setPropertyValue("Filename", inputFile);
     outputSpace="outer";
     nxLoad.setPropertyValue("OutputWorkspace", outputSpace);
     //
@@ -131,7 +133,8 @@ void testExecOnMuon()
     //entryName = "entry4";
     dataName = "spectra";
     title = "A save of a 2D workspace from Muon file";
-    algToBeTested.setPropertyValue("FileName", outputFile);
+    algToBeTested.setPropertyValue("Filename", outputFile);
+    outputFile = algToBeTested.getPropertyValue("Filename");
     //algToBeTested.setPropertyValue("EntryName", entryName);
     algToBeTested.setPropertyValue("Title", title);
 	algToBeTested.setPropertyValue("Append", "0");
@@ -182,11 +185,11 @@ void testExecOnLoadraw()
     //entryName = "entry4";
     dataName = "spectra";
     title = "A save of a workspace from Loadraw file";
-    algToBeTested.setPropertyValue("FileName", outputFile);
+    algToBeTested.setPropertyValue("Filename", outputFile);
     //algToBeTested.setPropertyValue("EntryName", entryName);
     algToBeTested.setPropertyValue("Title", title);
-	algToBeTested.setPropertyValue("Append", "0");
-
+    algToBeTested.setPropertyValue("Append", "0");
+    outputFile = algToBeTested.getPropertyValue("Filename");
     std::string result;
     TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("Filename") );
     TS_ASSERT( ! result.compare(outputFile));
@@ -211,7 +214,7 @@ void testExecOnMuonXml()
     nxLoad.initialize();
     // Now set required filename and output workspace name
     inputFile = "../../../../Test/Nexus/emu00006473.nxs";
-    nxLoad.setPropertyValue("FileName", inputFile);
+    nxLoad.setPropertyValue("Filename", inputFile);
     outputSpace="outer";
     nxLoad.setPropertyValue("OutputWorkspace", outputSpace);
     //
@@ -234,10 +237,10 @@ void testExecOnMuonXml()
     //entryName = "entry4";
     dataName = "spectra";
     title = "A save of a 2D workspace from Muon file";
-    algToBeTested.setPropertyValue("FileName", outputFile);
+    algToBeTested.setPropertyValue("Filename", outputFile);
     //algToBeTested.setPropertyValue("EntryName", entryName);
     algToBeTested.setPropertyValue("Title", title);
-
+    outputFile = algToBeTested.getPropertyValue("Filename");
     std::string result;
     TS_ASSERT_THROWS_NOTHING( result = algToBeTested.getPropertyValue("Filename") );
     TS_ASSERT( ! result.compare(outputFile));
-- 
GitLab