[fdo-commits] r2582 - in trunk/Providers/SDF/Src: Provider UnitTest

svn_fdo at osgeo.org svn_fdo at osgeo.org
Thu Feb 22 09:26:12 EST 2007


Author: pierredalcourt
Date: 2007-02-22 09:26:12 -0500 (Thu, 22 Feb 2007)
New Revision: 2582

Modified:
   trunk/Providers/SDF/Src/Provider/SdfExpressionCapabilities.cpp
   trunk/Providers/SDF/Src/UnitTest/ApplySchemaTest.cpp
   trunk/Providers/SDF/Src/UnitTest/AssociationSchemaTest.h
   trunk/Providers/SDF/Src/UnitTest/ConnectionInfoTest.h
   trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h
   trunk/Providers/SDF/Src/UnitTest/Makefile.am
   trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
   trunk/Providers/SDF/Src/UnitTest/MasterTest.h
   trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp
   trunk/Providers/SDF/Src/UnitTest/SelectTest.h
   trunk/Providers/SDF/Src/UnitTest/SpatialContextTest.cpp
   trunk/Providers/SDF/Src/UnitTest/UnitTest.vcproj
   trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp
   trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h
Log:
TRAC Ticket #17 "SHP/SDF: fix various Select/SelectAggregates defects"


Modified: trunk/Providers/SDF/Src/Provider/SdfExpressionCapabilities.cpp
===================================================================
--- trunk/Providers/SDF/Src/Provider/SdfExpressionCapabilities.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/Provider/SdfExpressionCapabilities.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -144,6 +144,8 @@
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Double, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Single, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Decimal, 
+            FdoPropertyType_DataProperty, FdoDataType_DateTime, 1, FdoPropertyType_DataProperty, FdoDataType_DateTime,
+            FdoPropertyType_DataProperty, FdoDataType_String, 1, FdoPropertyType_DataProperty, FdoDataType_String,
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Byte, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Int16, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Int32, 
@@ -166,6 +168,8 @@
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Double, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Single, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Decimal, 
+            FdoPropertyType_DataProperty, FdoDataType_DateTime, 1, FdoPropertyType_DataProperty, FdoDataType_DateTime,
+            FdoPropertyType_DataProperty, FdoDataType_String, 1, FdoPropertyType_DataProperty, FdoDataType_String,
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Byte, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Int16, 
             FdoPropertyType_DataProperty, FdoDataType_Double, 1, FdoPropertyType_DataProperty, FdoDataType_Int32, 

Modified: trunk/Providers/SDF/Src/UnitTest/ApplySchemaTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/ApplySchemaTest.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/ApplySchemaTest.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -16,12 +16,7 @@
 
 #include "ApplySchemaTest.h"
 #include "UnitTestUtil.h"
-/*
-#include "XmlFormatter.h"
-#include <Inc/Fdo/Rdbms/FdoIDescribeSchema.h>
-#include <Inc/Fdo/Rdbms/FdoRdbmsDescribeSchemaMappingCommand.h>
-#include <Inc/Fdo/Rdbms/FdoRdbmsDestroySchemaCommand.h>
-*/
+
 #ifdef _WIN32
 #include <windows.h>
 #else
@@ -208,37 +203,33 @@
 		// Compare output files with expected results.
 
 
-        UnitTestUtil::CheckOutput( "apply_schema_test1_master.xml", "apply_schema_test1.xml" );
-        UnitTestUtil::CheckOutput( "apply_schema_test2_master.xml", "apply_schema_test2.xml" );
-        UnitTestUtil::CheckOutput( "apply_schema_test3_master.xml", "apply_schema_test3.xml" );
-        UnitTestUtil::CheckOutput( "apply_schema_test4_master.xml", "apply_schema_test4.xml" );
-        UnitTestUtil::CheckOutput( "apply_schema_test5_master.xml", "apply_schema_test5.xml" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_test1_master.xml", "apply_schema_test1.xml" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_test2_master.xml", "apply_schema_test2.xml" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_test3_master.xml", "apply_schema_test3.xml" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_test4_master.xml", "apply_schema_test4.xml" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_test5_master.xml", "apply_schema_test5.xml" );
 
         // Next do the error messages. Some checks are not done for some providers
         // since their expect output is different from the master
         // TODO: create special masters for these cases.
 
 #ifdef _WIN32
-        UnitTestUtil::CheckOutput( "apply_schema_err1_master.txt", "apply_schema_err1.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err2_master.txt", "apply_schema_err2.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err3_imaster.txt", "apply_schema_err3.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err4_master.txt", "apply_schema_err4.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err5_imaster.txt", "apply_schema_err5.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err6_imaster.txt", "apply_schema_err6.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err7_master.txt", "apply_schema_err7.txt" );
-		UnitTestUtil::CheckOutput( "apply_schema_err8_master.txt", "apply_schema_err8.txt" );
-        UnitTestUtil::CheckOutput( "apply_schema_err10_master.txt", "apply_schema_err10.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err1_master.txt", "apply_schema_err1.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err2_master.txt", "apply_schema_err2.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err3_imaster.txt", "apply_schema_err3.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err4_master.txt", "apply_schema_err4.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err5_imaster.txt", "apply_schema_err5.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err6_imaster.txt", "apply_schema_err6.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err7_master.txt", "apply_schema_err7.txt" );
+		TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err8_master.txt", "apply_schema_err8.txt" );
+        TestCommonFileUtil::CompareFilesAndThrow( "apply_schema_err10_master.txt", "apply_schema_err10.txt" );
 #endif
 
     }
 	catch ( FdoException* e ) 
 	{
-		UnitTestUtil::FailOnException( e );
+		TestCommonFail( e );
 	}
-	catch ( CppUnit::Exception e ) 
-	{
-		throw;
-	}
    	catch (...)
    	{
    		CPPUNIT_FAIL ("caught unexpected exception");
@@ -274,12 +265,8 @@
     }
 	catch ( FdoException* e ) 
 	{
-		UnitTestUtil::FailOnException( e );
+		TestCommonFail( e );
 	}
-	catch ( CppUnit::Exception e ) 
-	{
-		throw;
-	}
    	catch (...)
    	{
    		CPPUNIT_FAIL ("caught unexpected exception");
@@ -311,12 +298,8 @@
     }
 	catch ( FdoException* e ) 
 	{
-		UnitTestUtil::FailOnException( e );
+		TestCommonFail( e );
 	}
-	catch ( CppUnit::Exception e ) 
-	{
-		throw;
-	}
    	catch (...)
    	{
    		CPPUNIT_FAIL ("caught unexpected exception");

Modified: trunk/Providers/SDF/Src/UnitTest/AssociationSchemaTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/AssociationSchemaTest.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/AssociationSchemaTest.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -24,6 +24,7 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include <map>
+#include <TestCommonMiscUtil.h>
 
 /* 
  * The unit test of the association schema.

Modified: trunk/Providers/SDF/Src/UnitTest/ConnectionInfoTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/ConnectionInfoTest.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/ConnectionInfoTest.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -10,6 +10,7 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include <Fdo.h>
+#include <TestCommonMiscUtil.h>
 
 /* 
  * Checks whether or not the provider type and list of dependent files

Modified: trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -24,6 +24,7 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include "Fdo.h"
+#include <TestCommonMiscUtil.h>
 
 struct ConnectInfo {
     int   connectionId;

Modified: trunk/Providers/SDF/Src/UnitTest/Makefile.am
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/Makefile.am	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/Makefile.am	2007-02-22 14:26:12 UTC (rev 2582)
@@ -38,6 +38,7 @@
   ExtendedSelectTest.cpp \
   NlsTest.cpp \
   SelectTest.cpp \
+  SchemaTest.cpp \
   SpatialContextTest.cpp \
   UnitTestUtil.cpp
 
@@ -56,6 +57,7 @@
   MasterTest.h \
   NlsTest.h \
   SelectTest.h \
+  SchemaTest.h \
   SpatialContextTest.h \
   UnitTestUtil.h \
   tester-linux.h
@@ -63,11 +65,13 @@
 INCLUDES = \
   -I$(FDO)/Unmanaged/Inc \
   -I$(FDOUTILITIES)/TestCommon/Inc \
+  -I$(FDOUTILITIES)/Common/Inc \
   -I$(FDOTHIRDPARTY)/linux/cppunit/include/ \
   -I../../Inc
 
 UnitTest_LDADD = \
   $(FDOUTILITIES)/TestCommon/libTestCommon.la \
+  $(FDOUTILITIES)/Common/libProvidersCommon.la \
   $(FDO)/Unmanaged/Src/libFDO.la \
   $(FDOTHIRDPARTY)/linux/cppunit/lib/libcppunit.a \
   -ldl \

Modified: trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -59,11 +59,15 @@
 #include <ctime>
 #include <math.h>
 #include "MasterTest.h"
+#include "FdoCommonFile.h"
+#include "SDF/SdfCommandType.h"
+#include "SDF/ICreateSDFFile.h"
 #include "UnitTestUtil.h"
 #include <cppunit/extensions/HelperMacros.h>
 const wchar_t* DEST_PATH = L"../../TestData/PARCEL_linuxtest.SDX";
 const wchar_t* SHP_PATH = L"../../TestData/World_Countries.sdf";
 const wchar_t* SHP_PATH2 = L"../../TestData/province.sdf";
+const wchar_t* AGGR_PATH = L"../../TestData/TestAggregates.sdf";
 
 // Replace the text "TestExample" with your own class name
 CPPUNIT_TEST_SUITE_REGISTRATION(MasterTest);
@@ -153,7 +157,7 @@
         conn->Close();
     }
     catch ( FdoException* ex ) {
-        UnitTestUtil::FailOnException( ex );
+        TestCommonFail( ex );
     }
 }
 
@@ -191,7 +195,7 @@
         conn->Close();
     }
     catch ( FdoException* ex ) {
-        UnitTestUtil::FailOnException( ex );
+        TestCommonFail( ex );
     }
 }
 
@@ -228,361 +232,395 @@
         update_conn->Close();
     }
     catch ( FdoException* ex ) {
-        UnitTestUtil::FailOnException( ex );
+        TestCommonFail( ex );
     }
 }
 
 void MasterTest::keyFilterBeforeDelete()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);
-       
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);
+           
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
-    //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022') or (Key = 'LN0316')");
-    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%' or Key = 'LN0316' or Key = 'DI0022'");
+        //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022') or (Key = 'LN0316')");
+        FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%' or Key = 'LN0316' or Key = 'DI0022'");
 
 
-    select->SetFilter(filter);
-    
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        select->SetFilter(filter);
+        
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
-    FdoPtr<FdoByteArray> geom;
-    
-    printf("\n\n\nKey Filter");
-    
-    char tmp[1024];
-    
-    while (rdr->ReadNext())
-    {
-        const wchar_t* something = rdr->GetString(L"Name");
-        wcstombs(tmp, something, 1024);
-        printf("%s\n", tmp);
-        count2++;
-    }
+        FdoPtr<FdoByteArray> geom;
+        
+        printf("\n\n\nKey Filter");
+        
+        char tmp[1024];
+        
+        while (rdr->ReadNext())
+        {
+            const wchar_t* something = rdr->GetString(L"Name");
+            wcstombs(tmp, something, 1024);
+            printf("%s\n", tmp);
+            count2++;
+        }
 
 
-    rdr->Close();
+        rdr->Close();
 
-    conn->Close();
+        conn->Close();
 
-    printf ("\nKey filter, number of features returned = %d\n", count2);
+        printf ("\nKey filter, number of features returned = %d\n", count2);
 
-    CPPUNIT_ASSERT(count2 == 154);
+        CPPUNIT_ASSERT(count2 == 154);
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 void MasterTest::keyFilterAfterDelete()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);
-       
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);
+           
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
-    //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022') or (Key = 'LN0316')");
-    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%' or Key = 'LN0316' or Key = 'DI0022'");
+        //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022') or (Key = 'LN0316')");
+        FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%' or Key = 'LN0316' or Key = 'DI0022'");
 
 
-    select->SetFilter(filter);
-    
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        select->SetFilter(filter);
+        
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
-    FdoPtr<FdoByteArray> geom;
-    
-    printf("\n\n\nKey Filter Again... after delete");
-    
-    char tmp[1024];
+        FdoPtr<FdoByteArray> geom;
+        
+        printf("\n\n\nKey Filter Again... after delete");
+        
+        char tmp[1024];
 
-    while (rdr->ReadNext())
-    {
-        const wchar_t* something = rdr->GetString(L"Name");
-        wcstombs(tmp, something, 1024);
-        printf("%s\n", tmp);
-        count2++;
-    }
+        while (rdr->ReadNext())
+        {
+            const wchar_t* something = rdr->GetString(L"Name");
+            wcstombs(tmp, something, 1024);
+            printf("%s\n", tmp);
+            count2++;
+        }
 
-    rdr->Close();
+        rdr->Close();
 
-    conn->Close();
+        conn->Close();
 
-    printf ("\nKey filter after delete, number of features returned = %d\n", count2);
-    CPPUNIT_ASSERT(count2 == 152);
+        printf ("\nKey filter after delete, number of features returned = %d\n", count2);
+        CPPUNIT_ASSERT(count2 == 152);
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 void MasterTest::computedPropTest()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);    
-   
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);    
+       
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
 
-    FdoPtr<FdoIdentifierCollection> propnames = select->GetPropertyNames();
+        FdoPtr<FdoIdentifierCollection> propnames = select->GetPropertyNames();
 
-    FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"2+3");
-    FdoPtr<FdoComputedIdentifier> ci = FdoComputedIdentifier::Create(L"ComputedInt", expr);
-    propnames->Add(ci);
+        FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"2+3");
+        FdoPtr<FdoComputedIdentifier> ci = FdoComputedIdentifier::Create(L"ComputedInt", expr);
+        propnames->Add(ci);
 
 
-    //computed identifier used as filter... hehe.
-    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name) As ComputedString, (ComputedString = 'MO0418') or (ComputedString = 'DE0065')");
-    select->SetFilter(filter);
+        //computed identifier used as filter... hehe.
+        FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name) As ComputedString, (ComputedString = 'MO0418') or (ComputedString = 'DE0065')");
+        select->SetFilter(filter);
 
-    
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
-    FdoPtr<FdoByteArray> geom;
+        FdoPtr<FdoByteArray> geom;
 
-    FdoPtr<FdoClassDefinition> classDef = rdr->GetClassDefinition();
-       
-    char tmp[1024];
-    
-    while (rdr->ReadNext())
-    {
+        FdoPtr<FdoClassDefinition> classDef = rdr->GetClassDefinition();
+           
+        char tmp[1024];
+        
+        while (rdr->ReadNext())
+        {
 
-        FdoInt64 something = rdr->GetInt64(L"ComputedInt");
-        FdoString* something2 = rdr->GetString(L"Name");
+            FdoInt64 something = rdr->GetInt64(L"ComputedInt");
+            FdoString* something2 = rdr->GetString(L"Name");
 
-        printf("Computed identifier 1:   %ld\n", something);
-        
-        wcstombs(tmp, something2, 1024);
-        printf("Feature name:   %s\n", tmp);
+            printf("Computed identifier 1:   %ld\n", something);
+            
+            wcstombs(tmp, something2, 1024);
+            printf("Feature name:   %s\n", tmp);
 
-        try 
-        {
-            rdr->GetString(L"whoop dee doo");
+            try 
+            {
+                rdr->GetString(L"whoop dee doo");
+            }
+            catch (FdoException* e)
+            {
+                printf("correctly caught exception about non-existing property\n");
+                e->Release();
+            }
+
+            count2++;
         }
-        catch (FdoException* e)
-        {
-            printf("correctly caught exception about non-existing property\n");
-            e->Release();
-        }
 
-        count2++;
-    }
 
+        rdr->Close();
 
-    rdr->Close();
+        printf ("\nString filter, number of features returned = %d\n", count2);
 
-    printf ("\nString filter, number of features returned = %d\n", count2);
-
-    conn->Close();
-    
+        conn->Close();
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 
 void MasterTest::stringFilter()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);    
-   
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);    
+       
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
-    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
+        FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
 
 
-    select->SetFilter(filter);
-    
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        select->SetFilter(filter);
+        
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
 
-    FdoPtr<FdoByteArray> geom;
+        FdoPtr<FdoByteArray> geom;
 
-    char tmp[1024];
-    
-    while (rdr->ReadNext())
-    {
+        char tmp[1024];
+        
+        while (rdr->ReadNext())
+        {
 
-        const wchar_t* something = rdr->GetString(L"Name");
+            const wchar_t* something = rdr->GetString(L"Name");
 
-        try 
-        {
-            rdr->GetString(L"whoop dee doo");
-        }
-        catch (FdoException* e)
-        {
-            printf("correctly caught exception about non-existing property\n");
-            e->Release();
-        }
+            try 
+            {
+                rdr->GetString(L"whoop dee doo");
+            }
+            catch (FdoException* e)
+            {
+                printf("correctly caught exception about non-existing property\n");
+                e->Release();
+            }
 
-        wcstombs(tmp, something, 1024);
-        printf("%s\n", tmp);
+            wcstombs(tmp, something, 1024);
+            printf("%s\n", tmp);
 
-        count2++;
-    }
+            count2++;
+        }
 
 
-    rdr->Close();
+        rdr->Close();
 
-    printf ("\nString filter, number of features returned = %d\n", count2);
+        printf ("\nString filter, number of features returned = %d\n", count2);
 
-    conn->Close();
-    
+        conn->Close();
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 void MasterTest::rtreeFilter()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);    
-    
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);    
+        
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
-    //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
+        //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
 
-    
-    FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+        
+        FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
 
-    double coords[] = { 7.2230, 43.6861, 
-                        7.2505, 43.6861, 
-                        7.2505, 43.7134, 
-                        7.2230, 43.7134, 
-                        7.2230, 43.6861 }; //last pt equals first for rings
+        double coords[] = { 7.2230, 43.6861, 
+                            7.2505, 43.6861, 
+                            7.2505, 43.7134, 
+                            7.2230, 43.7134, 
+                            7.2230, 43.6861 }; //last pt equals first for rings
 
-    FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+        FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
 
-    FdoPtr<FdoIPolygon> poly = gf->CreatePolygon(outer, NULL);
+        FdoPtr<FdoIPolygon> poly = gf->CreatePolygon(outer, NULL);
 
-    FdoPtr<FdoByteArray> polyfgf = gf->GetFgf(poly);
-    FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(polyfgf);
-    FdoPtr<FdoSpatialCondition> filter = FdoSpatialCondition::Create(L"Data", FdoSpatialOperations_EnvelopeIntersects, gv);
-    
+        FdoPtr<FdoByteArray> polyfgf = gf->GetFgf(poly);
+        FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(polyfgf);
+        FdoPtr<FdoSpatialCondition> filter = FdoSpatialCondition::Create(L"Data", FdoSpatialOperations_EnvelopeIntersects, gv);
+        
 
-    printf("\n\n\nR-Tree filter");
+        printf("\n\n\nR-Tree filter");
 
-    select->SetFilter(filter);
-   
-    clock_t start;
-    clock_t finish;
-    start = clock ();
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        select->SetFilter(filter);
+       
+        clock_t start;
+        clock_t finish;
+        start = clock ();
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
-    FdoPtr<FdoByteArray> geom;
+        FdoPtr<FdoByteArray> geom;
 
-    while (rdr->ReadNext())
-    {
-        const wchar_t* something = rdr->GetString(L"Name");
-        count2++;
-    }
+        while (rdr->ReadNext())
+        {
+            const wchar_t* something = rdr->GetString(L"Name");
+            count2++;
+        }
 
-    rdr->Close();
-    
+        rdr->Close();
+        
 
-    finish = clock ();
-    printf("Count = %d  time: %2.3f seconds \n", count2, (double)(finish - start) / CLOCKS_PER_SEC);
-    //correct R-Tree will return that many features!
-    CPPUNIT_ASSERT(count2 == 4535);
+        finish = clock ();
+        printf("Count = %d  time: %2.3f seconds \n", count2, (double)(finish - start) / CLOCKS_PER_SEC);
+        //correct R-Tree will return that many features!
+        CPPUNIT_ASSERT(count2 == 4535);
 
 
-    // Now do the selection again, using the non-default geometry property "Data2".
+        // Now do the selection again, using the non-default geometry property "Data2".
 
-    select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
-    select->SetFeatureClassName(L"DaKlass");
-    gv = FdoGeometryValue::Create(polyfgf);
-    filter = FdoSpatialCondition::Create(L"Data2", FdoSpatialOperations_EnvelopeIntersects, gv);
-    printf("\n\n\nEnvelopeIntersects filter (with no R-tree) on non-default geometry property");
-    select->SetFilter(filter);
-    start = clock ();
-    rdr = select->Execute();
-    count2 = 0;
-    while (rdr->ReadNext())
-    {
-        const wchar_t* something = rdr->GetString(L"Name");
-        count2++;
-    }
-    rdr->Close();
-    finish = clock ();
-    printf("Count = %d  time: %2.3f seconds \n", count2, (double)(finish - start) / CLOCKS_PER_SEC);
-    //correct R-Tree will return that many features!
-    CPPUNIT_ASSERT(count2 == 4535);
+        select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        select->SetFeatureClassName(L"DaKlass");
+        gv = FdoGeometryValue::Create(polyfgf);
+        filter = FdoSpatialCondition::Create(L"Data2", FdoSpatialOperations_EnvelopeIntersects, gv);
+        printf("\n\n\nEnvelopeIntersects filter (with no R-tree) on non-default geometry property");
+        select->SetFilter(filter);
+        start = clock ();
+        rdr = select->Execute();
+        count2 = 0;
+        while (rdr->ReadNext())
+        {
+            const wchar_t* something = rdr->GetString(L"Name");
+            count2++;
+        }
+        rdr->Close();
+        finish = clock ();
+        printf("Count = %d  time: %2.3f seconds \n", count2, (double)(finish - start) / CLOCKS_PER_SEC);
+        //correct R-Tree will return that many features!
+        CPPUNIT_ASSERT(count2 == 4535);
 
 
-    conn->Close();
+        conn->Close();
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 void MasterTest::spatialFilter()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);    
-    
-    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+        openConnection(conn, DEST_PATH);    
+        
+        FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-    select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"DaKlass");
 
-   
-    FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+       
+        FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
 
-    double coords[] = { 7.2230, 43.6861, 
-                        7.2505, 43.6861, 
-                        7.2505, 43.7134, 
-                        7.2230, 43.7134, 
-                        7.2230, 43.6861 }; //last pt equals first for rings
+        double coords[] = { 7.2230, 43.6861, 
+                            7.2505, 43.6861, 
+                            7.2505, 43.7134, 
+                            7.2230, 43.7134, 
+                            7.2230, 43.6861 }; //last pt equals first for rings
 
-    FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
-    FdoPtr<FdoIPolygon> poly = gf->CreatePolygon(outer, NULL);
+        FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+        FdoPtr<FdoIPolygon> poly = gf->CreatePolygon(outer, NULL);
 
-    //FdoPtr<FdoILineString> poly = gf->CreateLineString(0, 10, coords);
+        //FdoPtr<FdoILineString> poly = gf->CreateLineString(0, 10, coords);
 
 
-    FdoPtr<FdoByteArray> polyfgf = gf->GetFgf(poly);
-    FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(polyfgf);
-    FdoPtr<FdoSpatialCondition> filter = FdoSpatialCondition::Create(L"Data", FdoSpatialOperations_Intersects, gv);
-    
+        FdoPtr<FdoByteArray> polyfgf = gf->GetFgf(poly);
+        FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(polyfgf);
+        FdoPtr<FdoSpatialCondition> filter = FdoSpatialCondition::Create(L"Data", FdoSpatialOperations_Intersects, gv);
+        
 
-    printf("\n\n\nSpatial filter");
+        printf("\n\n\nSpatial filter");
 
-    select->SetFilter(filter);
-   
-    
-    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+        select->SetFilter(filter);
+       
+        
+        FdoPtr<FdoIFeatureReader> rdr = select->Execute();
 
-    int count2 = 0;
+        int count2 = 0;
 
-    while (rdr->ReadNext())
-    {
-        //const wchar_t* something = rdr->GetString(L"Name");
-        //const wchar_t* something2 = rdr->GetString(L"Key");
-        //const wchar_t* something3 = rdr->GetString(L"Name");
+        while (rdr->ReadNext())
+        {
+            //const wchar_t* something = rdr->GetString(L"Name");
+            //const wchar_t* something2 = rdr->GetString(L"Key");
+            //const wchar_t* something3 = rdr->GetString(L"Name");
+            
+            //wprintf(L"%s\n", something);
+            count2++;
+        }
+
+        rdr->Close();
         
-        //wprintf(L"%s\n", something);
-        count2++;
+       
+        CPPUNIT_ASSERT(count2 == 4533);
+
+            
+        conn->Close();
     }
-
-    rdr->Close();
-    
-   
-    CPPUNIT_ASSERT(count2 == 4533);
-
-        
-    conn->Close();
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 void MasterTest::spatialInsideFilter()
@@ -625,169 +663,182 @@
 
 void MasterTest::coordSysTest()
 {
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+    try
+    {
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, DEST_PATH);
+        openConnection(conn, DEST_PATH);
 
-    printf("\n\n\nCoord sys tests");
-    
-    FdoPtr<FdoIGetSpatialContexts> gsc = (FdoIGetSpatialContexts*)conn->CreateCommand(FdoCommandType_GetSpatialContexts);
-    
-    FdoPtr<FdoISpatialContextReader> rdr = gsc->Execute();
+        printf("\n\n\nCoord sys tests");
+        
+        FdoPtr<FdoIGetSpatialContexts> gsc = (FdoIGetSpatialContexts*)conn->CreateCommand(FdoCommandType_GetSpatialContexts);
+        
+        FdoPtr<FdoISpatialContextReader> rdr = gsc->Execute();
 
-    bool hello = rdr->ReadNext();    
+        bool hello = rdr->ReadNext();    
 
-    CPPUNIT_ASSERT(hello);
+        CPPUNIT_ASSERT(hello);
 
-    FdoPtr<FdoByteArray> extent = rdr->GetExtent();
+        FdoPtr<FdoByteArray> extent = rdr->GetExtent();
 
-    if (extent != NULL)
-    {
-        FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
-        FdoPtr<FdoIGeometry> fgfgeom = gf->CreateGeometryFromFgf(extent);
+        if (extent != NULL)
+        {
+            FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+            FdoPtr<FdoIGeometry> fgfgeom = gf->CreateGeometryFromFgf(extent);
 
-        FdoIPolygon* poly = dynamic_cast<FdoIPolygon*> (fgfgeom.p);
+            FdoIPolygon* poly = dynamic_cast<FdoIPolygon*> (fgfgeom.p);
 
-        FdoPtr<FdoILinearRing> ring = poly->GetExteriorRing();
+            FdoPtr<FdoILinearRing> ring = poly->GetExteriorRing();
 
-        double x, y, z, m; 
-        int dim;
+            double x, y, z, m; 
+            int dim;
 
-        ring->GetItemByMembers(0, &x, &y, &z, &m, &dim);
-        printf("%lf,  %lf\n", x, y);
+            ring->GetItemByMembers(0, &x, &y, &z, &m, &dim);
+            printf("%lf,  %lf\n", x, y);
 
-        ring->GetItemByMembers(1, &x, &y, &z, &m, &dim);
-        printf("%lf,  %lf\n", x, y);
+            ring->GetItemByMembers(1, &x, &y, &z, &m, &dim);
+            printf("%lf,  %lf\n", x, y);
 
-        ring->GetItemByMembers(2, &x, &y, &z, &m, &dim);
-        printf("%lf,  %lf\n", x, y);
+            ring->GetItemByMembers(2, &x, &y, &z, &m, &dim);
+            printf("%lf,  %lf\n", x, y);
 
-        ring->GetItemByMembers(3, &x, &y, &z, &m, &dim);
-        printf("%lf,  %lf\n", x, y);
-    }
+            ring->GetItemByMembers(3, &x, &y, &z, &m, &dim);
+            printf("%lf,  %lf\n", x, y);
+        }
 
 
-    FdoString* desc = rdr->GetDescription();
-    FdoString* cs = rdr->GetCoordinateSystem();
+        FdoString* desc = rdr->GetDescription();
+        FdoString* cs = rdr->GetCoordinateSystem();
 
-    CPPUNIT_ASSERT(rdr->GetXYTolerance() == 17.0);
-    CPPUNIT_ASSERT(rdr->GetZTolerance() == 3.14159);
+        CPPUNIT_ASSERT(rdr->GetXYTolerance() == 17.0);
+        CPPUNIT_ASSERT(rdr->GetZTolerance() == 3.14159);
 
-    conn->Close();
+        conn->Close();
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 void MasterTest::selectDistinctTests()
 {
-    printf("Testing select distinct:\n");
+    try
+    {
+        printf("Testing select distinct:\n");
 
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, SHP_PATH, true);
+        openConnection(conn, SHP_PATH, true);
 
-    /*
-    FdoPtr<FdoISelectAggregates> advsel = dynamic_cast<FdoISelectAggregates*>(conn->CreateCommand(FdoCommandType_SelectAggregates));
+        /*
+        FdoPtr<FdoISelectAggregates> advsel = dynamic_cast<FdoISelectAggregates*>(conn->CreateCommand(FdoCommandType_SelectAggregates));
 
-    advsel->SetFeatureClassName(L"SHPClass");
-    
-    FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
+        advsel->SetFeatureClassName(L"SHPClass");
+        
+        FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
 
-    FdoPtr<FdoComputedIdentifier> cid = FdoComputedIdentifier::Create(L"NumRecords");
-    FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"Count(MAPKEY)");
-    cid->SetExpression(expr);
-    ids->Add(cid);
-    */
-    
-    //select distinct
-    FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
+        FdoPtr<FdoComputedIdentifier> cid = FdoComputedIdentifier::Create(L"NumRecords");
+        FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"Count(MAPKEY)");
+        cid->SetExpression(expr);
+        ids->Add(cid);
+        */
+        
+        //select distinct
+        FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
 
-    advsel->SetFeatureClassName(L"World_Countries");
-    
-    FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
+        advsel->SetFeatureClassName(L"World_Countries");
+        
+        FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
 
-    FdoPtr<FdoIdentifier> id = FdoIdentifier::Create(L"KEY");
-    ids->Add(id);
+        FdoPtr<FdoIdentifier> id = FdoIdentifier::Create(L"KEY");
+        ids->Add(id);
 
-    id = FdoIdentifier::Create(L"NAME");
-    ids->Add(id);
+        id = FdoIdentifier::Create(L"NAME");
+        ids->Add(id);
 
-    advsel->SetDistinct(true);
+        advsel->SetDistinct(true);
 
-    FdoPtr<FdoIDataReader> rdr = advsel->Execute();
+        FdoPtr<FdoIDataReader> rdr = advsel->Execute();
 
-    int count = 0;
+        int count = 0;
 
-    char tmp[1024];
+        char tmp[1024];
 
-    while (rdr->ReadNext())
-    {
-        FdoString* mk = rdr->GetString(L"KEY");
-        wcstombs(tmp, mk, 1024);
-        printf("%s\n", tmp);
-        count++;
-    }
+        while (rdr->ReadNext())
+        {
+            FdoString* mk = rdr->GetString(L"KEY");
+            wcstombs(tmp, mk, 1024);
+            printf("%s\n", tmp);
+            count++;
+        }
 
-    rdr->Close();
+        rdr->Close();
 
-    printf("Distinct values returned: %d", count);
-    //-------------
-    
-    conn->Close();    
-
+        printf("Distinct values returned: %d", count);
+        //-------------
+        
+        conn->Close();    
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 
 
 void MasterTest::selectAggregatesTest()
 {
-    printf("Testing select aggregates:\n");
+    try
+    {
+        printf("Testing select aggregates:\n");
 
-    FdoPtr<FdoIConnection> conn = CreateConnection();
+        FdoPtr<FdoIConnection> conn = CreateConnection();
 
-    openConnection(conn, SHP_PATH2, true);
+        openConnection(conn, SHP_PATH2, true);
 
-    FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
+        FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
 
-    advsel->SetFeatureClassName(L"province");
-    
-    FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
+        advsel->SetFeatureClassName(L"province");
+        
+        FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
 
-    FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"Count(AREA)");
-    FdoPtr<FdoComputedIdentifier> cid = FdoComputedIdentifier::Create(L"NumRecords", expr);
-    ids->Add(cid);
+        FdoPtr<FdoExpression> expr = FdoExpression::Parse(L"Count(AREA)");
+        FdoPtr<FdoComputedIdentifier> cid = FdoComputedIdentifier::Create(L"NumRecords", expr);
+        ids->Add(cid);
 
-    expr = FdoExpression::Parse(L"Min(AREA)");
-    cid = FdoComputedIdentifier::Create(L"MinArea", expr);
-    ids->Add(cid);
-   
-    expr = FdoExpression::Parse(L"Max(AREA)");
-    cid = FdoComputedIdentifier::Create(L"MaxArea", expr);
-    ids->Add(cid);
+        expr = FdoExpression::Parse(L"Min(AREA)");
+        cid = FdoComputedIdentifier::Create(L"MinArea", expr);
+        ids->Add(cid);
+       
+        expr = FdoExpression::Parse(L"Max(AREA)");
+        cid = FdoComputedIdentifier::Create(L"MaxArea", expr);
+        ids->Add(cid);
 
-    expr = FdoExpression::Parse(L"Avg(AREA)");
-    cid = FdoComputedIdentifier::Create(L"AverageArea", expr);
-    ids->Add(cid);
+        expr = FdoExpression::Parse(L"Avg(AREA)");
+        cid = FdoComputedIdentifier::Create(L"AverageArea", expr);
+        ids->Add(cid);
 
+        FdoPtr<FdoIDataReader> rdr = advsel->Execute();
 
-    FdoPtr<FdoIDataReader> rdr = advsel->Execute();
+        int count = 0;
 
-    int count = 0;
+        while (rdr->ReadNext())
+        {
+            printf("Number of provinces: %d\n", rdr->GetInt64(L"NumRecords"));
+            printf("Min area: %lf\n", rdr->GetDouble(L"MinArea"));
+            printf("Max area: %lf\n", rdr->GetDouble(L"MaxArea"));
+            printf("Ave area: %lf\n", rdr->GetDouble(L"AverageArea"));
+            
+            count++;
+        }
 
-    while (rdr->ReadNext())
-    {
-        printf("Number of provinces: %d\n", rdr->GetInt64(L"NumRecords"));
-        printf("Min area: %lf\n", rdr->GetDouble(L"MinArea"));
-        printf("Max area: %lf\n", rdr->GetDouble(L"MaxArea"));
-        printf("Ave area: %lf\n", rdr->GetDouble(L"AverageArea"));
-        
-        count++;
+        rdr->Close();
+        conn->Close();    
     }
-
-    rdr->Close();
-
-    
-    conn->Close();    
-
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
 
 void MasterTest::selectSpatialExtentsTest()
@@ -993,43 +1044,229 @@
 
 void MasterTest::descReadOnly()
 {
-    printf("Testing describeschema with read-only connection:\n");
+    try
+    {
+        printf("Testing describeschema with read-only connection:\n");
 
-    // open connection as read-only:
-    FdoPtr<FdoIConnection> conn = CreateConnection();
-    openConnection(conn, SHP_PATH, true);
+        // open connection as read-only:
+        FdoPtr<FdoIConnection> conn = CreateConnection();
+        openConnection(conn, SHP_PATH, true);
 
-    // Verify that classes are read-only too:
-    FdoPtr<FdoIDescribeSchema> descSchema = static_cast<FdoIDescribeSchema*>(conn->CreateCommand(FdoCommandType_DescribeSchema));
-    FdoPtr<FdoFeatureSchemaCollection> schemas = descSchema->Execute();
-    for (int s=0; s<schemas->GetCount(); s++)
-    {
-        FdoPtr<FdoFeatureSchema> schema = schemas->GetItem(s);
-        FdoPtr<FdoClassCollection> classes = schema->GetClasses();
-        for (int c=0; c<classes->GetCount(); c++)
+        // Verify that classes are read-only too:
+        FdoPtr<FdoIDescribeSchema> descSchema = static_cast<FdoIDescribeSchema*>(conn->CreateCommand(FdoCommandType_DescribeSchema));
+        FdoPtr<FdoFeatureSchemaCollection> schemas = descSchema->Execute();
+        for (int s=0; s<schemas->GetCount(); s++)
         {
-            FdoPtr<FdoClassDefinition> classDef = classes->GetItem(c);
-            FdoPtr<FdoClassCapabilities> classCapabilities = classDef->GetCapabilities();
-            CPPUNIT_ASSERT_MESSAGE("class should be read-only", !classCapabilities->SupportsWrite());
+            FdoPtr<FdoFeatureSchema> schema = schemas->GetItem(s);
+            FdoPtr<FdoClassCollection> classes = schema->GetClasses();
+            for (int c=0; c<classes->GetCount(); c++)
+            {
+                FdoPtr<FdoClassDefinition> classDef = classes->GetItem(c);
+                FdoPtr<FdoClassCapabilities> classCapabilities = classDef->GetCapabilities();
+                CPPUNIT_ASSERT_MESSAGE("class should be read-only", !classCapabilities->SupportsWrite());
+            }
         }
+
+        // open connection as read-write:
+        conn = CreateConnection();
+        openConnection(conn, SHP_PATH, false);
+
+        // Verify that classes are read-write too:
+        descSchema = static_cast<FdoIDescribeSchema*>(conn->CreateCommand(FdoCommandType_DescribeSchema));
+        schemas = descSchema->Execute();
+        for (int s=0; s<schemas->GetCount(); s++)
+        {
+            FdoPtr<FdoFeatureSchema> schema = schemas->GetItem(s);
+            FdoPtr<FdoClassCollection> classes = schema->GetClasses();
+            for (int c=0; c<classes->GetCount(); c++)
+            {
+                FdoPtr<FdoClassDefinition> classDef = classes->GetItem(c);
+                FdoPtr<FdoClassCapabilities> classCapabilities = classDef->GetCapabilities();
+                CPPUNIT_ASSERT_MESSAGE("class should be read-write", classCapabilities->SupportsWrite());
+            }
+        }
     }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
+}
 
-    // open connection as read-write:
-    conn = CreateConnection();
-    openConnection(conn, SHP_PATH, false);
 
-    // Verify that classes are read-write too:
-    descSchema = static_cast<FdoIDescribeSchema*>(conn->CreateCommand(FdoCommandType_DescribeSchema));
-    schemas = descSchema->Execute();
-    for (int s=0; s<schemas->GetCount(); s++)
+void MasterTest::selectAggregatesFailureTests()
+{
+    try
     {
-        FdoPtr<FdoFeatureSchema> schema = schemas->GetItem(s);
-        FdoPtr<FdoClassCollection> classes = schema->GetClasses();
-        for (int c=0; c<classes->GetCount(); c++)
+        printf("Testing select aggregates:\n");
+
+        FdoPtr<FdoIConnection> conn = CreateConnection();
+
+        openConnection(conn, SHP_PATH2, true);
+
+        FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
+
+        advsel->SetFeatureClassName(L"province");
+        
+        FdoPtr<FdoIdentifierCollection> ids = advsel->GetPropertyNames();
+        FdoPtr<FdoExpression> expr;
+        FdoPtr<FdoComputedIdentifier> cid;
+
+        expr = FdoExpression::Parse(L"Avg(CODE)");
+        cid = FdoComputedIdentifier::Create(L"AvgCode", expr);
+        ids->Add(cid);
+
+        try
         {
-            FdoPtr<FdoClassDefinition> classDef = classes->GetItem(c);
-            FdoPtr<FdoClassCapabilities> classCapabilities = classDef->GetCapabilities();
-            CPPUNIT_ASSERT_MESSAGE("class should be read-write", classCapabilities->SupportsWrite());
+            FdoPtr<FdoIDataReader> rdr = advsel->Execute();
+            CPPUNIT_FAIL("Expected exception when doing AVG() of a String property, but didn't get one");
         }
+        catch (FdoException *e)
+        {
+            // We expect to fall into here, so absorb the exception quietly
+            e->Release();
+        }
     }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
 }
+
+
+
+void MasterTest::test_aggregates_datetime_string(void)
+{
+    try
+    {
+        FdoPtr<FdoIConnection> connection = CreateConnection();
+
+        ////////////////////////////////////////////////////////////////////////////////////////////
+        // Create a new SDF File:
+        ////////////////////////////////////////////////////////////////////////////////////////////
+
+        FdoCommonFile::Delete(AGGR_PATH, true);
+	    FdoPtr<FdoICreateSDFFile> crsdf = (FdoICreateSDFFile*)(connection->CreateCommand(SdfCommandType_CreateSDFFile));
+	    crsdf->SetCoordinateSystemWKT(L"[LL84]");
+	    crsdf->SetFileName(AGGR_PATH);
+	    crsdf->SetSpatialContextDescription(L"World Coordinate System, Degrees, what else do you need to know?");
+	    crsdf->SetSpatialContextName(L"World Geodetic Coordinate System, 1984");
+	    crsdf->SetXYTolerance(17.0);
+	    crsdf->SetZTolerance(3.14159);
+	    crsdf->Execute();
+
+        // Connect to new file:
+        wchar_t connString[500];
+        swprintf(connString, 500, L"File=%ls", AGGR_PATH);
+        connection->SetConnectionString(connString);
+        connection->Open();
+
+
+        ////////////////////////////////////////////////////////////////////////////////////////////
+        // Create a new schema and class in the new SDF file:
+        ////////////////////////////////////////////////////////////////////////////////////////////
+
+        // Create new schema:
+        FdoPtr<FdoFeatureSchema> pSchema = FdoFeatureSchema::Create(L"MySchema", L"");
+
+	    // Create a new Feature Class:
+	    FdoPtr<FdoFeatureClass> pClass = FdoFeatureClass::Create( L"MyClass", L"" );
+	    pClass->SetIsAbstract(false);
+
+	    // Add featid property
+
+	    FdoPtr<FdoDataPropertyDefinition> pProp = FdoDataPropertyDefinition::Create( L"FeatId", L"id" );
+	    pProp->SetDataType( FdoDataType_Int32 );
+	    pProp->SetNullable(false);
+        pProp->SetIsAutoGenerated(true);
+	    FdoPropertiesP(pClass->GetProperties())->Add( pProp );
+	    FdoDataPropertiesP(pClass->GetIdentityProperties())->Add( pProp );
+
+	    // Add geometry property
+
+	    FdoPtr<FdoGeometricPropertyDefinition> pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry", L"location and shape" );
+	    pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve );
+	    pGeomProp->SetHasElevation(true);
+        FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp );
+	    pClass->SetGeometryProperty( pGeomProp );
+
+	    // Add data properties of various types
+
+	    pProp = FdoDataPropertyDefinition::Create( L"MyString", L"A, B or C" );
+	    pProp->SetDataType( FdoDataType_String );
+	    pProp->SetLength(200);
+	    pProp->SetNullable(false);
+	    FdoPropertiesP(pClass->GetProperties())->Add( pProp );
+
+	    pProp = FdoDataPropertyDefinition::Create( L"MyDate", L"" );
+	    pProp->SetDataType( FdoDataType_DateTime );
+	    pProp->SetNullable(true);
+	    FdoPropertiesP(pClass->GetProperties())->Add( pProp );
+
+	    FdoClassesP(pSchema->GetClasses())->Add( pClass );
+
+        // Now do ApplySchema:
+	    FdoPtr<FdoIApplySchema>  pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema);
+	    pCmd->SetFeatureSchema( pSchema );
+	    pCmd->Execute();
+
+
+        ////////////////////////////////////////////////////////////////////////////////////////////
+        // Insert some test data:
+        ////////////////////////////////////////////////////////////////////////////////////////////
+
+        FdoPtr<FdoIInsert> ins = (FdoIInsert*)connection->CreateCommand(FdoCommandType_Insert);
+        ins->SetFeatureClassName(L"MyClass");
+
+        FdoPtr<FdoPropertyValueCollection> propVals = ins->GetPropertyValues();
+        FdoPtr<FdoPropertyValue> propVal;
+        FdoPtr<FdoIFeatureReader> reader;
+
+        propVals->Clear();
+        propVal = FdoPropertyValue::Create(L"MyString", FdoPtr<FdoValueExpression>((FdoValueExpression*)FdoValueExpression::Parse(L"'Potato'")));
+        propVals->Add(propVal);
+        propVal = FdoPropertyValue::Create(L"MyDate", FdoPtr<FdoValueExpression>((FdoValueExpression*)FdoValueExpression::Parse(L"DATE'1957-3-2'")));
+        propVals->Add(propVal);
+        reader = ins->Execute();
+
+        propVals->Clear();
+        propVal = FdoPropertyValue::Create(L"MyString", FdoPtr<FdoValueExpression>((FdoValueExpression*)FdoValueExpression::Parse(L"'Tomato'")));
+        propVals->Add(propVal);
+        propVal = FdoPropertyValue::Create(L"MyDate", FdoPtr<FdoValueExpression>((FdoValueExpression*)FdoValueExpression::Parse(L"DATE'1967-5-30'")));
+        propVals->Add(propVal);
+        reader = ins->Execute();
+
+
+        ////////////////////////////////////////////////////////////////////////////////////////////
+        // Select aggregates on datetime values:
+        ////////////////////////////////////////////////////////////////////////////////////////////
+
+        FdoPtr<FdoISelectAggregates> selAggr = (FdoISelectAggregates*)connection->CreateCommand(FdoCommandType_SelectAggregates);
+        selAggr->SetFeatureClassName(L"MySchema:MyClass");
+        FdoPtr<FdoIdentifierCollection> ids = selAggr->GetPropertyNames();
+        ids->Add(FdoPtr<FdoComputedIdentifier>(FdoComputedIdentifier::Create(L"MinDate", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Min(MyDate)")))));
+        ids->Add(FdoPtr<FdoComputedIdentifier>(FdoComputedIdentifier::Create(L"MaxDate", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Max(MyDate)")))));
+        ids->Add(FdoPtr<FdoComputedIdentifier>(FdoComputedIdentifier::Create(L"MinString", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Min(MyString)")))));
+        ids->Add(FdoPtr<FdoComputedIdentifier>(FdoComputedIdentifier::Create(L"MaxString", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Max(MyString)")))));
+        FdoPtr<FdoIDataReader> dr = selAggr->Execute();
+        CPPUNIT_ASSERT_MESSAGE("Should have one row of data", dr->ReadNext());
+
+        FdoDateTime mindt = dr->GetDateTime(L"MinDate");
+        CPPUNIT_ASSERT_MESSAGE("wrong min date year", mindt.year==1957);
+        CPPUNIT_ASSERT_MESSAGE("wrong min date month", mindt.month==3);
+        CPPUNIT_ASSERT_MESSAGE("wrong min date day", mindt.day==2);
+
+        FdoDateTime maxdt = dr->GetDateTime(L"MaxDate");
+        CPPUNIT_ASSERT_MESSAGE("wrong max date year", maxdt.year==1967);
+        CPPUNIT_ASSERT_MESSAGE("wrong max date month", maxdt.month==5);
+        CPPUNIT_ASSERT_MESSAGE("wrong max date day", maxdt.day==30);
+
+        FdoString* minString = dr->GetString(L"MinString");
+        CPPUNIT_ASSERT_MESSAGE("wrong min string", 0==wcscmp(minString, L"Potato"));
+
+        FdoString* maxString = dr->GetString(L"MaxString");
+        CPPUNIT_ASSERT_MESSAGE("wrong max string", 0==wcscmp(maxString, L"Tomato"));
+
+        CPPUNIT_ASSERT_MESSAGE("Should only have one row of data", !dr->ReadNext());
+    }
+    catch ( FdoException* ex ) {
+        TestCommonFail( ex );
+    }
+}

Modified: trunk/Providers/SDF/Src/UnitTest/MasterTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -91,9 +91,11 @@
     CPPUNIT_TEST(coordSysTest);
     CPPUNIT_TEST(selectDistinctTests);
     CPPUNIT_TEST(selectAggregatesTest);
+    CPPUNIT_TEST(selectAggregatesFailureTests);
 	CPPUNIT_TEST(selectSpatialExtentsTest);
 	CPPUNIT_TEST(concurencyTest);
     CPPUNIT_TEST(descReadOnly);
+    CPPUNIT_TEST(test_aggregates_datetime_string);
     CPPUNIT_TEST_SUITE_END();
 
     // You may define any private variables that are used in your test
@@ -124,10 +126,11 @@
     void computedPropTest();
     void selectDistinctTests();
     void selectAggregatesTest();
+    void selectAggregatesFailureTests();
 	void concurencyTest();
     void selectSpatialExtentsTest();
     void descReadOnly();
-
+    void test_aggregates_datetime_string();
 };
 
 #endif

Modified: trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -180,7 +180,7 @@
 	catch ( FdoException* e ) 
 	{
         connection->Close();
-        printf( "Exception: %ls\n", e->GetExceptionMessage() );
+        TestCommonFail(e);
 	}
 
 	connection->Close();
@@ -338,3 +338,28 @@
 
     return connection;
 }
+
+
+
+void SelectTest::select_aggregates_should_fail()
+{
+    try
+    {
+        FdoPtr<FdoIConnection> mConnection = CreateDb();
+
+        FdoPtr<FdoISelect> select = (FdoISelect*)mConnection->CreateCommand (FdoCommandType_Select);
+        select->SetFeatureClassName (L"Class3");
+        FdoPtr <FdoIdentifierCollection> ids = select->GetPropertyNames ();
+        FdoPtr <FdoIdentifier> id = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Avg(Prop1)")));
+        ids->Add(id);
+        FdoPtr<FdoIFeatureReader> reader = select->Execute ();
+        while (reader->ReadNext ())
+        {
+            double avg_computed_id = reader->GetDouble (L"AVG_ID");
+        }
+    }
+    catch (FdoException* e)
+    {
+        TestCommonFail(e);
+    }
+}

Modified: trunk/Providers/SDF/Src/UnitTest/SelectTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SelectTest.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/SelectTest.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -10,6 +10,7 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include <Fdo.h>
+#include <TestCommonMiscUtil.h>
 
 /* 
  * A test case for the schema.
@@ -26,6 +27,7 @@
   CPPUNIT_TEST( TestBaseProps );
   CPPUNIT_TEST( TestBothProps );
   CPPUNIT_TEST( TestAllProps );
+  CPPUNIT_TEST( select_aggregates_should_fail );
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -38,6 +40,7 @@
     void TestBaseProps();
     void TestBothProps();
     void TestAllProps();
+    void select_aggregates_should_fail();
 
     FdoIConnection* CreateDb();
     void DoTest ( 

Modified: trunk/Providers/SDF/Src/UnitTest/SpatialContextTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SpatialContextTest.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/SpatialContextTest.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -82,7 +82,7 @@
     }
     catch ( FdoException* e )
 	{
-		UnitTestUtil::FailOnException( e );
+		TestCommonFail( e );
 	}
 	catch ( CppUnit::Exception e ) 
 	{

Modified: trunk/Providers/SDF/Src/UnitTest/UnitTest.vcproj
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/UnitTest.vcproj	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/UnitTest.vcproj	2007-02-22 14:26:12 UTC (rev 2582)
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\include\&quot;;&quot;$(FDO)\Unmanaged\Inc&quot;;..\..\Inc;&quot;$(FDOUTILITIES)\TestCommon\inc&quot;"
+				AdditionalIncludeDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\include\&quot;;&quot;$(FDO)\Unmanaged\Inc&quot;;..\..\Inc;&quot;$(FDOUTILITIES)\TestCommon\inc&quot;;&quot;$(FDOUTILITIES)\Common\inc&quot;"
 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;IGNORE_THREAD_TEST;__CPPUNIT_MFC_APP"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -65,10 +65,10 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="cppunitd.lib FDO.lib FDOCommon.lib FDOGeometry.lib FDOSpatial.lib"
+				AdditionalDependencies="cppunitd.lib FDO.lib FDOCommon.lib FDOGeometry.lib FDOSpatial.lib ProvidersCommon.lib"
 				OutputFile="$(OutDir)/UnitTest.exe"
 				LinkIncremental="2"
-				AdditionalLibraryDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\lib\&quot;;&quot;$(FDO)\Unmanaged\Lib\Win32\Debug&quot;;&quot;$(FDOUTILITIES)\TestCommon\Lib\Win32\Debug&quot;"
+				AdditionalLibraryDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\lib\&quot;;&quot;$(FDO)\Unmanaged\Lib\Win32\Debug&quot;;&quot;$(FDOUTILITIES)\TestCommon\Lib\Win32\Debug&quot;;&quot;$(FDOUTILITIES)\Common\Lib\Win32\Debug&quot;"
 				IgnoreDefaultLibraryNames="libcmtd.lib"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/UnitTest.pdb"
@@ -126,7 +126,7 @@
 			/>
 			<Tool
 				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\include\&quot;;&quot;$(FDO)\Unmanaged\Inc&quot;;..\..\Inc;&quot;$(FDOUTILITIES)\TestCommon\inc&quot;"
+				AdditionalIncludeDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\include\&quot;;&quot;$(FDO)\Unmanaged\Inc&quot;;..\..\Inc;&quot;$(FDOUTILITIES)\TestCommon\inc&quot;;&quot;$(FDOUTILITIES)\Common\inc&quot;"
 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;IGNORE_THREAD_TEST"
 				RuntimeLibrary="2"
 				TreatWChar_tAsBuiltInType="true"
@@ -147,10 +147,10 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="cppunit.lib FDO.lib FDOCommon.lib FDOGeometry.lib"
+				AdditionalDependencies="cppunit.lib FDO.lib FDOCommon.lib FDOGeometry.lib ProvidersCommon.lib"
 				OutputFile="$(OutDir)/UnitTest.exe"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\lib\&quot;;&quot;$(FDO)\Unmanaged\Lib\Win32\Release&quot;;&quot;$(FDOUTILITIES)\TestCommon\Lib\Win32\Release&quot;"
+				AdditionalLibraryDirectories="&quot;$(FDOTHIRDPARTY)\CppUnit\lib\&quot;;&quot;$(FDO)\Unmanaged\Lib\Win32\Release&quot;;&quot;$(FDOUTILITIES)\TestCommon\Lib\Win32\Release&quot;;&quot;$(FDOUTILITIES)\Common\Lib\Win32\Release&quot;"
 				IgnoreDefaultLibraryNames=""
 				GenerateDebugInformation="true"
 				SubSystem="1"
@@ -540,6 +540,14 @@
 			>
 		</File>
 		<File
+			RelativePath=".\SchemaTest.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\SchemaTest.h"
+			>
+		</File>
+		<File
 			RelativePath=".\SpatialContextTest.cpp"
 			>
 		</File>

Modified: trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp	2007-02-22 14:26:12 UTC (rev 2582)
@@ -1,4 +1,5 @@
 #include "UnitTestUtil.h"
+#include "FdoCommonFile.h"
 #include "SDF/SdfCommandType.h"
 #include "SDF/ICreateSDFFile.h"
 #ifndef _WIN32
@@ -39,20 +40,8 @@
     FdoIConnection *conn = manager->CreateConnection (L"OSGeo.SDF.3.3");
 	if( re_create )
 	{
-		size_t len = wcstombs(NULL, fileName, 0);
-		char* mbsPath = new char[len+1];
-		wcstombs(mbsPath, fileName, len+1);
+        FdoCommonFile::Delete(fileName, true);
 
-#ifdef _WIN32    
-		SetFileAttributes(mbsPath, FILE_ATTRIBUTE_NORMAL);
-		DeleteFile(mbsPath);
-#else
-		unlink(mbsPath);
-#endif
-
-		delete[] mbsPath;
-
-
 		FdoPtr<FdoICreateSDFFile> crsdf = (FdoICreateSDFFile*)(conn->CreateCommand(SdfCommandType_CreateSDFFile));
 
 		crsdf->SetCoordinateSystemWKT(L"[LL84]");
@@ -81,8 +70,6 @@
     FdoXmlSpatialContextFlags* flags
 )
 {
-//    FdoInt32 i;
-
     stream->Reset();
     FdoXmlWriterP writer = FdoXmlWriter::Create(stream, true, FdoXmlWriter::LineFormat_Indent);
 /*
@@ -110,37 +97,9 @@
     reader->Parse( copier );
 }
 
-void UnitTestUtil::FailOnException( FdoException* e )
-{
-    char buffer[5000];
 
-    PrintException( e );
-    Exception2String( e, buffer );
-    e->Release ();
-
-
-    CPPUNIT_FAIL( buffer );
-}
-
-
-void UnitTestUtil::Exception2String( FdoException* e, char* buffer )
-{
-    FdoPtr<FdoException> innerE = e;
-    // Add ref to prevent smart pointer from destroying exception.
-    FDO_SAFE_ADDREF(e);
-
-    while ( innerE->GetCause() )
-        innerE = innerE->GetCause();
-
-    if ( innerE == e )
-        sprintf( buffer, "%ls", e->GetExceptionMessage() );
-    else
-        sprintf( buffer, "%ls ... %ls", innerE->GetExceptionMessage(), e->GetExceptionMessage() );
-}
-
 void UnitTestUtil::PrintException( FdoException* e, FILE* fp, FdoBoolean stripLineNo )
 {
-
     FdoPtr<FdoException> currE = e;
     // Add ref to prevent smart pointer from destroying exception.
     FDO_SAFE_ADDREF(e);
@@ -247,57 +206,3 @@
 
     fclose( fp );
 }
-
-void UnitTestUtil::CheckOutput( const char* masterFileName, const char* outFileName )
-{
-    if ( CompareFiles( masterFileName, outFileName ) != 0 ) {
-        char buffer[5000];
-        sprintf( buffer, "Output file %s differs from expected output file %s", outFileName, masterFileName );
-        CPPUNIT_FAIL( buffer );
-    }
-}
-
-int UnitTestUtil::CompareFiles( const char* file1Name, const char* file2Name )
-{
-    char buffer[500];
-    char buffer1[5000];
-    char buffer2[5000];
-
-    int retcode = -1;
-
-    FILE* fp1 = fopen( file1Name, "r" );
-    FILE* fp2 = fopen( file2Name, "r" );
-
-    if ( fp1 == NULL ) {
-        sprintf( buffer, "UnitTestUtil::CompareFiles: failed to open file %s", file1Name );
-        CPPUNIT_FAIL( buffer );
-    }
-
-    if ( fp2 == NULL ) {
-        sprintf( buffer, "UnitTestUtil::CompareFiles: failed to open file %s", file2Name );
-        CPPUNIT_FAIL( buffer );
-    }
-
-    while ( fgets( buffer1, 4999, fp1 ) != NULL ) {
-        if ( !fgets( buffer2, 4999, fp2  ) )
-            // different: file2 has fewer lines.
-            goto the_exit;
-
-        if ( strcmp( buffer1, buffer2 ) )
-            // different: a line is different
-            goto the_exit;
-    }
-
-    if ( fgets( buffer2, 4999, fp2 ) )
-        // different: file2 has more lines.
-        goto the_exit;
-
-    retcode = 0;
-
-the_exit:
-    fclose(fp1);
-    fclose(fp2);
-
-    return( retcode );
-}
-

Modified: trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h	2007-02-22 14:25:27 UTC (rev 2581)
+++ trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h	2007-02-22 14:26:12 UTC (rev 2582)
@@ -24,8 +24,8 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <Fdo.h>
 #include <TestCommonMiscUtil.h>
+#include <TestCommonFileUtil.h>
 
-
 /* 
  * A test case for ApplySchemaCommand.
  *
@@ -44,31 +44,12 @@
         FdoXmlSpatialContextFlags* flags = NULL
     );
 
-//    void DeleteSchema( FdoIConnection* connection, GisString* schemaName );
-    
-    // Fail the current Unit Test, showing the given exception's message.
-    static void FailOnException( FdoException* e );
-
-    static void Exception2String( FdoException* e, char* buffer );
-
     // Print an exception, and all it's cause exceptions to a file
     // or stdout by default.
     static void PrintException( FdoException* e, FILE* fp = stdout, FdoBoolean stripLineNo = false );
 
     // Print an exception, and all it's cause exceptions to the given file.
     static void PrintException( FdoException* e, const char* fileName, FdoBoolean stripLineNo = false );
-
-    // Compare an output file against its master (expected) copy.
-    // Fail if they are different.
-    static void CheckOutput( const char* masterFileName, const char* outFileName );
-
-    // Compare to files.
-    //
-    // Returns:
-    //      0 - they are the same
-    //      -1 - they are different.
-    static int CompareFiles( const char* file1Name, const char* file2Name );
-
 };
 
 #endif



More information about the fdo-commits mailing list