[fdo-commits] r752 - branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc

svn_fdo at osgeo.org svn_fdo at osgeo.org
Wed Feb 14 18:30:16 EST 2007


Author: gavincramer
Date: 2007-02-14 18:30:16 -0500 (Wed, 14 Feb 2007)
New Revision: 752

Modified:
   branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
   branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
   branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h
Log:
ODBC: Primary keys in views

Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2007-02-14 23:28:52 UTC (rev 751)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2007-02-14 23:30:16 UTC (rev 752)
@@ -346,6 +346,8 @@
 	L"( FEATID1, NAME, X, Y )",
 	L" values ",
 	L"( 2, 'His''Name', 20, 25 );",
+    L"",
+	L"create view VIEW1 as select FEATID1, NAME, X, Y from TABLE1;",
 #ifdef _WIN32
     L"",
 	L"create table ALLDBTYPES (",

Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2007-02-14 23:28:52 UTC (rev 751)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2007-02-14 23:30:16 UTC (rev 752)
@@ -144,6 +144,55 @@
     }
 }
 
+void OdbcOracleFdoSelectTest::View1Test()
+{
+    if( mConnection != NULL )
+    {
+        try
+        {
+            FdoPtr<FdoISelect> selectCmd = (FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);
+
+            selectCmd->SetFeatureClassName(L"VIEW1");
+
+            FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
+
+            FdoPtr<FdoClassDefinition> classDef = reader->GetClassDefinition();
+            CPPUNIT_ASSERT_MESSAGE("Class should not have IsComputed=true", !classDef->GetIsComputed());
+            FdoFeatureSchemaP pSchema =  classDef->GetFeatureSchema(); 
+            FdoPtr<FdoDataPropertyDefinitionCollection> idPropDefs = classDef->GetIdentityProperties();
+            FdoInt32 numIdProps = 0;
+            if (idPropDefs != NULL)
+            {
+                numIdProps = idPropDefs->GetCount();
+                for (FdoInt32 i=0;  i < numIdProps;  i++)
+                {
+                    FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
+                    printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                }
+                printf("  Found total %d identity properties.\n", numIdProps);
+                CPPUNIT_ASSERT_MESSAGE("Expected no identity properties", 0==numIdProps);
+            }
+
+            // read through all the features
+            int numFeatures = 0;
+            while (reader->ReadNext())
+            {
+                numFeatures++;
+                UnitTestUtil::ProcessFeature(reader);
+            }
+
+            printf("   %i feature(s) read\n", numFeatures);
+
+            // close the reader
+            reader->Close();
+        }
+        catch (FdoException* e)
+        {
+            TestCommonFail (e);
+        }
+    }
+}
+
 void OdbcMySqlFdoSelectTest::ConfigFileTest()
 {
     if( mConnection != NULL ) try
@@ -454,6 +503,114 @@
     }
 }
 
+void OdbcAccessFdoSelectTest::View1Test()
+{
+    if( mConnection != NULL )
+    {
+        try
+        {
+            FdoPtr<FdoISelect> selectCmd = (FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);
+
+            // must set the feature class name
+            FdoStringP fcn = GetSchemaName();
+            fcn += L":";
+            fcn += L"VIEW1";
+            selectCmd->SetFeatureClassName(fcn);
+
+            // execute the command
+            FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
+
+            FdoPtr<FdoClassDefinition> classDef = reader->GetClassDefinition();
+            CPPUNIT_ASSERT_MESSAGE("Class should not have IsComputed=true", !classDef->GetIsComputed());
+            FdoFeatureSchemaP pSchema =  classDef->GetFeatureSchema(); 
+            FdoPtr<FdoDataPropertyDefinitionCollection> idPropDefs = classDef->GetIdentityProperties();
+            FdoInt32 numIdProps = 0;
+            if (idPropDefs != NULL)
+            {
+                numIdProps = idPropDefs->GetCount();
+                for (FdoInt32 i=0;  i < numIdProps;  i++)
+                {
+                    FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
+                    printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                }
+                printf("  Found total %d identity properties.\n", numIdProps);
+                CPPUNIT_ASSERT_MESSAGE("Expected no identity properties", 0==numIdProps);
+            }
+
+            // read through all the features
+            int numFeatures = 0;
+            while (reader->ReadNext())
+            {
+                numFeatures++;
+                UnitTestUtil::ProcessFeature(reader);
+            }
+
+            printf("   %i feature(s) read\n", numFeatures);
+
+            // close the reader
+            reader->Close();
+        }
+        catch (FdoException* e)
+        {
+            TestCommonFail (e);
+        }
+    }
+}
+
+void OdbcAccessFdoSelectTest::View2Test()
+{
+    if( mConnection != NULL )
+    {
+        try
+        {
+            FdoPtr<FdoISelect> selectCmd = (FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);
+
+            // must set the feature class name
+            FdoStringP fcn = GetSchemaName();
+            fcn += L":";
+            fcn += L"VIEW2";
+            selectCmd->SetFeatureClassName(fcn);
+
+            // execute the command
+            FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
+
+            FdoPtr<FdoClassDefinition> classDef = reader->GetClassDefinition();
+            CPPUNIT_ASSERT_MESSAGE("Class should not have IsComputed=true", !classDef->GetIsComputed());
+            FdoFeatureSchemaP pSchema =  classDef->GetFeatureSchema(); 
+            FdoPtr<FdoDataPropertyDefinitionCollection> idPropDefs = classDef->GetIdentityProperties();
+            FdoInt32 numIdProps = 0;
+            if (idPropDefs != NULL)
+            {
+                numIdProps = idPropDefs->GetCount();
+                for (FdoInt32 i=0;  i < numIdProps;  i++)
+                {
+                    FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
+                    printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                }
+                printf("  Found total %d identity properties.\n", numIdProps);
+                CPPUNIT_ASSERT_MESSAGE("Expected 1 identity property", 1==numIdProps);
+            }
+
+            // read through all the features
+            int numFeatures = 0;
+            while (reader->ReadNext())
+            {
+                numFeatures++;
+                UnitTestUtil::ProcessFeature(reader);
+            }
+
+            printf("   %i feature(s) read\n", numFeatures);
+
+            // close the reader
+            reader->Close();
+        }
+        catch (FdoException* e)
+        {
+            TestCommonFail (e);
+        }
+    }
+}
+
 void OdbcAccessFdoSelectTest::TestDefect779194()
 {
     if( mConnection != NULL )

Modified: branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h	2007-02-14 23:28:52 UTC (rev 751)
+++ branches/3.2.x/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h	2007-02-14 23:30:16 UTC (rev 752)
@@ -53,6 +53,7 @@
 class OdbcOracleFdoSelectTest : public OdbcFdoSelectTest
 {
     CPPUNIT_TEST_SUB_SUITE (OdbcOracleFdoSelectTest, OdbcFdoSelectTest);
+    CPPUNIT_TEST (View1Test);
     CPPUNIT_TEST_SUITE_END ();
 
 public:
@@ -85,6 +86,8 @@
 
         TestCommonFeatureCommands::secondComputedIdTest(mConnection, fcn, L"CLASSID");
     }
+
+    virtual void View1Test();
 };
 
 class OdbcMySqlFdoSelectTest : public OdbcFdoSelectTest
@@ -137,7 +140,9 @@
     CPPUNIT_TEST_SUB_SUITE (OdbcAccessFdoSelectTest, OdbcFdoSelectTest);
     CPPUNIT_TEST (TestDefect889655);
     CPPUNIT_TEST (Table1Test);
-    //CPPUNIT_TEST (Table2Test);
+    CPPUNIT_TEST (Table2Test);
+    CPPUNIT_TEST (View1Test);
+    CPPUNIT_TEST (View2Test);
     CPPUNIT_TEST (ComparisonFilterTable1Test);
     CPPUNIT_TEST (RestrictedPropertiesTable1Test);
     CPPUNIT_TEST (TestDateFilter);
@@ -150,6 +155,8 @@
     virtual void Table1Test();
     virtual void TestDefect889655();
     void Table2Test();
+    void View1Test();
+    void View2Test();
     void ComparisonFilterTable1Test();  // Contains a spatial query
     void RestrictedPropertiesTable1Test();
     void TestDefect779194();



More information about the fdo-commits mailing list