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

svn_fdo at osgeo.org svn_fdo at osgeo.org
Mon Mar 26 16:46:30 EDT 2007


Author: badreddinekaroui
Date: 2007-03-26 16:46:30 -0400 (Mon, 26 Mar 2007)
New Revision: 2716

Added:
   trunk/Providers/SDF/TestData/HYDRANTSMULTIGEOM.sdf
Modified:
   trunk/Providers/SDF/Src/Provider/SDF.vcproj
   trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.cpp
   trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h
   trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
   trunk/Providers/SDF/Src/UnitTest/MasterTest.h
   trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp
   trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp
   trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h
Log:
See trac#53: upgrade the Sqlite library to the latest version 3.3.13 and add more unit tests


Modified: trunk/Providers/SDF/Src/Provider/SDF.vcproj
===================================================================
--- trunk/Providers/SDF/Src/Provider/SDF.vcproj	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/Provider/SDF.vcproj	2007-03-26 20:46:30 UTC (rev 2716)
@@ -70,7 +70,7 @@
 				AdditionalDependencies="FDOUtils.lib FDO.lib FDOCommon.lib FDOGeometry.lib FDONLS.lib ProvidersCommon.lib FDOSpatial.lib SQLiteInterface.lib Sqlite3.lib Advapi32.lib"
 				OutputFile="$(OutDir)/SDFProvider.dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="$(FDO)\Unmanaged\Lib\Win32\Debug\;$(FDOUTILITIES)\Common\Lib\Win32\Debug;..\..\Lib\Win32\Debug;$(FDOTHIRDPARTY)\Sqlite3.1.5\Debug;$(FDOUTILITIES)\SQLiteInterface\Lib\Win32\Debug"
+				AdditionalLibraryDirectories=""$(FDO)\Unmanaged\Lib\Win32\Debug\";"$(FDOUTILITIES)\Common\Lib\Win32\Debug";..\..\Lib\Win32\Debug;"$(FDOTHIRDPARTY)\Sqlite3.3.13\Debug";"$(FDOUTILITIES)\SQLiteInterface\Lib\Win32\Debug""
 				IgnoreDefaultLibraryNames="libcmtd.lib"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/SDFProvider.pdb"
@@ -164,7 +164,7 @@
 				AdditionalDependencies="FDOUtils.lib FDO.lib FDOCommon.lib FDOGeometry.lib FDONLS.lib ProvidersCommon.lib FDOSpatial.lib SQLiteInterface.lib Sqlite3.lib Advapi32.lib"
 				OutputFile="$(OutDir)/SDFProvider.dll"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="$(FDO)\Unmanaged\Lib\Win32\Release\;"$(FDOTHIRDPARTY)\db-4.3.27.NC\build_win32\Release_static";$(FDOUTILITIES)\Common\Lib\Win32\Release;..\..\Lib\Win32\Release;$(FDOTHIRDPARTY)\Sqlite3.1.5\Release;$(FDOUTILITIES)\SQLiteInterface\Lib\Win32\Release"
+				AdditionalLibraryDirectories=""$(FDO)\Unmanaged\Lib\Win32\Release\";"$(FDOTHIRDPARTY)\db-4.3.27.NC\build_win32\Release_static";"$(FDOUTILITIES)\Common\Lib\Win32\Release";..\..\Lib\Win32\Release;"$(FDOTHIRDPARTY)\Sqlite3.3.13\Release";"$(FDOUTILITIES)\SQLiteInterface\Lib\Win32\Release""
 				IgnoreDefaultLibraryNames="libcmt.lib"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/SDFProvider.pdb"

Modified: trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.cpp	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.cpp	2007-03-26 20:46:30 UTC (rev 2716)
@@ -1,5 +1,7 @@
 
 #include "FdoMultiThreadTest.h"
+#include "UnitTestUtil.h"
+#include "FdoCommonOSUtil.h"
 #include <stdio.h>
 
 #ifndef _WIN32
@@ -10,11 +12,21 @@
 
 #define   NUMBER_OF_THREADS     10
 static    bool   use_threads = true;
+static    bool   supports_multiple_writers = false;
+static    int    select_loop_count = 10;
+static    int    insert_loop_count = 20;
 
-#ifndef  IGNORE_THREAD_TEST
 CPPUNIT_TEST_SUITE_REGISTRATION( FdoMultiThreadTest );
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FdoMultiThreadTest, "FdoMultiThreadTest");
+
+void wait_a_bit(int ms)
+{
+#ifdef _WIN32
+        Sleep(ms);
+#else
+        sleep((ms+999)/1000);
 #endif
+}
 
 #ifdef _WIN32
 DWORD WINAPI StartQuery(LPVOID lpParameter)
@@ -23,45 +35,61 @@
 #endif
 {
     ConnectInfo  *cnInfo = (ConnectInfo*)lpParameter;
-	char tmp[1024];
+	char buffer[1024];
+	int  *counts = (int*)alloca( select_loop_count*sizeof(int) );
     try
 	{
+		wait_a_bit(200); // Give the insert thread a head start
+		printf("Start query Thread(%d)\n",cnInfo->connectionId );
 
 		FdoPtr<FdoISelect> select = (FdoISelect*)cnInfo->mConn->CreateCommand(FdoCommandType_Select); 
 
-		select->SetFeatureClassName(L"DaKlass");
+		select->SetFeatureClassName(L"Parcel");
 
-		FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%' or Key = 'LN0316' or Key = 'DI0022'");
+		//FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"Key LIKE 'DI%'");
 
+		FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+		double coords[] = { 7.2068, 43.7556, 
+							7.2088, 43.7556, 
+							7.2088, 43.7574, 
+							7.2068, 43.7574, 
+							7.2068, 43.7556 }; 
+		FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+		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);
 
 		select->SetFilter(filter);
-	    
-		FdoPtr<FdoIFeatureReader> rdr = select->Execute();
-
-		int count2 = 0;
-
-		FdoPtr<FdoByteArray> geom;
-	    	    
-	    
-		while (rdr->ReadNext())
+	    int count2 = 0;
+		for( int i=0; i<select_loop_count; i++ )
 		{
-			const wchar_t* something = rdr->GetString(L"Name");
-			//wcstombs(tmp, something, 1024);
-			//printf("Thread(%d):%s\n",cnInfo->connectionId, tmp);
-			count2++;
+			FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+			while (rdr->ReadNext())
+			{
+				const wchar_t* something = rdr->GetString(L"Name");
+				count2++;
+			}
+			counts[i] = count2;
+			rdr->Close();
+			wait_a_bit(100);
 		}
-#ifdef _WIN32
-		CPPUNIT_ASSERT_MESSAGE("Unexpected number of objects", count2==153 );
-#else
-		printf("Thread(%d) returned %d objects\n",cnInfo->connectionId,count2);
-#endif
-		rdr->Close();
+		char tmp[12];
+		buffer[0]=0;
+		for( int i=0; i<select_loop_count; i++ )
+		{
+			strcat( buffer, FdoCommonOSUtil::itoa(counts[i],tmp) );
+			strcat( buffer, " ");
+		}
 
+		printf("Thread(%d) is done Counts: %s \n",cnInfo->connectionId, buffer );
+		
 	}
 	catch (FdoException *ex )
 	{
-		sprintf(tmp,"FDO error: %ls\n", ex->GetExceptionMessage());
-		CPPUNIT_FAIL(tmp);
+		sprintf(buffer,"Query: FDO error: %ls\n", ex->GetExceptionMessage());
+		ex->Release();
+		CPPUNIT_FAIL(buffer);
 	}
 
     return 0;
@@ -73,6 +101,21 @@
 void* StartInsert( void *lpParameter) 
 #endif
 {
+	try
+	{
+		ConnectInfo  *cnInfo = (ConnectInfo*)lpParameter;
+		printf("Start insert Thread(%d)\n",cnInfo->connectionId );
+		for(int i=0; i<insert_loop_count; i++ )
+			UnitTestUtil::CreateData(false, cnInfo->mConn ,100, NULL, cnInfo->connectionId);
+		printf("Thread(%d) done insert\n",cnInfo->connectionId );
+	}
+	catch (FdoException *ex )
+	{
+		char buffer[1024];
+		sprintf(buffer,"Insert: FDO error: %ls\n", ex->GetExceptionMessage());
+		ex->Release();
+		CPPUNIT_FAIL(buffer);
+	}
     return 0;
 }
 
@@ -87,6 +130,7 @@
 
 void FdoMultiThreadTest::setUp ()
 {
+	UnitTestUtil::CreateData( true, NULL ,10000);
 }
 
 void FdoMultiThreadTest::OpenConnection(FdoIConnection* conn, const wchar_t* path )
@@ -104,7 +148,7 @@
 #endif
 
     std::wstring connStr = std::wstring(L"File=") + std::wstring(fullpath);
-    connStr += std::wstring(L";ReadOnly=TRUE");
+    connStr += std::wstring(L";ReadOnly=FALSE");
 
     conn->SetConnectionString(connStr.c_str());
     conn->Open();
@@ -129,7 +173,7 @@
 	    {
             info[i].connectionId = i;
             info[i].mConn = manager->CreateConnection (L"OSGeo.SDF.3.3");
-			OpenConnection(info[i].mConn,SDF_FILE);
+			OpenConnection(info[i].mConn,DESTINATION_FILE);
 	    } 
     }
     catch (FdoException *ex )
@@ -139,8 +183,19 @@
 	}
 
     bool  toggle = true;
-    for ( i = 0; i < NUMBER_OF_THREADS; i++)
+	
+	if( ! supports_multiple_writers && use_threads )
 	{
+#ifdef _WIN32
+		phThreads[0] = CreateThread(NULL, 0, funInfo->Function2, &info[0], 0, &dwThreadId);
+#else
+		pthread_create( &phThreads[0], NULL, funInfo->Function2, (void*) &info[0]);
+#endif
+	}
+
+	i = ( supports_multiple_writers )?0:1;
+    for ( ; i < NUMBER_OF_THREADS; i++)
+	{
         if( use_threads )
 #ifdef _WIN32
             phThreads[i] = CreateThread(NULL, 0, (toggle)?funInfo->Function1:funInfo->Function2, &info[i], 0, &dwThreadId);
@@ -150,9 +205,12 @@
         else
             StartQuery( &info[i] );
 
-        toggle = !toggle;
+		if( supports_multiple_writers )
+			toggle = !toggle;
 	} 
-    
+
+	
+
 #ifdef _WIN32
     if( use_threads )
 	    WaitForMultipleObjects(NUMBER_OF_THREADS, phThreads, TRUE, INFINITE);
@@ -180,17 +238,8 @@
     StartTest( &funcInfo );
 }
 
-void FdoMultiThreadTest::InsertTest()
-{
-    FunctionInfo funcInfo;
-    
-    InitInsertFunction(funcInfo.Function1);
-    InitInsertFunction(funcInfo.Function2);
 
-    StartTest( &funcInfo );
-}
-
-void FdoMultiThreadTest::CombinationTest()
+void FdoMultiThreadTest::InsertQueryTest()
 {
     FunctionInfo funcInfo;
 

Modified: trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/FdoMultiThreadTest.h	2007-03-26 20:46:30 UTC (rev 2716)
@@ -13,14 +13,10 @@
 #include <Windows.h>
 #endif // _WIN32
 
-#ifdef _WIN32
-#define SDF_FILE  L"..\\..\\TestData\\PARCEL.SDX"
-#define SDF_FILE_S  "..\\..\\TestData\\PARCEL.SDX"
-#else
-#define SDF_FILE  L"../../data/PARCEL_linuxtest.SDX"
-#define SDF_FILE_S  "../../data/PARCEL_linuxtest.SDX"
-#endif
+#define SDF_FILE  L"..\\..\\TestData\\PARCELS.SDF"
+#define SDF_FILE_S  "..\\..\\TestData\\PARCELS.SDF"
 
+
 #include <cppunit/TestCase.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include "Fdo.h"
@@ -45,10 +41,7 @@
 {
   CPPUNIT_TEST_SUITE( FdoMultiThreadTest );
   CPPUNIT_TEST( QueryTest );
-#ifdef _WIN32
-  CPPUNIT_TEST( InsertTest );
-  CPPUNIT_TEST( CombinationTest );
-#endif
+  CPPUNIT_TEST( InsertQueryTest );
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -60,8 +53,7 @@
 	void StartTest (FunctionInfo *funcInfo );
 	void OpenConnection(FdoIConnection* conn, const wchar_t* path );
     void QueryTest();
-    void InsertTest();
-    void CombinationTest();
+    void InsertQueryTest();
 #ifdef _WIN32
 	virtual void InitInsertFunction( LPTHREAD_START_ROUTINE & Funct );
 #else

Modified: trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.cpp	2007-03-26 20:46:30 UTC (rev 2716)
@@ -64,10 +64,14 @@
 #include "SDF/ICreateSDFFile.h"
 #include "UnitTestUtil.h"
 #include <cppunit/extensions/HelperMacros.h>
-const wchar_t* DEST_PATH = L"../../TestData/PARCEL_linuxtest.SDX";
+#include "FdoCommonFilterExecutor.h"
+#include "FdoCommonOSUtil.h"
+#include "FdoCommonMiscUtil.h"
+const wchar_t* CONSTRAINS_FILE = L"..\\..\\TestData\\Constrains.sdf";
 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";
+const wchar_t* DEST_PATH2 = L"..\\..\\TestData\\TestSdf.sdf";
 
 // Replace the text "TestExample" with your own class name
 CPPUNIT_TEST_SUITE_REGISTRATION(MasterTest);
@@ -138,11 +142,11 @@
     try {
         conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
        
         FdoPtr<FdoIDelete> del = (FdoIDelete*)conn->CreateCommand(FdoCommandType_Delete); 
 
-        del->SetFeatureClassName(L"DaKlass");
+        del->SetFeatureClassName(L"Parcel");
 
         //delete two features from the thing
         FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022') or (Key = 'LN0316')");
@@ -169,12 +173,12 @@
     try {
         conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
 
 
         FdoPtr<FdoIUpdate> update = (FdoIUpdate*)conn->CreateCommand(FdoCommandType_Update); 
 
-        update->SetFeatureClassName(L"DaKlass");
+        update->SetFeatureClassName(L"Parcel");
 
         FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022')");// or (Key = 'LN0316')");
 
@@ -201,52 +205,108 @@
 
 void MasterTest::concurencyTest()
 {
-    FdoPtr<FdoIConnection> update_conn;
-    
-    try {
-        update_conn = CreateConnection();
-        openConnection(update_conn, DEST_PATH);    
+    FdoPtr<FdoIConnection> update_conn = CreateConnection();
+    openConnection(update_conn, DESTINATION_FILE);    
 
 
-        FdoPtr<FdoIUpdate> update = (FdoIUpdate*)update_conn->CreateCommand(FdoCommandType_Update); 
+    FdoPtr<FdoIUpdate> update = (FdoIUpdate*)update_conn->CreateCommand(FdoCommandType_Update); 
 
-        update->SetFeatureClassName(L"DaKlass");
+    update->SetFeatureClassName(L"Parcel");
 
-        FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022')");// or (Key = 'LN0316')");
+    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Key = 'DI0022')");// or (Key = 'LN0316')");
 
-        update->SetFilter(filter);
+    update->SetFilter(filter);
 
-        FdoPtr<FdoStringValue> sval = FdoStringValue::Create(L"Cool");
-        FdoPtr<FdoPropertyValue> pv = FdoPropertyValue::Create(L"Name", sval);
+    FdoPtr<FdoStringValue> sval = FdoStringValue::Create(L"Cool");
+    FdoPtr<FdoPropertyValue> pv = FdoPropertyValue::Create(L"Name", sval);
 
-        FdoPtr<FdoPropertyValueCollection> pvc = update->GetPropertyValues();
+    FdoPtr<FdoPropertyValueCollection> pvc = update->GetPropertyValues();
 
-        pvc->Add(pv);
+    pvc->Add(pv);
 
-        printf("\n\n\nTesting Update");
-           
-        int count = update->Execute();
+    printf("\n\n\nTesting Update");
+       
+    int count = update->Execute();
 
-	    printf("\n\nUpdated %d features\n", count);
+	printf("\n\nUpdated %d features\n", count);
 
-        update_conn->Close();
-    }
-    catch ( FdoException* ex ) {
-        TestCommonFail( ex );
-    }
+	UnitTestUtil::CreateData( false, NULL, 200 );
+
+    update_conn->Close();
 }
 
+void MasterTest::concurencyRtreeTest()
+{
+	FdoPtr<FdoIConnection> conn1 = CreateConnection();
+
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 0);
+    conn->Close();
+	openConnection(conn, DESTINATION_FILE);
+
+	UnitTestUtil::CreateData( false , conn1, 4000);
+
+	conn1->Close();
+	openConnection(conn1, DESTINATION_FILE);    
+
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+    select->SetFeatureClassName(L"Parcel");
+    
+    FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+
+    double coords[] = { 7.2068, 43.7556, 
+                        7.2088, 43.7556, 
+                        7.2088, 43.7574, 
+                        7.2068, 43.7574, 
+                        7.2068, 43.7556 }; //last pt equals first for rings
+
+    FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+
+    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);
+    
+
+    printf("\n\n\nR-Tree filter");
+
+    select->SetFilter(filter);
+   
+    clock_t start;
+    clock_t finish;
+    start = clock ();
+    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+    int count2 = 0;
+
+    FdoPtr<FdoByteArray> geom;
+ 
+    while (rdr->ReadNext())
+        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 == 20);
+	conn->Close();
+}
+
 void MasterTest::keyFilterBeforeDelete()
 {
     try
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);
+        openConnection(conn, DESTINATION_FILE);
            
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
         //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'");
@@ -293,11 +353,11 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);
+        openConnection(conn, DESTINATION_FILE);
            
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
         //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'");
@@ -342,11 +402,11 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
        
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
 
         FdoPtr<FdoIdentifierCollection> propnames = select->GetPropertyNames();
@@ -415,11 +475,11 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
        
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
         FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
 
@@ -474,11 +534,11 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
         
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
         //FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"(Name = 'MO0418') or (Name = 'DE0065')");
 
@@ -531,7 +591,7 @@
         // Now do the selection again, using the non-default geometry property "Data2".
 
         select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
         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");
@@ -565,11 +625,11 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);    
+        openConnection(conn, DESTINATION_FILE);    
         
         FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
 
-        select->SetFeatureClassName(L"DaKlass");
+        select->SetFeatureClassName(L"Parcel");
 
        
         FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
@@ -667,7 +727,7 @@
     {
         FdoPtr<FdoIConnection> conn = CreateConnection();
 
-        openConnection(conn, DEST_PATH);
+        openConnection(conn, DESTINATION_FILE);
 
         printf("\n\n\nCoord sys tests");
         
@@ -1340,4 +1400,1020 @@
 		CPPUNIT_FAIL("Function test failed");
 	}
 }
+void MasterTest::rtreeCacheTest()
+{
+		try
+	{
+		FdoPtr<FdoIConnection> conn = CreateConnection();
 
+	    
+		UnitTestUtil::CreateData( true , conn, 4000);
+
+		//Enabling the next 2 lines would make the select read from the file and not from the cached data.
+		//conn->Close();
+		//openConnection(conn, DESTINATION_FILE);    
+
+		FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+		select->SetFeatureClassName(L"Parcel");
+	    
+		FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+
+		double coords[] = { 7.2068, 43.7556, 
+							7.2088, 43.7556, 
+							7.2088, 43.7574, 
+							7.2068, 43.7574, 
+							7.2068, 43.7556 }; //last pt equals first for rings
+
+		FdoPtr<FdoILinearRing> outer = gf->CreateLinearRing(0, 10, coords);
+
+		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);
+	    
+		printf("\n\n\nR-Tree filter");
+
+		select->SetFilter(filter);
+	   
+		FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+		int count2 = 0;
+		bool found = false;
+		while (rdr->ReadNext())
+		{
+			const wchar_t* something = rdr->GetString(L"Name");
+			if( wcscmp( something, L"AB0039") == 0 )
+				found = true;
+			count2++;
+		}
+		rdr->Close();
+		CPPUNIT_ASSERT(found);
+
+		FdoPtr<FdoIDelete> del = (FdoIDelete*)conn->CreateCommand(FdoCommandType_Delete); 
+		del->SetFeatureClassName(L"Parcel");
+		FdoPtr<FdoFilter> delfilter = FdoFilter::Parse(L"Name ='AB0039'");
+		del->SetFilter(delfilter);
+		CPPUNIT_ASSERT( del->Execute() == 1 );
+
+		// Let's make sure the feature is removed
+		rdr = select->Execute();
+		count2 = 0;
+		found = false;
+		while (rdr->ReadNext())
+		{
+			const wchar_t* something = rdr->GetString(L"Name");
+			if( wcscmp( something, L"AB0039") == 0 )
+				found = true;
+			count2++;
+		}
+		rdr->Close();
+		CPPUNIT_ASSERT(!found);    
+		CPPUNIT_ASSERT(count2 == 18);
+		conn->Close();
+	}
+	catch(FdoException *e )
+	{
+		wprintf(L"%s\n", e->GetExceptionMessage());
+        e->Release();
+		CPPUNIT_FAIL("Unexpected FdoException");
+	}
+}
+
+void MasterTest::CreateEmptyShpFileWithConstraints(FdoIConnection* conn)
+{
+    FdoPtr<FdoDataPropertyDefinition> dpd;
+
+    //first delete the destination file if it exists already -- cleanup that is
+    SetFileAttributesW(CONSTRAINS_FILE, FILE_ATTRIBUTE_NORMAL);
+	DeleteFileW( CONSTRAINS_FILE );
+
+    wchar_t fullpath[1024];
+    _wfullpath(fullpath, CONSTRAINS_FILE, 1024);
+
+	FdoPtr<FdoICreateDataStore>	pCreateCmd = (FdoICreateDataStore*) conn->CreateCommand(FdoCommandType_CreateDataStore);
+
+	FdoPtr<FdoIDataStorePropertyDictionary> dictionary = pCreateCmd->GetDataStoreProperties();
+
+	int	count;
+	FdoString **names = dictionary->GetPropertyNames(count);
+
+	CPPUNIT_ASSERT_MESSAGE("Wrong number of properties for create cmd", count==1 );
+
+	dictionary->SetProperty( names[0], fullpath );
+
+	pCreateCmd->Execute();	
+	openConnection(conn, CONSTRAINS_FILE);   
+	FdoPtr<FdoICreateSpatialContext>	pCreateCreateSpatialContext = (FdoICreateSpatialContext*) conn->CreateCommand(FdoCommandType_CreateSpatialContext);
+	pCreateCreateSpatialContext->SetCoordinateSystemWkt(L"[LL84]");
+	pCreateCreateSpatialContext->SetDescription(L"World Coordinate System, Degrees, what else do you need to know?" );
+	pCreateCreateSpatialContext->SetName( L"World Geodetic Coordinate System, 1984" );
+	pCreateCreateSpatialContext->SetXYTolerance( 17.0 );
+	pCreateCreateSpatialContext->SetZTolerance(3.14159);
+	pCreateCreateSpatialContext->Execute();
+	
+
+    //apply schema
+    FdoPtr<FdoIApplySchema> applyschema = (FdoIApplySchema*)conn->CreateCommand(FdoCommandType_ApplySchema);
+
+    FdoPtr<FdoFeatureSchema> schema = FdoFeatureSchema::Create(L"MySchema", L"");
+    FdoPtr<FdoFeatureClass> clas = FdoFeatureClass::Create(L"MyClass",L"");
+    FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas);
+    FdoPtr<FdoPropertyDefinitionCollection> properties = clas->GetProperties();
+    FdoPtr<FdoGeometricPropertyDefinition> geometry = FdoGeometricPropertyDefinition::Create(L"Geom", L"");
+    geometry->SetGeometryTypes(7); // Point, Line, Polygon
+    properties->Add(geometry);
+    clas->SetGeometryProperty(geometry);
+    dpd = FdoDataPropertyDefinition::Create(L"NotNullString", L"");
+    dpd->SetNullable(false);
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"StringRange", L"");
+    FdoPtr<FdoPropertyValueConstraintRange> rangeConstraint = FdoPropertyValueConstraintRange::Create();
+    rangeConstraint->SetMaxInclusive(false);
+    rangeConstraint->SetMaxValue(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Rich")));
+    rangeConstraint->SetMinInclusive(true);
+    rangeConstraint->SetMinValue(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Poor")));
+    dpd->SetValueConstraint(rangeConstraint);
+    dpd->SetNullable(true);
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"Int32Range", L"The key of the object");
+    dpd->SetDataType(FdoDataType_Int32);
+    rangeConstraint = FdoPropertyValueConstraintRange::Create();
+    rangeConstraint->SetMaxInclusive(true);
+    rangeConstraint->SetMaxValue(FdoPtr<FdoDataValue>(FdoDataValue::Create(10000)));
+    rangeConstraint->SetMinInclusive(true);
+    //rangeConstraint->SetMinValue(FdoPtr<FdoDataValue>(FdoDataValue::Create(0)));
+    dpd->SetNullable(true);
+    dpd->SetValueConstraint(rangeConstraint);
+    properties->Add(dpd);
+    FdoPtr<FdoDataPropertyDefinitionCollection>(clas->GetIdentityProperties())->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"StringEnum", L"");
+    FdoPtr<FdoPropertyValueConstraintList> listConstraint = FdoPropertyValueConstraintList::Create();
+    FdoPtr<FdoDataValueCollection> listValues = listConstraint->GetConstraintList();
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Up")));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Down")));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Left")));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Right")));
+    dpd->SetNullable(true);
+    dpd->SetValueConstraint(listConstraint);
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"Int32Enum", L"");
+    listConstraint = FdoPropertyValueConstraintList::Create();
+    listValues = listConstraint->GetConstraintList();
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(1)));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(2)));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(3)));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(5)));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(7)));
+    listValues->Add(FdoPtr<FdoDataValue>(FdoDataValue::Create(9)));
+    dpd->SetNullable(true);
+    dpd->SetValueConstraint(listConstraint);
+    dpd->SetDataType(FdoDataType_Int32);
+    properties->Add(dpd);
+
+    applyschema->SetFeatureSchema(schema);
+    applyschema->Execute();
+}
+
+void MasterTest::testConstraints()
+{
+	FdoPtr<FdoIConnection> conn = CreateConnection();
+    FdoPtr<FdoDataPropertyDefinition> dpd;
+
+    CreateEmptyShpFileWithConstraints(conn);
+
+    //try out describe schema
+    FdoPtr<FdoIDescribeSchema> desc = (FdoIDescribeSchema*)conn->CreateCommand(FdoCommandType_DescribeSchema);
+    FdoPtr<FdoFeatureSchemaCollection> schemas = desc->Execute();
+    FdoPtr<FdoFeatureSchema> schema2 = schemas->GetItem(0);
+    FdoPtr<FdoClassCollection> ccol = schema2->GetClasses();
+    FdoPtr<FdoClassDefinition> cdef = ccol->GetItem(L"MyClass");
+    FdoPtr<FdoPropertyDefinitionCollection> pdc = cdef->GetProperties();
+
+
+    FdoPtr<FdoPropertyDefinition> pd = pdc->GetItem(L"NotNullString");
+    CPPUNIT_ASSERT_MESSAGE("Wrong property type", pd->GetPropertyType() == FdoPropertyType_DataProperty);
+    dpd = FDO_SAFE_ADDREF(static_cast<FdoDataPropertyDefinition*>(pd.p));
+    CPPUNIT_ASSERT_MESSAGE("Wrong data property type", dpd->GetDataType() == FdoDataType_String);
+    CPPUNIT_ASSERT_MESSAGE("Wrong nullability", dpd->GetNullable() == false);
+
+    pd = pdc->GetItem(L"StringRange");
+    CPPUNIT_ASSERT_MESSAGE("Wrong property type", pd->GetPropertyType() == FdoPropertyType_DataProperty);
+    dpd = FDO_SAFE_ADDREF(static_cast<FdoDataPropertyDefinition*>(pd.p));
+    FdoPtr<FdoPropertyValueConstraint> valCons = dpd->GetValueConstraint();
+    CPPUNIT_ASSERT_MESSAGE("Wrong constraint type", valCons->GetConstraintType() == FdoPropertyValueConstraintType_Range);
+    FdoPtr<FdoPropertyValueConstraintRange> rangeValCons = FDO_SAFE_ADDREF(static_cast<FdoPropertyValueConstraintRange*>(valCons.p));
+    CPPUNIT_ASSERT_MESSAGE("Wrong max inclusive type", rangeValCons->GetMaxInclusive() == false);
+    CPPUNIT_ASSERT_MESSAGE("Wrong min inclusive type", rangeValCons->GetMinInclusive() == true);
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(rangeValCons->GetMaxValue()), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Rich")));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(rangeValCons->GetMinValue()), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Poor")));
+
+    pd = pdc->GetItem(L"Int32Range");
+    CPPUNIT_ASSERT_MESSAGE("Wrong property type", pd->GetPropertyType() == FdoPropertyType_DataProperty);
+    dpd = FDO_SAFE_ADDREF(static_cast<FdoDataPropertyDefinition*>(pd.p));
+    valCons = dpd->GetValueConstraint();
+    CPPUNIT_ASSERT_MESSAGE("Wrong constraint type", valCons->GetConstraintType() == FdoPropertyValueConstraintType_Range);
+    rangeValCons = FDO_SAFE_ADDREF(static_cast<FdoPropertyValueConstraintRange*>(valCons.p));
+    CPPUNIT_ASSERT_MESSAGE("Wrong max inclusive type", rangeValCons->GetMaxInclusive() == true);
+    CPPUNIT_ASSERT_MESSAGE("Wrong min inclusive type", rangeValCons->GetMinInclusive() == true);
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(rangeValCons->GetMaxValue()), FdoPtr<FdoDataValue>(FdoDataValue::Create(10000)));
+    CPPUNIT_ASSERT_MESSAGE("Wrong min inclusive", rangeValCons->GetMinValue() == NULL);
+    // FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(rangeValCons->GetMinValue()), FdoPtr<FdoDataValue>(FdoDataValue::Create(0)));
+
+    pd = pdc->GetItem(L"StringEnum");
+    CPPUNIT_ASSERT_MESSAGE("Wrong property type", pd->GetPropertyType() == FdoPropertyType_DataProperty);
+    dpd = FDO_SAFE_ADDREF(static_cast<FdoDataPropertyDefinition*>(pd.p));
+    valCons = dpd->GetValueConstraint();
+    CPPUNIT_ASSERT_MESSAGE("Wrong constraint type", valCons->GetConstraintType() == FdoPropertyValueConstraintType_List);
+    FdoPtr<FdoPropertyValueConstraintList> listValCons = FDO_SAFE_ADDREF(static_cast<FdoPropertyValueConstraintList*>(valCons.p));
+    FdoPtr<FdoDataValueCollection> dataValues = listValCons->GetConstraintList();
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(0)), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Up")));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(1)), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Down")));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(2)), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Left")));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(3)), FdoPtr<FdoDataValue>(FdoDataValue::Create(L"Right")));
+
+    pd = pdc->GetItem(L"Int32Enum");
+    CPPUNIT_ASSERT_MESSAGE("Wrong property type", pd->GetPropertyType() == FdoPropertyType_DataProperty);
+    dpd = FDO_SAFE_ADDREF(static_cast<FdoDataPropertyDefinition*>(pd.p));
+    valCons = dpd->GetValueConstraint();
+    CPPUNIT_ASSERT_MESSAGE("Wrong constraint type", valCons->GetConstraintType() == FdoPropertyValueConstraintType_List);
+    listValCons = FDO_SAFE_ADDREF(static_cast<FdoPropertyValueConstraintList*>(valCons.p));
+    dataValues = listValCons->GetConstraintList();
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(0)), FdoPtr<FdoDataValue>(FdoDataValue::Create(1)));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(1)), FdoPtr<FdoDataValue>(FdoDataValue::Create(2)));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(2)), FdoPtr<FdoDataValue>(FdoDataValue::Create(3)));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(3)), FdoPtr<FdoDataValue>(FdoDataValue::Create(5)));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(3)), FdoPtr<FdoDataValue>(FdoDataValue::Create(7)));
+    FdoCommonFilterExecutor::IsEqualTo(FdoPtr<FdoDataValue>(dataValues->GetItem(3)), FdoPtr<FdoDataValue>(FdoDataValue::Create(9)));
+
+
+    //set up the insert command
+    //we will execute it multiple times with different property values
+    FdoPtr<FdoIInsert> insert = (FdoIInsert*)conn->CreateCommand(FdoCommandType_Insert);
+    insert->SetFeatureClassName(L"MyClass");        
+
+    FdoPtr<FdoPropertyValueCollection> propvals = insert->GetPropertyValues();
+
+    FdoPtr<FdoStringValue> notnullstring = FdoStringValue::Create(L"");
+    FdoPtr<FdoStringValue> stringrange = FdoStringValue::Create(L"");
+    FdoPtr<FdoStringValue> stringenum = FdoStringValue::Create(L"");
+    FdoPtr<FdoInt32Value> int32range = FdoInt32Value::Create(0);
+    FdoPtr<FdoInt32Value> int32enum = FdoInt32Value::Create(0);
+    FdoPtr<FdoGeometryValue> geomval = FdoGeometryValue::Create(NULL);
+
+    FdoPtr<FdoPropertyValue> pvnotnullstring = FdoPropertyValue::Create(L"NotNullString", notnullstring);
+    FdoPtr<FdoPropertyValue> pvstringrange = FdoPropertyValue::Create(L"StringRange", stringrange);
+    FdoPtr<FdoPropertyValue> pvstringenum = FdoPropertyValue::Create(L"StringEnum", stringenum);
+    FdoPtr<FdoPropertyValue> pvint32range = FdoPropertyValue::Create(L"Int32Range", int32range);
+    FdoPtr<FdoPropertyValue> pvint32enum = FdoPropertyValue::Create(L"Int32Enum", int32enum);
+    FdoPtr<FdoPropertyValue> pvgeom = FdoPropertyValue::Create(L"Geom", geomval);
+        
+    propvals->Add(pvnotnullstring);
+    propvals->Add(pvstringrange);
+    propvals->Add(pvstringenum);
+    propvals->Add(pvint32range);
+    propvals->Add(pvint32enum);
+    propvals->Add(pvgeom);
+
+    // Insert correct not-null string:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetNull();
+    FdoPtr<FdoIFeatureReader> reader = insert->Execute();
+
+    // Insert incorrect not-null string:
+    notnullstring->SetNull();
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetNull();
+    try
+    {
+        reader = insert->Execute();
+        CPPUNIT_FAIL("Didnt receive expected exception");
+    }
+    catch (FdoException *e)
+    {
+        e->Release(); // we want an exception here, so dont fail
+    }
+
+    // Insert correct string range:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetString(L"Poor");
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetNull();
+    reader = insert->Execute();
+
+    // Insert incorrect string range:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetString(L"Rich");
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetNull();
+    try
+    {
+        reader = insert->Execute();
+        CPPUNIT_FAIL("Didnt receive expected exception");
+    }
+    catch (FdoException *e)
+    {
+        e->Release(); // we want an exception here, so dont fail
+    }
+
+    // Insert correct string enum:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetString(L"Down");
+    int32range->SetNull();
+    int32enum->SetNull();
+    reader = insert->Execute();
+
+    // Insert incorrect string enum:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetString(L"Bottom");
+    int32range->SetNull();
+    int32enum->SetNull();
+    try
+    {
+        reader = insert->Execute();
+        CPPUNIT_FAIL("Didnt receive expected exception");
+    }
+    catch (FdoException *e)
+    {
+        e->Release(); // we want an exception here, so dont fail
+    }
+
+    // Insert correct int32 range:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetInt32(333);
+    int32enum->SetNull();
+    reader = insert->Execute();
+
+    // Insert incorrect int32 range:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetInt32(10001);
+    int32enum->SetNull();
+    try
+    {
+        reader = insert->Execute();
+        CPPUNIT_FAIL("Didnt receive expected exception");
+    }
+    catch (FdoException *e)
+    {
+        e->Release(); // we want an exception here, so dont fail
+    }
+
+    // Insert correct int32 enum:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetInt32(9);
+    reader = insert->Execute();
+
+    // Insert incorrect int32 enum:
+    notnullstring->SetString(L"I'm not null!");
+    stringrange->SetNull();
+    stringenum->SetNull();
+    int32range->SetNull();
+    int32enum->SetInt32(11);
+    try
+    {
+        reader = insert->Execute();
+        CPPUNIT_FAIL("Didnt receive expected exception");
+    }
+    catch (FdoException *e)
+    {
+        e->Release(); // we want an exception here, so dont fail
+    }
+
+
+	conn->Close();
+}
+
+void MasterTest::noGeomObject()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 10 );
+
+	// Let's insert more feature with no geometry
+	FdoPtr<FdoIInsert> insert = (FdoIInsert*)conn->CreateCommand(FdoCommandType_Insert);
+
+    FdoPtr<FdoPropertyValueCollection> propvals = insert->GetPropertyValues();
+
+	FdoPtr<FdoStringValue> svname = FdoStringValue::Create(L"");
+    FdoPtr<FdoStringValue> svkey = FdoStringValue::Create(L"");
+	FdoPtr<FdoPropertyValue> pvname = FdoPropertyValue::Create(L"Name", svname);
+    FdoPtr<FdoPropertyValue> pvkey = FdoPropertyValue::Create(L"Key", svkey);
+
+	FdoPtr<FdoGeometryValue> gvgeom = FdoGeometryValue::Create();
+	gvgeom->SetNullValue();
+	FdoPtr<FdoPropertyValue> pvgeom = FdoPropertyValue::Create(L"Data", gvgeom);
+
+	
+	insert->SetFeatureClassName(L"Parcel");  
+
+	propvals->Add(pvname);
+    propvals->Add(pvkey);
+	propvals->Add(pvgeom);
+
+	svname->SetString(L"My Test Object");
+	svkey->SetString(L"AB002X3B");
+	FdoPtr<FdoIFeatureReader>rdr = insert->Execute();
+	CPPUNIT_ASSERT_MESSAGE("Unable to create an object with no geometry", rdr->ReadNext() );
+	printf("Insert new object: ID(%d)\n", rdr->GetInt32(L"ID") );
+    
+	FdoPtr<FdoClassDefinition>cls = rdr->GetClassDefinition();
+	CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"Parcel",cls->GetName())==0);
+	
+	conn->Close();
+}
+
+void MasterTest::numberFilter()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 10 );
+	conn->Close();
+	UnitTestUtil::CreateData( false , conn, 10, L"ParcelChild" );
+    conn->Close();
+	UnitTestUtil::CreateData( false , conn, 400 );
+	conn->Close();
+	openConnection(conn, DESTINATION_FILE);
+
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+    select->SetFeatureClassName(L"Parcel");
+
+    FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"ID <= 300");
+
+
+    select->SetFilter(filter);
+    
+    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+    int count2 = 0;
+
+
+    FdoPtr<FdoByteArray> geom;
+	int id = 0;
+    while (rdr->ReadNext())
+    {
+		FdoPtr<FdoPropertyDefinition> gp;
+		FdoPtr<FdoClassDefinition>cls = rdr->GetClassDefinition();
+        const wchar_t* something = rdr->GetString(L"Key");
+		if( (id=rdr->GetInt32(L"ID")) <= 10 )
+		{
+			CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"Parcel",cls->GetName())==0);
+		    gp = (FdoPtr<FdoPropertyDefinitionCollection>(cls->GetProperties()))->GetItem(L"Data");
+		}
+		else if ( (id=rdr->GetInt32(L"ID")) <= 20  )
+		{
+			CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"ParcelChild",cls->GetName())==0);
+			gp = (FdoPtr<FdoReadOnlyPropertyDefinitionCollection>(cls->GetBaseProperties()))->GetItem(L"Data");
+		}
+		//printf("key(%ls) ID(%d) number(%d) \n",something, rdr->GetInt32(L"ID"), rdr->GetInt32(L"Numb"));
+	    if( gp != NULL )
+		{
+			FdoGeometricPropertyDefinition *geom = (FdoGeometricPropertyDefinition*)gp.p;
+			CPPUNIT_ASSERT_MESSAGE("Expected a not null geometry property Spatial context", geom->GetSpatialContextAssociation() != NULL );
+		}
+        count2++;
+    }
+
+
+    rdr->Close();
+    conn->Close();
+
+	CPPUNIT_ASSERT_MESSAGE("Wrong number of returned objects", count2==300 );
+}
+
+void MasterTest::inFilter()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 200 );
+	UnitTestUtil::CreateData( false , conn, 200, L"ParcelChild" );
+	UnitTestUtil::CreateData( false , conn, 400 );
+   
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+    select->SetFeatureClassName(L"ParcelChild");
+	FdoPtr<FdoIdentifierCollection> props = select->GetPropertyNames();
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"DblNumb1")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Key")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"ID")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Numb")) );
+    select->SetFilter(FdoPtr<FdoFilter>(FdoFilter::Parse(L"Numb in (120,150,170,191)")));
+    
+    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+    int count2 = 0;
+
+    FdoPtr<FdoByteArray> geom;
+
+    while (rdr->ReadNext())
+    {
+		CPPUNIT_ASSERT_MESSAGE("Property should be NULL", rdr->IsNull(L"DblNumb1") );
+		
+        const wchar_t* something = rdr->GetString(L"Key");
+		FdoPtr<FdoClassDefinition>cls = rdr->GetClassDefinition();
+		CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"ParcelChild",cls->GetName())==0);
+		//printf("Class name = %ls Numb=%d\n", cls->GetName(), rdr->GetInt32(L"Numb") );
+		printf("key(%ls) ID(%d) number(%d) \n",something, rdr->GetInt32(L"ID"), rdr->GetInt32(L"Numb"));
+        count2++;
+		CPPUNIT_ASSERT_MESSAGE( "The property should be NULL", rdr->IsNull(L"DblNumb2") );
+		
+	}
+
+    rdr->Close();
+    conn->Close();
+
+	CPPUNIT_ASSERT_MESSAGE("Wrong number of returned objects", count2==4 );
+}
+
+void MasterTest::likeFilter()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 200 );
+	UnitTestUtil::CreateData( false , conn, 200, L"ParcelChild" );
+	UnitTestUtil::CreateData( false , conn, 400 );
+   
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+    select->SetFeatureClassName(L"ParcelChild");
+	FdoPtr<FdoIdentifierCollection> props = select->GetPropertyNames();
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"DblNumb1")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Key")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"ID")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Numb")) );
+    select->SetFilter(FdoPtr<FdoFilter>(FdoFilter::Parse(L"Key like 'AB007%'")));
+    
+    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+    int count2 = 0;
+
+    FdoPtr<FdoByteArray> geom;
+
+    while (rdr->ReadNext())
+    {
+		CPPUNIT_ASSERT_MESSAGE("Property should be NULL", rdr->IsNull(L"DblNumb1") );
+		
+        const wchar_t* something = rdr->GetString(L"Key");
+		FdoPtr<FdoClassDefinition>cls = rdr->GetClassDefinition();
+		CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"ParcelChild",cls->GetName())==0);
+		//printf("Class name = %ls Numb=%d\n", cls->GetName(), rdr->GetInt32(L"Numb") );
+		printf("key(%ls) ID(%d) number(%d) \n",something, rdr->GetInt32(L"ID"), rdr->GetInt32(L"Numb"));
+        count2++;
+		CPPUNIT_ASSERT_MESSAGE( "The property should be NULL", rdr->IsNull(L"DblNumb2") );
+		
+	}
+
+    rdr->Close();
+    conn->Close();
+
+	CPPUNIT_ASSERT_MESSAGE("Wrong number of returned objects", count2==10 );
+}
+
+void MasterTest::orFilter()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 200 );
+	UnitTestUtil::CreateData( false , conn, 200, L"ParcelChild" );
+	UnitTestUtil::CreateData( false , conn, 400 );
+   
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+
+    select->SetFeatureClassName(L"ParcelChild");
+	FdoPtr<FdoIdentifierCollection> props = select->GetPropertyNames();
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"DblNumb1")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Key")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"ID")) );
+	props->Add(FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"Numb")) );
+	select->SetFilter(FdoPtr<FdoFilter>(FdoFilter::Parse(L" 1=0 or (Numb = 120 and Key like 'AB007%') or (Numb = 150 and Key like 'AB0%') or Numb = 170 or Numb = 191")));
+    
+    FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+
+    int count2 = 0;
+
+    FdoPtr<FdoByteArray> geom;
+
+    while (rdr->ReadNext())
+    {
+		CPPUNIT_ASSERT_MESSAGE("Property should be NULL", rdr->IsNull(L"DblNumb1") );
+		
+        const wchar_t* something = rdr->GetString(L"Key");
+		FdoPtr<FdoClassDefinition>cls = rdr->GetClassDefinition();
+		CPPUNIT_ASSERT_MESSAGE("Wrong class name",wcscmp(L"ParcelChild",cls->GetName())==0);
+		//printf("Class name = %ls Numb=%d\n", cls->GetName(), rdr->GetInt32(L"Numb") );
+		printf("key(%ls) ID(%d) number(%d) \n",something, rdr->GetInt32(L"ID"), rdr->GetInt32(L"Numb"));
+        count2++;
+		CPPUNIT_ASSERT_MESSAGE( "The property should be NULL", rdr->IsNull(L"DblNumb2") );
+		
+	}
+
+    rdr->Close();
+    conn->Close();
+
+	CPPUNIT_ASSERT_MESSAGE("Wrong number of returned objects", count2==4 );
+}
+
+void MasterTest::dateFilter()
+{
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+	UnitTestUtil::CreateData( true , conn, 200 );
+	//conn->Close();
+	UnitTestUtil::CreateData( false , conn, 200, L"ParcelChild" );
+    //conn->Close();
+   
+    FdoPtr<FdoISelect> select = (FdoISelect*)conn->CreateCommand(FdoCommandType_Select); 
+    try
+	{
+		select->SetFeatureClassName(L"ParcelChild");  
+		select->SetFilter(FdoPtr<FdoFilter>(FdoFilter::Parse(L"datetime = TIMESTAMP '2006-04-21 19:40:10.0001'")));
+	/*
+	    // The object version of the same filter
+		FdoPtr<FdoComparisonCondition>pCompare = FdoComparisonCondition::Create(
+							FdoPtr<FdoIdentifier>(FdoIdentifier::Create(L"datetime")), 
+							FdoComparisonOperations_EqualTo, 
+							FdoPtr<FdoDateTimeValue>( FdoDateTimeValue::Create(FdoDateTime(2006,4,21,19,40,10.0001) ) ) ); 
+		select->SetFilter(pCompare);
+	*/
+	    
+		int   gold_data[] = {100,160,220,280};
+		int count = 0;
+		FdoPtr<FdoIFeatureReader> rdr = select->Execute();
+		while (rdr->ReadNext())
+		{
+			if( count < 4 )
+				CPPUNIT_ASSERT_MESSAGE("Wrong return value", gold_data[count++]==rdr->GetInt32(L"Numb") );
+		}
+		CPPUNIT_ASSERT_MESSAGE("Wrong number of returned objects", count==4 );
+	}
+	catch(FdoException *exp )
+	{
+		printf("Exception: %ls \n", exp->GetExceptionMessage() );
+		throw;
+	}
+    conn->Close();
+}
+
+void MasterTest::testSpecialClassNames()
+{        
+#ifdef _WIN32
+    DeleteFileW( DEST_PATH2 );
+#else
+	size_t len = wcstombs(NULL, DEST_PATH2, 0);
+    char* mbsPath = new char[len+1];
+    wcstombs(mbsPath, DEST_PATH2, len+1);
+	unlink( mbsPath );
+	delete mbsPath;
+#endif
+	try
+	{
+		FdoPtr<FdoIConnection> conn = CreateConnection();
+		FdoPtr<FdoICreateDataStore>	pCreateCmd = (FdoICreateDataStore*) conn->CreateCommand(FdoCommandType_CreateDataStore);
+		FdoPtr<FdoIDataStorePropertyDictionary> dictionary = pCreateCmd->GetDataStoreProperties();
+
+		int	count;
+		FdoString **names = dictionary->GetPropertyNames(count);
+		dictionary->SetProperty( names[0], DEST_PATH2 );
+		pCreateCmd->Execute();	
+
+
+		openConnection(conn, DEST_PATH2); 
+		FdoPtr<FdoIApplySchema> applyschema = (FdoIApplySchema*)conn->CreateCommand(FdoCommandType_ApplySchema);
+		
+		FdoPtr<FdoFeatureSchema> schema = FdoFeatureSchema::Create(L"SDFTestSchema",L"Schema to test special class names");
+
+		FdoPtr<FdoFeatureClass> clas = FdoFeatureClass::Create(L"special-class",L"");    
+		FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas);
+	        
+		FdoPtr<FdoPropertyDefinitionCollection> properties = clas->GetProperties();
+
+		FdoPtr<FdoDataPropertyDefinition> dpd = FdoDataPropertyDefinition::Create(L"Name", L"The name of the object");
+		dpd->SetDataType(FdoDataType_String);
+		properties->Add(dpd);
+
+		dpd = FdoDataPropertyDefinition::Create(L"ID", L"The autogenerated sequence ID of the object");
+		dpd->SetDataType(FdoDataType_Int32);
+		dpd->SetIsAutoGenerated(true);
+		properties->Add(dpd);
+		FdoPtr<FdoDataPropertyDefinitionCollection>(clas->GetIdentityProperties())->Add(dpd);
+
+		clas = FdoFeatureClass::Create(L"special*class",L"");    
+		FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas);
+	        
+		properties = clas->GetProperties();
+
+		dpd = FdoDataPropertyDefinition::Create(L"Name", L"The name of the object");
+		dpd->SetDataType(FdoDataType_String);
+		properties->Add(dpd);
+
+		dpd = FdoDataPropertyDefinition::Create(L"ID", L"The autogenerated sequence ID of the object");
+		dpd->SetDataType(FdoDataType_Int32);
+		dpd->SetIsAutoGenerated(true);
+		properties->Add(dpd);
+		FdoPtr<FdoDataPropertyDefinitionCollection>(clas->GetIdentityProperties())->Add(dpd);
+
+		applyschema->SetFeatureSchema(schema);
+		applyschema->Execute();
+	}
+	catch(FdoException* e)
+    {
+        wprintf(L"%s\n", e->GetExceptionMessage());
+        e->Release();
+		CPPUNIT_FAIL("Unexpected FdoException");
+    }
+}
+
+void MasterTest::selectAggregatesSpatialExtentsTest()
+{
+    printf("Testing select aggregates -- Spatial Extents:\n");
+
+    FdoPtr<FdoISelectAggregates> selAggr;
+    FdoPtr<FdoIDataReader> rdr;
+    FdoPtr<FdoIdentifierCollection> ids;
+    FdoPtr<FdoExpression> expr;
+    FdoPtr<FdoComputedIdentifier> cid;
+    int count;
+    FdoPtr<FdoIConnection> conn = CreateConnection();
+
+
+    openConnection(conn, SHP_PATH2, true);
+
+    FdoPtr<FdoISelectAggregates> advsel = (FdoISelectAggregates*)(conn->CreateCommand(FdoCommandType_SelectAggregates));
+
+    advsel->SetFeatureClassName(L"province");
+    
+    ids = advsel->GetPropertyNames();
+
+    expr = FdoExpression::Parse(L"SpatialExtents(SHPGEOM)");
+    cid = FdoComputedIdentifier::Create(L"MBR", expr);
+    ids->Add(cid);
+
+
+    // Test the optimized case (no filter, no other identifiers in select property list):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+    rdr = advsel->Execute();
+
+    count = 0;
+
+    FdoPtr<FdoIEnvelope> envelopeAllWithoutFilter;
+    while (rdr->ReadNext())
+    {
+        FdoPtr<FdoByteArray> geomBytes = rdr->GetGeometry(L"MBR");
+        FdoPtr<FdoIGeometry> geom = gf->CreateGeometryFromFgf(geomBytes);
+
+        FdoGeometryType geomType = geom->GetDerivedType();
+        if (geomType != FdoGeometryType_Polygon)
+		    CPPUNIT_FAIL("Expected Polygon geometry for SpatialExtents() result");
+
+        envelopeAllWithoutFilter = geom->GetEnvelope();
+        if (envelopeAllWithoutFilter->GetIsEmpty())
+            CPPUNIT_FAIL("Expected non-empty envelope for SpatialExtents() result");
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+
+    rdr->Close();
+
+
+    // Test the non-optimized case (with a filter provided):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    advsel->SetFilter(L"AREA != -1.0");  // this is an arbitrary value that should allow all rows through
+    rdr = advsel->Execute();
+
+    count = 0;
+    FdoPtr<FdoIEnvelope> envelopeAllWithFilter;
+    while (rdr->ReadNext())
+    {
+        FdoPtr<FdoByteArray> geomBytes = rdr->GetGeometry(L"MBR");
+        FdoPtr<FdoIGeometry> geom = gf->CreateGeometryFromFgf(geomBytes);
+
+        FdoGeometryType geomType = geom->GetDerivedType();
+        if (geomType != FdoGeometryType_Polygon)
+		    CPPUNIT_FAIL("Expected Polygon geometry for SpatialExtents() result");
+
+        envelopeAllWithFilter = geom->GetEnvelope();
+        if (envelopeAllWithFilter->GetIsEmpty())
+            CPPUNIT_FAIL("Expected non-empty envelope for SpatialExtents() result");
+
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+
+    rdr->Close();
+
+    // Compare the two "all" results to make sure they are equivalent:
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinX)", envelopeAllWithoutFilter->GetMinX() == envelopeAllWithFilter->GetMinX());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinY)", envelopeAllWithoutFilter->GetMinY() == envelopeAllWithFilter->GetMinY());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinZ)", FdoCommonOSUtil::_isnan(envelopeAllWithoutFilter->GetMinZ()) && FdoCommonOSUtil::_isnan(envelopeAllWithFilter->GetMinZ()));
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxX)", envelopeAllWithoutFilter->GetMaxX() == envelopeAllWithFilter->GetMaxX());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxY)", envelopeAllWithoutFilter->GetMaxY() == envelopeAllWithFilter->GetMaxY());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxZ)", FdoCommonOSUtil::_isnan(envelopeAllWithoutFilter->GetMaxZ()) && FdoCommonOSUtil::_isnan(envelopeAllWithFilter->GetMaxZ()));
+
+
+    // Test the non-optimized case (filter that returns NULL):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    advsel->SetFilter(L"AREA = -1");  // will select 0 rows
+    rdr = advsel->Execute();
+
+    count = 0;
+    while (rdr->ReadNext())
+    {
+        CPPUNIT_ASSERT_MESSAGE("Expected NULL result from SpatialExtents with filter returning 0 rows", rdr->IsNull(L"MBR"));
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+
+    rdr->Close();
+
+
+    // Test the non-optimized case (no filter, more than one thing in the identifier property list):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    advsel->SetFilter((FdoFilter*)NULL);  // no filter
+    ids->Add(FdoPtr<FdoIdentifier>(FdoComputedIdentifier::Create(L"MyCount",
+                FdoPtr<FdoExpression>(FdoExpression::Parse(L"Count(AREA)"))
+             )));
+    rdr = advsel->Execute();
+
+    count = 0;
+    FdoPtr<FdoIEnvelope> envelopeAllWithoutFilterMultipleIds;
+    while (rdr->ReadNext())
+    {
+        FdoPtr<FdoByteArray> geomBytes = rdr->GetGeometry(L"MBR");
+        FdoPtr<FdoIGeometry> geom = gf->CreateGeometryFromFgf(geomBytes);
+
+        FdoGeometryType geomType = geom->GetDerivedType();
+        if (geomType != FdoGeometryType_Polygon)
+		    CPPUNIT_FAIL("Expected Polygon geometry for SpatialExtents() result");
+
+        envelopeAllWithoutFilterMultipleIds = geom->GetEnvelope();
+        if (envelopeAllWithoutFilterMultipleIds->GetIsEmpty())
+            CPPUNIT_FAIL("Expected non-empty envelope for SpatialExtents() result");
+
+        FdoInt64 mycount = rdr->GetInt64(L"MyCount");
+        CPPUNIT_ASSERT_MESSAGE("Wrong row count", 12 == mycount);
+
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+
+    rdr->Close();
+
+    // Compare the two "all" results to make sure they are equivalent:
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinX)", envelopeAllWithoutFilter->GetMinX() == envelopeAllWithoutFilterMultipleIds->GetMinX());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinY)", envelopeAllWithoutFilter->GetMinY() == envelopeAllWithoutFilterMultipleIds->GetMinY());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MinZ)", FdoCommonOSUtil::_isnan(envelopeAllWithoutFilter->GetMinZ()) && FdoCommonOSUtil::_isnan(envelopeAllWithoutFilterMultipleIds->GetMinZ()));
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxX)", envelopeAllWithoutFilter->GetMaxX() == envelopeAllWithoutFilterMultipleIds->GetMaxX());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxY)", envelopeAllWithoutFilter->GetMaxY() == envelopeAllWithoutFilterMultipleIds->GetMaxY());
+    CPPUNIT_ASSERT_MESSAGE("SpatialExtents results don't match (MaxZ)", FdoCommonOSUtil::_isnan(envelopeAllWithoutFilter->GetMaxZ()) && FdoCommonOSUtil::_isnan(envelopeAllWithoutFilterMultipleIds->GetMaxZ()));
+
+
+    // Create new empty SHP file :
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    conn->Close();
+    CreateEmptyShpFileWithConstraints(conn);
+
+
+    // Test the optimized case (no filter, no rows of data):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    selAggr = (FdoISelectAggregates*)conn->CreateCommand(FdoCommandType_SelectAggregates);
+    selAggr->SetFeatureClassName(L"MyClass");
+    ids = selAggr->GetPropertyNames();
+
+    expr = FdoExpression::Parse(L"SpatialExtents(Geom)");
+    cid = FdoComputedIdentifier::Create(L"MBR", expr);
+    ids->Add(cid);
+
+    ids->Add(FdoPtr<FdoIdentifier>(FdoComputedIdentifier::Create(L"MyCount",
+                FdoPtr<FdoExpression>(FdoExpression::Parse(L"Count(AREA)"))
+             )));
+
+    rdr = selAggr->Execute();
+    count = 0;
+    while (rdr->ReadNext())
+    {
+        CPPUNIT_ASSERT_MESSAGE("Expected NULL result from SpatialExtents with filter returning 0 rows", rdr->IsNull(L"MBR"));
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+
+    rdr->Close();
+
+
+    // Insert many rows of data, for performance tests :
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    const int PERF_TEST_NUM_ROWS = 4000;
+    clock_t start;
+    clock_t finish;
+    FdoPtr<FdoIFeatureReader> featRdr;
+
+    FdoPtr<FdoIInsert> ins = (FdoIInsert*)conn->CreateCommand(FdoCommandType_Insert);
+    ins->SetFeatureClassName(L"MyClass");
+    FdoPtr<FdoPropertyValueCollection> propVals = ins->GetPropertyValues();
+    FdoPtr<FdoFgfGeometryFactory> fgf = FdoFgfGeometryFactory::GetInstance();
+    double ordinates[2*2];  //2 XY coordinates
+    ordinates[0] =  10.0; ordinates[1] =  10.0;
+    ordinates[2] = 100.0; ordinates[3] = 100.0;
+    FdoPtr<FdoIGeometry> geom = fgf->CreateLineString(FdoDimensionality_XY, ELEMENTS(ordinates), ordinates);
+    FdoPtr<FdoByteArray> geomBytes = fgf->GetFgf(geom);
+    FdoPtr<FdoGeometryValue> geomVal = FdoGeometryValue::Create(geomBytes);
+    FdoPtr<FdoPropertyValue> propVal = FdoPropertyValue::Create(L"Geom", geomVal);
+    propVals->Add(propVal);
+    propVals->Add(FdoPtr<FdoPropertyValue>(FdoPropertyValue::Create(L"NotNullString", FdoPtr<FdoValueExpression>(FdoStringValue::Create(L"Some String")))));
+    for (int i=0; i<PERF_TEST_NUM_ROWS; i++)
+    {
+        FdoPtr<FdoPropertyValue> propVal = FdoPropertyValue::Create(L"Int32Range", FdoPtr<FdoValueExpression>(FdoInt32Value::Create(i)));
+        propVals->Add(propVal);
+        featRdr = ins->Execute();
+        featRdr->Close();
+        propVals->Remove(propVal);
+    }
+
+
+    // Test the optimized case for performance (no filter, PERF_TEST_NUM_ROWS rows of data):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    selAggr = (FdoISelectAggregates*)conn->CreateCommand(FdoCommandType_SelectAggregates);
+    selAggr->SetFeatureClassName(L"MyClass");
+    ids = selAggr->GetPropertyNames();
+
+    expr = FdoExpression::Parse(L"SpatialExtents(Geom)");
+    cid = FdoComputedIdentifier::Create(L"MBR", expr);
+    ids->Add(cid);
+    ids->Add(FdoPtr<FdoIdentifier>(FdoComputedIdentifier::Create(L"MyCount",
+                FdoPtr<FdoExpression>(FdoExpression::Parse(L"Count(AREA)"))
+             )));
+    start = clock();
+    rdr = selAggr->Execute();
+    count = 0;
+    while (rdr->ReadNext())
+    {
+        CPPUNIT_ASSERT_MESSAGE("Expected not-null result from SpatialExtents with filter returning all rows", !rdr->IsNull(L"MBR"));
+        FdoPtr<FdoByteArray> bytes = rdr->GetGeometry(L"MBR");
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+    rdr->Close();
+    finish = clock();
+
+    wprintf(L"Seconds to read SpatialExtents from SHP file containing %d records, using optimization: %g\n", PERF_TEST_NUM_ROWS, (double)(finish-start)/CLOCKS_PER_SEC);
+
+
+    // Test the non-optimized case for performance (no filter, PERF_TEST_NUM_ROWS rows of data):
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    selAggr = (FdoISelectAggregates*)conn->CreateCommand(FdoCommandType_SelectAggregates);
+    selAggr->SetFeatureClassName(L"MyClass");
+    selAggr->SetFilter(L"NotNullString != 'Garbage'");
+    ids = selAggr->GetPropertyNames();
+
+    expr = FdoExpression::Parse(L"SpatialExtents(Geom)");
+    cid = FdoComputedIdentifier::Create(L"MBR", expr);
+    ids->Add(cid);
+
+    start = clock();
+    rdr = selAggr->Execute();
+    count = 0;
+    while (rdr->ReadNext())
+    {
+        CPPUNIT_ASSERT_MESSAGE("Expected not-null result from SpatialExtents with filter returning all rows", !rdr->IsNull(L"MBR"));
+        FdoPtr<FdoByteArray> bytes = rdr->GetGeometry(L"MBR");
+        count++;
+    }
+    CPPUNIT_ASSERT_MESSAGE("Expected exactly one row of aggregate data", count==1);
+    rdr->Close();
+    finish = clock();
+
+    wprintf(L"Seconds to read SpatialExtents from SHP file containing %d records, using no optimization: %g\n", PERF_TEST_NUM_ROWS, (double)(finish-start)/CLOCKS_PER_SEC);
+
+
+    // Done all tests; let's clean up:
+    ////////////////////////////////////////////////////////////////////////////////////
+
+    conn->Close();    
+}

Modified: trunk/Providers/SDF/Src/UnitTest/MasterTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/MasterTest.h	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/MasterTest.h	2007-03-26 20:46:30 UTC (rev 2716)
@@ -63,6 +63,7 @@
 
 #include "cppunit/extensions/HelperMacros.h"
 #include "Fdo.h"
+#include "UnitTestUtil.h"
 
 // NOTE: Define __CPPUNIT_MFC_APP in order to have the CPPUNIT UI appear... 
 #ifdef __CPPUNIT_MFC_APP
@@ -78,6 +79,9 @@
 class MasterTest : public CppUnit::TestFixture
 {
     CPPUNIT_TEST_SUITE(MasterTest);
+	CPPUNIT_TEST(rtreeCacheTest); // Leave this test first as most of the other tests depend on insertTest
+	CPPUNIT_TEST(testConstraints); 
+	CPPUNIT_TEST(insertTest);
     CPPUNIT_TEST(rtreeFilter);
     CPPUNIT_TEST(spatialFilter);
     CPPUNIT_TEST(spatialInsideFilter);
@@ -94,9 +98,18 @@
     CPPUNIT_TEST(selectAggregatesFailureTests);
 	CPPUNIT_TEST(selectSpatialExtentsTest);
 	CPPUNIT_TEST(concurencyTest);
+	CPPUNIT_TEST(noGeomObject); 
+	CPPUNIT_TEST(numberFilter); 
+	CPPUNIT_TEST(inFilter); 
+	CPPUNIT_TEST(likeFilter);
+	CPPUNIT_TEST(orFilter);
+	CPPUNIT_TEST(dateFilter); 
+	CPPUNIT_TEST(concurencyRtreeTest);
     CPPUNIT_TEST(descReadOnly);
     CPPUNIT_TEST(test_aggregates_datetime_string);
 	CPPUNIT_TEST(selectFunctionTest);
+	CPPUNIT_TEST(testSpecialClassNames); 
+    CPPUNIT_TEST(selectAggregatesSpatialExtentsTest);
     CPPUNIT_TEST_SUITE_END();
 
     // You may define any private variables that are used in your test
@@ -114,7 +127,7 @@
 
     void setUp();
     void tearDown();
-
+	void insertTest() { UnitTestUtil::CreateData(true); }
     void deleteTest();
     void updateTest();
     void keyFilterBeforeDelete();
@@ -129,10 +142,24 @@
     void selectAggregatesTest();
     void selectAggregatesFailureTests();
 	void concurencyTest();
+	void concurencyRtreeTest();
     void selectSpatialExtentsTest();
     void descReadOnly();
     void test_aggregates_datetime_string();
 	void selectFunctionTest();
+
+	void rtreeCacheTest();
+	void testConstraints();
+	void noGeomObject();
+	void numberFilter();
+	void inFilter();
+	void likeFilter();
+	void orFilter();
+	void dateFilter();
+	void testSpecialClassNames();
+	void selectAggregatesSpatialExtentsTest();
+
+	void CreateEmptyShpFileWithConstraints(FdoIConnection* conn);
 };
 
 #endif

Modified: trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp	2007-03-26 20:46:30 UTC (rev 2716)
@@ -73,7 +73,7 @@
     try
     {
         FdoPtr<IConnectionManager> manager = FdoFeatureAccessManager::GetConnectionManager ();
-        FdoPtr<FdoIConnection> conn = manager->CreateConnection (L"OSGeo.SDF.3.2");
+        FdoPtr<FdoIConnection> conn = manager->CreateConnection (L"OSGeo.SDF.3.3");
 
         OpenConnection(conn, SDF_FILE_MG);
         

Modified: trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.cpp	2007-03-26 20:46:30 UTC (rev 2716)
@@ -1,3 +1,18 @@
+// Copyright (C) 2004-2007  Autodesk, Inc.
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#include <ctime>
 #include "UnitTestUtil.h"
 #include "FdoCommonFile.h"
 #include "SDF/SdfCommandType.h"
@@ -6,24 +21,98 @@
 #include <unistd.h>
 #endif
 
- //
- // Copyright (C) 2004-2006  Autodesk, Inc.
- // 
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of version 2.1 of the GNU Lesser
- // General Public License as published by the Free Software Foundation.
- // 
- // This library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- // Lesser General Public License for more details.
- // 
- // You should have received a copy of the GNU Lesser General Public
- // License along with this library; if not, write to the Free Software
- // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+const wchar_t* SOURCE_FILE = L"..\\..\\TestData\\PARCEL_linuxtest.SDX";
 
-FdoIConnection* UnitTestUtil::OpenConnection( FdoString* fileName, bool re_create )
+FdoFeatureSchema* CreateSDFSchema()
 {
+    FdoFeatureSchema* schema = FdoFeatureSchema::Create(L"SDF Schema",L"Schema of the Spatial Data File format");
+    FdoPtr<FdoFeatureClass> clas = FdoFeatureClass::Create(L"Parcel",L"");    
+    FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas);
+    FdoPtr<FdoPropertyDefinitionCollection> properties = clas->GetProperties();
+
+    FdoPtr<FdoGeometricPropertyDefinition> geometry = FdoGeometricPropertyDefinition::Create(
+                                                        L"Data",
+                                                        L"The geometry of the object");
+    geometry->SetGeometryTypes(7); // Point, Line, Polygon
+    properties->Add(geometry);
+
+    clas->SetGeometryProperty(geometry);
+
+    // Add a second geometry property (to test defect 670427).
+    FdoPtr<FdoGeometricPropertyDefinition> geometry2 = FdoGeometricPropertyDefinition::Create(
+                                                        L"Data2",
+                                                        L"The geometry of the object");
+    geometry2->SetGeometryTypes(7); // Point, Line, Polygon
+	geometry2->SetSpatialContextAssociation( L"World Geodetic Coordinate System, 1984" );
+    properties->Add(geometry2);
+
+    FdoPtr<FdoDataPropertyDefinition> dpd = FdoDataPropertyDefinition::Create(L"Name",
+                                                    L"The name of the object");
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"Url", L"The url of the object");
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+
+
+
+    dpd = FdoDataPropertyDefinition::Create(L"Key", L"The key of the object");
+    dpd->SetDataType(FdoDataType_String);
+    properties->Add(dpd);
+    FdoPtr<FdoDataPropertyDefinitionCollection>(clas->GetIdentityProperties())->Add(dpd);
+
+    dpd = FdoDataPropertyDefinition::Create(L"ID", L"The autogenerated sequence ID of the object");
+    dpd->SetDataType(FdoDataType_Int32);
+    dpd->SetIsAutoGenerated(true);
+    properties->Add(dpd);
+    FdoPtr<FdoDataPropertyDefinitionCollection>(clas->GetIdentityProperties())->Add(dpd);
+
+
+    FdoPtr<FdoFeatureClass> clas2 = FdoFeatureClass::Create(L"ParcelChild",L"");    
+    clas2->SetBaseClass(clas);
+	properties = clas2->GetProperties();
+
+	dpd = FdoDataPropertyDefinition::Create(L"Numb", L"A number property");
+    dpd->SetDataType(FdoDataType_Int32);
+    properties->Add(dpd);
+
+	dpd = FdoDataPropertyDefinition::Create(L"datetime", L"A date time property");
+    dpd->SetDataType(FdoDataType_DateTime);
+    properties->Add(dpd);
+
+	dpd = FdoDataPropertyDefinition::Create(L"DblNumb1", L"A double number property(1)");
+    dpd->SetDataType(FdoDataType_Double);
+    properties->Add(dpd);
+
+	dpd = FdoDataPropertyDefinition::Create(L"DblNumb2", L"A double number property(2)");
+    dpd->SetDataType(FdoDataType_Double);
+    properties->Add(dpd);
+
+//    clas2->SetGeometryProperty(geometry);
+//    FdoPtr<FdoDataPropertyDefinitionCollection>(clas2->GetIdentityProperties())->Add(dpd);
+
+    FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas2);
+
+	clas = FdoFeatureClass::Create(L"AbsClass",L"");    
+    FdoPtr<FdoClassCollection>(schema->GetClasses())->Add(clas);
+    clas->SetIsAbstract( true );
+    properties = clas->GetProperties();
+	dpd = FdoDataPropertyDefinition::Create(L"Numb", L"A number property");
+    dpd->SetDataType(FdoDataType_Int32);
+    properties->Add(dpd);
+
+    return schema;
+}
+
+FdoIConnection* UnitTestUtil::CreateConnection()
+{
+    FdoPtr<IConnectionManager> manager = FdoFeatureAccessManager::GetConnectionManager ();
+    return (manager->CreateConnection (L"OSGeo.SDF.3.3"));
+}
+
+FdoIConnection* UnitTestUtil::OpenConnection(  FdoString* fileName, bool re_create, FdoIConnection  *inConn)
+{
 #ifdef _WIN32
 	wchar_t fullpath[1024];
 	_wfullpath(fullpath, fileName, 1024);
@@ -36,24 +125,43 @@
 	mbstowcs(fullpath, cfullpath, 1024);
 #endif
 
-    FdoPtr<IConnectionManager> manager = FdoFeatureAccessManager::GetConnectionManager ();
-    FdoIConnection *conn = manager->CreateConnection (L"OSGeo.SDF.3.3");
+    FdoIConnection *conn = inConn;
+	if( conn == NULL )
+		conn = UnitTestUtil::CreateConnection();
 	if( re_create )
 	{
-        FdoCommonFile::Delete(fileName, true);
+		// Clean up the existing file
+        FdoCommonFile::Delete(fullpath, true);
 
-		FdoPtr<FdoICreateSDFFile> crsdf = (FdoICreateSDFFile*)(conn->CreateCommand(SdfCommandType_CreateSDFFile));
+		// Crate the SDF file
+		FdoPtr<FdoICreateDataStore>	pCreateCmd = (FdoICreateDataStore*) conn->CreateCommand(FdoCommandType_CreateDataStore);
+		FdoPtr<FdoIDataStorePropertyDictionary> dictionary = pCreateCmd->GetDataStoreProperties();
+		int	count;
+		FdoString **names = dictionary->GetPropertyNames(count);
+		CPPUNIT_ASSERT_MESSAGE("Wrong number of properties for create cmd", count==1 );
+		dictionary->SetProperty( names[0], fullpath );
+		pCreateCmd->Execute();	
 
-		crsdf->SetCoordinateSystemWKT(L"[LL84]");
-		crsdf->SetFileName(fullpath);
-		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);
+		// Open the connection
+		std::wstring connStr = std::wstring(L"File=") + std::wstring(fullpath);
+		conn->SetConnectionString(connStr.c_str());
+		FdoPtr<FdoIConnectionInfo>info = conn->GetConnectionInfo();
+		FdoPtr<FdoIConnectionPropertyDictionary> prop = info->GetConnectionProperties();
+		conn->Open();
 
-		crsdf->Execute();
+		// Create spatial context
+		FdoPtr<FdoICreateSpatialContext>	pCreateCreateSpatialContext = (FdoICreateSpatialContext*) conn->CreateCommand(FdoCommandType_CreateSpatialContext);
+		pCreateCreateSpatialContext->SetCoordinateSystemWkt(L"[LL84]");
+		pCreateCreateSpatialContext->SetDescription(L"World Coordinate System, Degrees, what else do you need to know?" );
+		pCreateCreateSpatialContext->SetName( L"World Geodetic Coordinate System, 1984" );
+		pCreateCreateSpatialContext->SetXYTolerance( 17.0 );
+		pCreateCreateSpatialContext->SetZTolerance(3.14159);
+		pCreateCreateSpatialContext->Execute();
 
+		return conn;
 	}
+
+	// Just open the connection
     std::wstring connStr = std::wstring(L"File=") + std::wstring(fullpath);
     conn->SetConnectionString(connStr.c_str());
     FdoPtr<FdoIConnectionInfo>info = conn->GetConnectionInfo();
@@ -206,3 +314,176 @@
 
     fclose( fp );
 }
+
+void UnitTestUtil::CreateData( bool create, FdoIConnection  *inConn, int featCount, FdoString* className, int threadId  )
+{
+    //first delete the destination file if it exists already -- cleanup that is
+	FdoPtr<FdoIConnection> conn;
+	if( inConn != NULL )
+	{
+		inConn->AddRef();
+		conn = inConn;
+	}
+
+    if( create )
+	{
+		try
+		{
+			if( conn == NULL )
+				conn = UnitTestUtil::CreateConnection();
+
+			UnitTestUtil::OpenConnection( DESTINATION_FILE, true, conn );
+			 //apply schema
+			FdoPtr<FdoIApplySchema> applyschema = (FdoIApplySchema*)conn->CreateCommand(FdoCommandType_ApplySchema);
+			FdoPtr<FdoFeatureSchema> schema = CreateSDFSchema();
+			applyschema->SetFeatureSchema(schema);
+			applyschema->Execute();
+		}
+		catch(FdoException *exp )
+		{
+			PrintException( exp, stdout, false);
+			CPPUNIT_FAIL("Insert failed");
+		}
+	}
+    else if( inConn == NULL || inConn->GetConnectionState() != FdoConnectionState_Open )
+        conn = UnitTestUtil::OpenConnection(DESTINATION_FILE, false);    
+
+    //try out describe schema
+    FdoPtr<FdoIDescribeSchema> desc = (FdoIDescribeSchema*)conn->CreateCommand(FdoCommandType_DescribeSchema);
+    FdoPtr<FdoFeatureSchemaCollection> schemas = desc->Execute();
+    FdoPtr<FdoFeatureSchema> schema2 = schemas->GetItem(0);
+    FdoPtr<FdoClassCollection> ccol = schema2->GetClasses();
+    FdoPtr<FdoClassDefinition> cdef = ccol->GetItem(L"Parcel");
+    FdoPtr<FdoPropertyDefinitionCollection> pdc = cdef->GetProperties();
+    FdoPtr<FdoPropertyDefinition> pd = pdc->GetItem(L"ID");
+    CPPUNIT_ASSERT(((FdoDataPropertyDefinition*)(pd.p))->GetReadOnly());
+    FdoPtr<FdoClassCapabilities> caps = cdef->GetCapabilities();
+    CPPUNIT_ASSERT(caps->SupportsLocking() == false);
+    CPPUNIT_ASSERT(caps->SupportsLongTransactions() == false);
+    
+	FdoPtr<FdoPropertyDefinition> gpd = pdc->GetItem(L"Data2");
+    CPPUNIT_ASSERT_MESSAGE("Expected a geometry property type", gpd->GetPropertyType() == FdoPropertyType_GeometricProperty );
+	FdoGeometricPropertyDefinition *geom = (FdoGeometricPropertyDefinition*)gpd.p;
+	CPPUNIT_ASSERT_MESSAGE("Expected a not null geometry property Spatial context", geom->GetSpatialContextAssociation() != NULL );
+
+	cdef = ccol->GetItem(L"AbsClass");
+	CPPUNIT_ASSERT_MESSAGE("Expected an abstract class", cdef->GetIsAbstract() );
+
+    //set up the insert command
+    //we will execute it multiple times with different property values
+    FdoPtr<FdoIInsert> insert = (FdoIInsert*)conn->CreateCommand(FdoCommandType_Insert);
+
+    FdoPtr<FdoPropertyValueCollection> propvals = insert->GetPropertyValues();
+
+    FdoPtr<FdoStringValue> svname = FdoStringValue::Create(L"");
+    FdoPtr<FdoStringValue> svkey = FdoStringValue::Create(L"");
+    FdoPtr<FdoStringValue> svurl = FdoStringValue::Create(L"");
+	FdoPtr<FdoInt32Value> svNumb = FdoInt32Value::Create();
+
+    FdoPtr<FdoGeometryValue> gvgeom = FdoGeometryValue::Create(NULL);
+    FdoPtr<FdoGeometryValue> gvgeom2 = FdoGeometryValue::Create(NULL);
+
+    FdoPtr<FdoPropertyValue> pvname = FdoPropertyValue::Create(L"Name", svname);
+    FdoPtr<FdoPropertyValue> pvkey = FdoPropertyValue::Create(L"Key", svkey);
+	FdoPtr<FdoPropertyValue> pvurl = FdoPropertyValue::Create(L"Url", svurl);
+    FdoPtr<FdoPropertyValue> pvgeom = FdoPropertyValue::Create(L"Data", gvgeom);
+    FdoPtr<FdoPropertyValue> pvgeom2 = FdoPropertyValue::Create(L"Data2", gvgeom2);
+
+	FdoPtr<FdoPropertyValue> pvNumb = FdoPropertyValue::Create(L"Numb", svNumb);
+
+	FdoDateTime dt(2006,4,21,19,40,10.0001);
+	FdoPtr<FdoDateTimeValue> dtv = FdoDateTimeValue::Create(dt);
+	FdoPtr<FdoPropertyValue> pvDateTime = FdoPropertyValue::Create(L"datetime", dtv);
+
+    propvals->Add(pvname);
+    propvals->Add(pvkey);
+    propvals->Add(pvurl);
+    propvals->Add(pvgeom);
+    propvals->Add(pvgeom2);
+
+	if( className == NULL )
+		insert->SetFeatureClassName(L"Parcel");  
+	else
+	{
+		propvals->Add(pvNumb);
+		propvals->Add(pvDateTime);
+		insert->SetFeatureClassName(className);
+	}
+
+	clock_t start;
+    clock_t finish;
+	if( threadId == -1 )
+		start = clock ();
+
+	FdoPtr<FdoIConnection> shpConn = UnitTestUtil::OpenConnection( SOURCE_FILE, false, NULL );
+	FdoPtr<FdoISelect> select = (FdoISelect*)shpConn->CreateCommand (FdoCommandType_Select);
+    select->SetFeatureClassName (L"DaKlass");
+	FdoPtr<FdoIFeatureReader> shpReader = select->Execute();
+
+	int count = 1;
+	int numbProp = 100;
+	char tmp[32];
+	while( shpReader->ReadNext() )
+	{
+		if( ! shpReader->IsNull(L"Data") )
+		{
+			gvgeom->SetGeometry( FdoPtr<FdoByteArray>( shpReader->GetGeometry(L"Data") ) );
+			gvgeom2->SetGeometry( FdoPtr<FdoByteArray>( shpReader->GetGeometry(L"Data") ) ); 
+		}
+		else
+		{
+			gvgeom->SetGeometry( NULL );
+			gvgeom2->SetGeometry( NULL );
+		}
+		if( ! shpReader->IsNull(L"Name") )
+			svname->SetString( shpReader->GetString(L"Name") );
+		else
+			svname->SetString( L"" );
+
+		if( ! shpReader->IsNull(L"Key") )
+			svkey->SetString( shpReader->GetString(L"Key") );
+		else
+			svkey->SetString( L"" );
+
+		if( ! shpReader->IsNull(L"Url") )
+			svurl->SetString( shpReader->GetString(L"Url") );
+		else
+			svurl->SetString( L"" );
+
+		dt.minute = numbProp%60;
+		dtv->SetDateTime( dt );
+		svNumb->SetInt32( numbProp++ );
+
+        FdoPtr<FdoIFeatureReader> rdr = insert->Execute();
+        if ( (count % 1000) == 0 && threadId == -1)
+        {
+            for(unsigned int i=0;i<strlen(tmp);i++)putchar(8);
+            sprintf(tmp,"Count = %d",count);
+            printf(tmp);
+
+            rdr->ReadNext();
+            int id = rdr->GetInt32(L"ID");
+            if( create )
+            {
+                CPPUNIT_ASSERT(id == count);
+            }
+            //printf("Testing autogen ID = 1 + count: %d\n", id);
+        }
+	   count++;
+       if( featCount != -1 && count>featCount )
+			break;
+    };
+
+    conn->Flush();
+
+    if( threadId == -1 )
+	{
+		for(unsigned int i=0;i<strlen(tmp);i++)putchar(8);
+		sprintf(tmp,"Count = %d",count);
+		printf(tmp);
+		finish = clock ();
+		printf ("  time: %2.3f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC);
+	}
+	if( inConn == NULL )
+		conn->Close();
+}

Modified: trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h	2007-03-26 20:42:50 UTC (rev 2715)
+++ trunk/Providers/SDF/Src/UnitTest/UnitTestUtil.h	2007-03-26 20:46:30 UTC (rev 2716)
@@ -25,6 +25,7 @@
 #include <Fdo.h>
 #include <TestCommonMiscUtil.h>
 #include <TestCommonFileUtil.h>
+#define DESTINATION_FILE L"..\\..\\TestData\\PARCELS.SDF"
 
 /* 
  * A test case for ApplySchemaCommand.
@@ -36,8 +37,10 @@
 {
 
 public:
-    static FdoIConnection* OpenConnection( FdoString* fileName, bool re_create );
+	static FdoIConnection* CreateConnection();
 
+    static FdoIConnection* OpenConnection( FdoString* fileName, bool re_create, FdoIConnection  *inConn = NULL );
+
     static void ExportDb( 
         FdoIConnection* connection, 
         FdoIoStream* stream, 
@@ -50,6 +53,8 @@
 
     // Print an exception, and all it's cause exceptions to the given file.
     static void PrintException( FdoException* e, const char* fileName, FdoBoolean stripLineNo = false );
+
+	static void CreateData( bool create,FdoIConnection  *inConn = NULL/* open a new connection*/, int featCount = -1/* all */, FdoString* className=NULL, int threadId = -1 );
 };
 
 #endif

Added: trunk/Providers/SDF/TestData/HYDRANTSMULTIGEOM.sdf
===================================================================
(Binary files differ)


Property changes on: trunk/Providers/SDF/TestData/HYDRANTSMULTIGEOM.sdf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream



More information about the fdo-commits mailing list