[fdo-commits] r745 -
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Wed Feb 14 12:05:54 EST 2007
Author: brentrobinson
Date: 2007-02-14 12:05:54 -0500 (Wed, 14 Feb 2007)
New Revision: 745
Added:
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.h
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.h
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoSelectTest.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.h
Modified:
branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisConnectionUtil.cpp
Log:
PostGis GenericRdbms Post-Mortem: Got main feature command unit tests running for FDO-enabled and non FDO-enabled datastores.
Modified: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisConnectionUtil.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisConnectionUtil.cpp 2007-02-14 17:02:54 UTC (rev 744)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisConnectionUtil.cpp 2007-02-14 17:05:54 UTC (rev 745)
@@ -19,12 +19,7 @@
#include "Pch.h"
#include "PostGisConnectionUtil.h"
#include "UnitTestUtil.h"
-/*
-
- TODO: mloskot - to be uncommented.
-
#include "PostGisFdoInsertTest.h"
-*/
#include "../../PostGIS/SchemaMgr/SchemaManager.h"
#include "../../PostGIS/SchemaMgr/Ph/Mgr.h"
#include <FdoCommonFile.h>
@@ -227,9 +222,7 @@
FdoInsertTest* PostGisConnectionUtil::GetInsertTest()
{
- // TODO: Add insert test
- // return new PostGisFdoInsertTest();
- return NULL;
+ return new PostGisFdoInsertTest();
}
FdoStringP PostGisConnectionUtil::GetOutputFileName (FdoString* pBaseFileName)
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.cpp (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.cpp 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ */
+
+#include "Pch.h"
+#include "PostGisFdoDeleteTest.h"
+#include "UnitTestUtil.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PostGisFdoDeleteTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PostGisFdoDeleteTest, "FdoDeleteTest");
+
+void PostGisFdoDeleteTest::set_provider()
+{
+ UnitTestUtil::SetProvider( "PostGIS" );
+}
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.h
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.h (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoDeleteTest.h 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,32 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef POSTGIS_FDODELETETEST_H
+#define POSTGIS_FDODELETETEST_H
+
+#include "FdoDeleteTest.h"
+
+class PostGisFdoDeleteTest : public FdoDeleteTest
+{
+ CPPUNIT_TEST_SUB_SUITE (PostGisFdoDeleteTest, FdoDeleteTest);
+ CPPUNIT_TEST_SUITE_END ();
+
+ void set_provider();
+};
+
+#endif // PostGis_FDODELETETEST_H
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.cpp (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.cpp 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,306 @@
+/*
+ * 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
+ *
+ */
+
+#include "Pch.h"
+#include "PostGisFdoInsertTest.h"
+#include "UnitTestUtil.h"
+#include "ConnectionUtil.h"
+#include "PostGisConnectionUtil.h"
+
+#define UNSIGNED_SUFFIX L"_unsigned"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PostGisFdoInsertTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PostGisFdoInsertTest, "FdoInsertTest");
+
+void PostGisFdoInsertTest::set_provider()
+{
+ UnitTestUtil::SetProvider( "PostGIS" );
+}
+
+void PostGisFdoInsertTest::insertDate ()
+{
+ wprintf(L"InsertDate: Test insert command with different date/time settings.\n");
+ FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(mSuffix, true);
+
+ int baseColorIndex = 990,
+ numberTestCases = 9;
+ bool exceptionExpected = false;
+ FdoStringP colorIndex;
+ FdoDateTime dateTime;
+
+ for (int j = 0; j < numberTestCases; j++)
+ {
+ // Reinitialize the date-time object as defined by the constructor.
+
+ dateTime.year = -1;
+ dateTime.month = -1;
+ dateTime.day = -1;
+ dateTime.hour = -1;
+ dateTime.minute = -1;
+ dateTime.seconds = 0.0f;;
+
+ colorIndex = FdoStringP::Format(L"%d", (baseColorIndex+j));
+ switch (j)
+ {
+ case 0:
+ wprintf(L" > (1) No date or time specification: should fail.\n");
+ exceptionExpected = true;
+ break;
+
+ case 1:
+ wprintf(L" > (2)Complete date, but no time specification: should work.\n");
+ dateTime.year = 2003;
+ dateTime.month = 1;
+ dateTime.day = 1;
+ exceptionExpected = false;
+ break;
+
+ case 2:
+ wprintf(L" > (3) Complete time, but no date specification: should work.\n");
+ dateTime.hour = 1;
+ dateTime.minute = 11;
+ dateTime.seconds = 0;
+ exceptionExpected = false;
+ break;
+
+ case 3:
+ wprintf(L" > (4) Complete date and time specification: should work.\n");
+ dateTime.year = 2003;
+ dateTime.month = 1;
+ dateTime.day = 1;
+ dateTime.hour = 1;
+ dateTime.minute = 11;
+ dateTime.seconds = 11;
+ exceptionExpected = false;
+ break;
+
+ case 4:
+ wprintf(L" > (5) Partial date, but no time specification: should fail.\n");
+ dateTime.year = 2003;
+ dateTime.day = 1;
+ exceptionExpected = true;
+ break;
+
+ case 5:
+ wprintf(L" > (6) Partial time, but no date specification: should fail.\n");
+ dateTime.hour = 1;
+ dateTime.seconds = 0;
+ exceptionExpected = true;
+ break;
+
+ case 6:
+ wprintf(L" > (7) Partial date and time specification: should fail.\n");
+ dateTime.year = 2003;
+ dateTime.day = 1;
+ dateTime.hour = 1;
+ dateTime.seconds = 0;
+ exceptionExpected = true;
+ break;
+
+ case 7:
+ wprintf(L" > (8) Partial date and complete time specification: should fail.\n");
+ dateTime.year = 2003;
+ dateTime.day = 1;
+ dateTime.hour = 1;
+ dateTime.minute = 11;
+ dateTime.seconds = 0;
+ exceptionExpected = true;
+ break;
+
+ case 8:
+ wprintf(L" > (9) Partial time and complete date specification: should fail.\n");
+ dateTime.year = 2003;
+ dateTime.month = 1;
+ dateTime.day = 1;
+ dateTime.hour = 1;
+ dateTime.seconds = 0;
+ exceptionExpected = true;
+ break;
+
+ }
+
+ // Attempt to insert a record using the constructed date-time object.
+ try
+ {
+ FdoInsertTest::insertDate(connection, dateTime, colorIndex);
+ }
+
+ catch (FdoException *ex)
+ {
+ if (!exceptionExpected)
+ {
+ wprintf(L" Unexpected Exception: %ls\n", ex->GetExceptionMessage());
+ connection->Close();
+ throw ex;
+ }
+
+ wchar_t expectedErrMsg[] = L"Incomplete date/time setting. ";
+ FdoString *excMsg = ex->GetExceptionMessage();
+ // eliminate a space from the end if is the case
+ if (excMsg[wcslen(excMsg) - 1] != L' ')
+ expectedErrMsg[wcslen(expectedErrMsg)-1] = L'\0';
+
+ if ((wcscmp(excMsg, expectedErrMsg)) != 0)
+ {
+ wprintf(L" Unexpected Exception: %ls\n", ex->GetExceptionMessage());
+ connection->Close();
+ throw ex;
+ }
+ else
+ wprintf(L" Expected Exception: %ls\n", ex->GetExceptionMessage());
+ }
+
+ catch ( ... )
+ {
+ wprintf(L" Unexpected Exception in insertDate()\n");
+ connection->Close();
+ throw;
+ }
+
+ }
+
+ wprintf(L" > Test Verification.\n");
+ insertDateVerification(connection, 3);
+
+ wprintf(L" > Test Cleanup.\n");
+ FdoInsertTest::insertDateCleanUp(connection);
+
+ connection->Close();
+}
+
+void PostGisFdoInsertTest::insertBoundaryUnsigned()
+{
+ StaticConnection* conn = new PostGisStaticConnection();
+
+ try {
+
+ UnitTestUtil::SetProvider( conn->GetServiceName() );
+
+ conn->connect();
+
+ FdoSchemaManagerP mgr = conn->CreateSchemaManager();
+
+ FdoSmPhMgrP phMgr = mgr->GetPhysicalSchema();
+
+ FdoStringP datastore = phMgr->GetDcOwnerName(
+ FdoStringP::Format(
+ L"%hs",
+ UnitTestUtil::GetEnviron("datastore", UNSIGNED_SUFFIX)
+ )
+ );
+
+ FdoSmPhDatabaseP database = phMgr->GetDatabase();
+
+ FdoSmPhOwnerP owner = phMgr->FindOwner( datastore, L"", false );
+ if ( owner ) {
+ owner->SetElementState( FdoSchemaElementState_Deleted );
+ owner->Commit();
+ }
+
+ owner = database->CreateOwner(
+ datastore,
+ false
+ );
+ owner->SetPassword( L"test" );
+
+ FdoStringP tableName = L"unsigned_test";
+
+ FdoSmPhTableP table = owner->CreateTable( tableName );
+ table->SetPkeyName( tableName + L"_key" );
+ FdoSmPhColumnP column = table->CreateColumnInt32(
+ L"id",
+ false
+ );
+ table->AddPkeyCol( column->GetName() );
+ column = table->CreateColumnUnknown(
+ L"uint_column",
+ L"int unsigned",
+ false,
+ 0,
+ 0
+ );
+ owner->Commit();
+
+ phMgr = NULL;
+ mgr = NULL;
+ conn->disconnect();
+ delete conn;
+
+ FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(UNSIGNED_SUFFIX, false);
+ FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction();
+ FdoIInsert *insertCommand = (FdoIInsert *) connection->CreateCommand(FdoCommandType_Insert);
+ insertCommand->SetFeatureClassName(tableName);
+ FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues();
+
+ FdoPtr<FdoDataValue> dataValue;
+ dataValue = FdoDataValue::Create(L"1");
+ FdoPtr<FdoPropertyValue> propertyValue = AddNewProperty( propertyValues, L"id");
+ propertyValue->SetValue(dataValue);
+
+ dataValue = FdoDataValue::Create(L"0");
+ propertyValue = AddNewProperty( propertyValues, L"uint_column");
+ propertyValue->SetValue(dataValue);
+
+ FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute();
+
+ dataValue = FdoDataValue::Create(L"2");
+ propertyValue = AddNewProperty( propertyValues, L"id");
+ propertyValue->SetValue(dataValue);
+
+ dataValue = FdoDataValue::Create(L"4294967295");
+ propertyValue = AddNewProperty( propertyValues, L"uint_column");
+ propertyValue->SetValue(dataValue);
+
+ reader = insertCommand->Execute();
+
+ featureTransaction->Commit();
+ insertCommand->Release();
+
+ // check
+ FdoISelect* selectCmd = (FdoISelect *) connection->CreateCommand(FdoCommandType_Select);
+ selectCmd->SetFeatureClassName(tableName);
+
+ FdoPtr<FdoIFeatureReader> featureReader = selectCmd->Execute();
+ FdoInt32 rowCount = 0;
+
+ while ( featureReader->ReadNext() ) {
+ rowCount++;
+
+ switch ( featureReader->GetInt32(L"id") ) {
+ case 1:
+ CPPUNIT_ASSERT ( featureReader->GetInt64(L"uint_column") == 0 );
+ break;
+
+ case 2:
+ CPPUNIT_ASSERT ( featureReader->GetInt64(L"uint_column") == 4294967295LL);
+ break;
+ }
+ }
+
+ CPPUNIT_ASSERT( rowCount == 2 );
+ }
+ catch (FdoCommandException *ex)
+ {
+ UnitTestUtil::FailOnException(ex);
+ }
+ catch (FdoException *ex)
+ {
+ UnitTestUtil::FailOnException(ex);
+ }
+}
+
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.h
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.h (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoInsertTest.h 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,38 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef POSTGIS_INSERTTESTS_H
+#define POSTGIS_INSERTTESTS_H
+
+#include "FdoInsertTest.h"
+
+class PostGisFdoInsertTest : public FdoInsertTest
+{
+ CPPUNIT_TEST_SUB_SUITE (PostGisFdoInsertTest, FdoInsertTest);
+ CPPUNIT_TEST( insertBoundaryUnsigned );
+ CPPUNIT_TEST_SUITE_END ();
+
+ void set_provider();
+ void insertDate ();
+public:
+ virtual void conditionalInsert() { }
+ virtual void insertBoundaryUnsigned();
+};
+
+
+#endif // PostGis_INSERTTESTS_H
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoSelectTest.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoSelectTest.cpp (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoSelectTest.cpp 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ */
+
+#include "Pch.h"
+#include "PostGisFdoSelectTest.h"
+#include "UnitTestUtil.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PostGisFdoSelectTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PostGisFdoSelectTest, "FdoSelectTest");
+
+void PostGisFdoSelectTest::set_provider()
+{
+ UnitTestUtil::SetProvider( "PostGIS" );
+}
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.cpp (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.cpp 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,225 @@
+/*
+ * 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
+ *
+ */
+
+#include "Pch.h"
+#include "PostGisFdoUpdateTest.h"
+#include "UnitTestUtil.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( PostGisFdoUpdateTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PostGisFdoUpdateTest, "FdoUpdateTest");
+
+void PostGisFdoUpdateTest::set_provider()
+{
+ UnitTestUtil::SetProvider( "PostGIS" );
+ m_hasAssoc = false;
+ m_hasGeom = true;
+}
+
+void PostGisFdoUpdateTest::testForeignDataStore()
+{
+ FdoPtr<FdoIConnection> connection;
+ try
+ {
+ printf( "Initializing Connection ... \n" );
+ FdoStringP userConnectString = UnitTestUtil::GetConnectionString(Connection_NoDatastore, L"");
+ connection = UnitTestUtil::GetProviderConnectionObject();
+ connection->SetConnectionString ( userConnectString);
+ connection->Open();
+
+ FdoStringP datastore = UnitTestUtil::GetEnviron("datastore", L"_foreign_sch");
+ FdoStringP pQueryStringCr = L"CREATE DATABASE ";
+ pQueryStringCr += datastore;
+ pQueryStringCr += L";";
+ try
+ {
+ UnitTestUtil::Sql2Db( (const wchar_t*) pQueryStringCr, connection.p );
+ connection->Close();
+ userConnectString = UnitTestUtil::GetConnectionString(Connection_WithDatastore, L"_foreign_sch");
+ connection->SetConnectionString ( userConnectString);
+ connection->Open();
+ UnitTestUtil::Sql2Db( (const wchar_t**) mForeignPolygonTest, connection.p );
+ connection->Close();
+ }
+ catch(...){}
+
+ userConnectString = UnitTestUtil::GetConnectionString(Connection_WithDatastore, L"_foreign_sch");
+ connection->SetConnectionString ( userConnectString);
+ connection->Open();
+
+ FdoPtr<FdoIDescribeSchema> pDescSchemaCmd = (FdoIDescribeSchema*) connection->CreateCommand(FdoCommandType_DescribeSchema);
+ FdoFeatureSchemasP fsc = pDescSchemaCmd->Execute();
+ fsc->WriteXml( UnitTestUtil::GetOutputFileName( L"describeSchemasf.xml" ) );
+
+ double pPoints[10];
+ double pPoints2[10];
+ pPoints[0] = 249.54; pPoints[1] = 576.84;
+ pPoints[2] = 249.54; pPoints[3] = 516.33;
+ pPoints[4] = 146.90; pPoints[5] = 516.33;
+ pPoints[6] = 146.90; pPoints[7] = 576.84;
+ pPoints[8] = 249.54; pPoints[9] = 576.84;
+
+ pPoints2[0] = 29.54; pPoints2[1] = 76.84;
+ pPoints2[2] = 29.54; pPoints2[3] = 16.33;
+ pPoints2[4] = 16.90; pPoints2[5] = 16.33;
+ pPoints2[6] = 16.90; pPoints2[7] = 76.84;
+ pPoints2[8] = 29.54; pPoints2[9] = 76.84;
+ try
+ {
+ FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction();
+ FdoPtr<FdoIInsert> insertCommand = (FdoIInsert *)connection->CreateCommand(FdoCommandType_Insert);
+ insertCommand->SetFeatureClassName(L"foreignpolygon");
+ FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues();
+
+ FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+ FdoPtr<FdoPropertyValue> propertyValue;
+
+ propertyValue = AddNewProperty( propertyValues, L"GEOMETRY");
+ FdoPtr<FdoILineString> line1 = gf->CreateLineString(FdoDimensionality_XY, 2*2, pPoints);
+ FdoPtr<FdoByteArray> byteArray = gf->GetFgf(line1);
+
+ FdoPtr<FdoGeometryValue> geometryValue = FdoGeometryValue::Create(byteArray);
+ propertyValue->SetValue(geometryValue);
+
+ FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute();
+ featureTransaction->Commit();
+ UnitTestUtil::FailOnException( FdoException::Create( L"testForeignDataStore step 1 should fail!" ));
+ }
+ catch ( FdoException* e )
+ {
+ printf( "Expected exception:%ls\n", e->GetExceptionMessage());
+ e->Release();
+ }
+ try
+ {
+ FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction();
+ FdoPtr<FdoIInsert> insertCommand = (FdoIInsert *)connection->CreateCommand(FdoCommandType_Insert);
+ insertCommand->SetFeatureClassName(L"foreignpolygon");
+ FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues();
+
+ FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+ FdoPtr<FdoPropertyValue> propertyValue;
+
+ propertyValue = AddNewProperty( propertyValues, L"GEOMETRY");
+ FdoPtr<FdoILinearRing> extRing = gf->CreateLinearRing(FdoDimensionality_XY, 10, pPoints);
+ FdoPtr<FdoIPolygon> poly1 = gf->CreatePolygon(extRing, NULL );
+
+ FdoPtr<FdoByteArray> byteArray = gf->GetFgf(poly1);
+ FdoPtr<FdoGeometryValue> geometryValue = FdoGeometryValue::Create(byteArray);
+ propertyValue->SetValue(geometryValue);
+
+ FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute();
+ featureTransaction->Commit();
+ }
+ catch ( FdoException* e )
+ {
+ UnitTestUtil::FailOnException( e );
+ }
+ try
+ {
+ FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction();
+ FdoPtr<FdoIInsert> insertCommand = (FdoIInsert *)connection->CreateCommand(FdoCommandType_Insert);
+ insertCommand->SetFeatureClassName(L"foreignpolygon");
+ FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues();
+
+ FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance();
+ FdoPtr<FdoPropertyValue> propertyValue;
+
+ propertyValue = AddNewProperty( propertyValues, L"GEOMETRY");
+ FdoPtr<FdoILinearRing> extRing1 = gf->CreateLinearRing(FdoDimensionality_XY, 10, pPoints);
+ FdoPtr<FdoIPolygon> poly1 = gf->CreatePolygon(extRing1, NULL );
+
+ FdoPtr<FdoILinearRing> extRing2 = gf->CreateLinearRing(FdoDimensionality_XY, 10, pPoints2);
+ FdoPtr<FdoIPolygon> poly2 = gf->CreatePolygon(extRing2, NULL );
+ FdoPtr<FdoPolygonCollection> pPolCol = FdoPolygonCollection::Create();
+ pPolCol->Add(poly1);
+ pPolCol->Add(poly2);
+ FdoPtr<FdoIMultiPolygon> pObjIns = gf->CreateMultiPolygon(pPolCol);
+
+ FdoPtr<FdoByteArray> byteArray = gf->GetFgf(pObjIns);
+ FdoPtr<FdoGeometryValue> geometryValue = FdoGeometryValue::Create(byteArray);
+ propertyValue->SetValue(geometryValue);
+
+ FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute();
+ featureTransaction->Commit();
+ UnitTestUtil::FailOnException( FdoException::Create( L"testForeignDataStore step 3 should fail!" ));
+ }
+ catch ( FdoException* e )
+ {
+ printf( "Expected exception:%ls\n", e->GetExceptionMessage());
+ e->Release();
+ }
+ }
+ catch ( FdoException* e )
+ {
+ try {
+ if (connection)
+ connection->Close();
+ }
+ catch ( ... )
+ {
+ }
+ UnitTestUtil::FailOnException( e );
+ }
+ catch (...)
+ {
+ if (connection)
+ connection->Close();
+ throw;
+ }
+}
+
+const wchar_t* PostGisFdoUpdateTest::mForeignPolygonTest[] = {
+ L"CREATE TABLE foreignpolygon",
+ L"(GEOMETRY POLYGON,",
+ L"ENTITYID INT AUTO_INCREMENT PRIMARY KEY,",
+ L"VERSIONNUMBER SMALLINT,",
+ L"LOCKID TINYINT,",
+ L"FSBLOCKNAME TEXT(255),",
+ L"DESCR TEXT(50),",
+ L"FSCLOSED CHAR(1),",
+ L"FSCOLOR INT,",
+ L"FSENTITYTYPE CHAR(30),",
+ L"FSHYPERLINK DATETIME,",
+ L"FSJUSTIFICATION DECIMAL(5,2),",
+ L"FSLAYER VARCHAR(255),",
+ L"FSLINETYPE TINYTEXT,",
+ L"FSGEOMETRYTYPE SET('1','2','3','4','5','6','7','8','9','10','11','12'),",
+ L"FSLINEWEIGHT DECIMAL(38,8),",
+ L"FSOLYPATCOLOR BIGINT,",
+ L"FSOLYPATTYPE VARCHAR(100),",
+ L"FSPLOTSTYLE MEDIUMTEXT,",
+ L"FSROTATION DECIMAL,",
+ L"FSTEXTCONTENT LONGTEXT,",
+ L"FSTEXTHEIGHT MEDIUMINT,",
+ L"FSTHICKNESS DECIMAL(35),",
+ L"FSWIDTH DOUBLE,",
+ L"FSBLOB MEDIUMBLOB,",
+ L"FSGEOMETRICTYPE ENUM('one', 'two', 'three', 'four'),",
+ L"FSTIME TIME,",
+ L"FSYEAR YEAR,",
+ L"FSDATE DATE) ENGINE=MyISAM;",
+ NULL
+};
+
+FdoString* PostGisFdoUpdateTest::NoMetaSuffix()
+{
+ FdoString* noMetaSuffix = L"_no_meta";
+
+ return noMetaSuffix;
+}
+
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.h
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.h (rev 0)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/UnitTest/PostGIS/PostGisFdoUpdateTest.h 2007-02-14 17:05:54 UTC (rev 745)
@@ -0,0 +1,42 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef POSTGIS_FDOUPDATETEST_H
+#define POSTGIS_FDOUPDATETEST_H
+
+#include "FdoUpdateTest.h"
+
+class PostGisFdoUpdateTest : public FdoUpdateTest
+{
+ CPPUNIT_TEST_SUB_SUITE (PostGisFdoUpdateTest, FdoUpdateTest);
+ CPPUNIT_TEST( testForeignDataStore );
+ CPPUNIT_TEST_SUITE_END ();
+
+ void set_provider();
+ virtual FdoStringP TableIdGeomName() {return L"table_id_geom";}
+
+public:
+ virtual void ConditionalUpdate () { }
+ void testForeignDataStore();
+
+protected:
+ virtual FdoString* NoMetaSuffix();
+ static const wchar_t* mForeignPolygonTest[];
+};
+
+#endif // POSTGIS_FDOUPDATETEST_H
More information about the fdo-commits
mailing list