[fdo-commits] r2548 - in trunk/Providers/ArcSDE: Src/Provider
Src/UnitTest TestData
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Fri Feb 16 09:08:13 EST 2007
Author: pierredalcourt
Date: 2007-02-16 09:08:13 -0500 (Fri, 16 Feb 2007)
New Revision: 2548
Modified:
trunk/Providers/ArcSDE/Src/Provider/ArcSDEDescribeSchemaCommand.cpp
trunk/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h
trunk/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp
trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.cpp
trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.h
trunk/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp
trunk/Providers/ArcSDE/TestData/SetupTestData.perl
Log:
Fixed unit test errors, compiler warnings, etc.
Modified: trunk/Providers/ArcSDE/Src/Provider/ArcSDEDescribeSchemaCommand.cpp
===================================================================
--- trunk/Providers/ArcSDE/Src/Provider/ArcSDEDescribeSchemaCommand.cpp 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/Provider/ArcSDEDescribeSchemaCommand.cpp 2007-02-16 14:08:13 UTC (rev 2548)
@@ -594,7 +594,8 @@
// optimization: only load information for a specific class if only that class is requested:
if ((preloadedClass==NULL)
&& ((mFdoClassIdToLoad==NULL)
- || ((0==wcscmp(mFdoClassIdToLoad->GetSchemaName(),fdoSchemaName)) && (0==wcscmp(mFdoClassIdToLoad->GetName(),fdoClassName)))))
+ || (((mFdoClassIdToLoad->GetSchemaName()==NULL) || (mFdoClassIdToLoad->GetSchemaName()[0]=='\0') || 0==wcscmp(mFdoClassIdToLoad->GetSchemaName(),fdoSchemaName))
+ && (0==wcscmp(mFdoClassIdToLoad->GetName(),fdoClassName)))))
{
// Store the overrides always:
FdoPtr<ArcSDEClassMapping> classMapping = mConnection->GetClassMapping(fdoSchemaName, fdoClassName, false);
Modified: trunk/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h
===================================================================
--- trunk/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h 2007-02-16 14:08:13 UTC (rev 2548)
@@ -32,11 +32,11 @@
{
static int bufferIndex=0;
static wchar_t buffer[10][1000];
+ bufferIndex = (bufferIndex+1) % 10;
+ wcscpy(buffer[bufferIndex], name);
#ifdef _DEBUG
- return name;
+ return buffer[bufferIndex];
#else
- bufferIndex = (bufferIndex+1) % 10;
- wcscpy(buffer[bufferIndex], name);
return FdoCommonOSUtil::wcsupr(buffer[bufferIndex]);
#endif
}
@@ -46,8 +46,8 @@
class UnitTestData
{
public:
- FdoString* mPropertyName;
- FdoString* mPropertyDescription;
+ FdoStringP mPropertyName;
+ FdoStringP mPropertyDescription;
FdoDataType mPropertyType;
int mPropertyLength;
int mPropertyPrecision;
@@ -577,6 +577,10 @@
DECLARE_CLASS(TestSingleDb, Metadcov, TestClassComplex, L"TESTB");
DECLARE_CLASS(TestMultiDb, Metadcov, TestClassSimpleMultiDb, L"TESTA");
DECLARE_CLASS(Sde, Australia, LargeWithGeom, L"LARGEWITHGEOM");
+
+ static FdoStringP ClassSchemaTreesUniqueName() { return FdoStringP::Format(L"%ls%ls", (FdoString*)FdoSchemaPrefixSde(), (FdoString*)UserNameMetadcov()); } \
+ static FdoStringP ClassNameTreesUniqueName() { return AdjustRdbmsName((FdoString*)FdoStringP::Format(L"TREES_%ls", (FdoString*)DatasetName())); } \
+ static FdoStringP QClassNameTreesUniqueName() { return FdoStringP::Format(L"%ls:%ls", (FdoString*)ClassSchemaTreesUniqueName(), (FdoString*)ClassNameTreesUniqueName()); }
};
#endif // CPP_UNIT_ArcSDETests_H
Modified: trunk/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp
===================================================================
--- trunk/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp 2007-02-16 14:08:13 UTC (rev 2548)
@@ -1344,7 +1344,7 @@
update->Execute();
// Select back the result to see if it changed properly:
- FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", Data[0]->mPropertyName, id2);
+ FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", (FdoString*)Data[0]->mPropertyName, id2);
select->SetFilter(buff);
reader = select->Execute();
CPPUNIT_ASSERT_MESSAGE("Expected to receive one row from FdoISelect::Execute(), got none.", reader->ReadNext());
@@ -1357,7 +1357,7 @@
FdoString* updatedId1 = L"BobTwo";
update = (FdoIUpdate*)mConnection->CreateCommand(FdoCommandType_Update);
update->SetFeatureClassName(ArcSDETestConfig::QClassNameTestUserManagedId());
- FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", Data[0]->mPropertyName, id1);
+ FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", (FdoString*)Data[0]->mPropertyName, id1);
update->SetFilter(buff);
propValues = update->GetPropertyValues();
FdoPtr<FdoStringValue> strVal1 = FdoStringValue::Create(updatedId1);
@@ -1366,7 +1366,7 @@
update->Execute();
// Select back the result to see if it changed properly:
- FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", Data[0]->mPropertyName, updatedId1);
+ FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", (FdoString*)Data[0]->mPropertyName, updatedId1);
select->SetFilter(buff);
reader = select->Execute();
CPPUNIT_ASSERT_MESSAGE("Expected to receive one row from FdoISelect::Execute(), got none.", reader->ReadNext());
@@ -1381,7 +1381,7 @@
// delete the first row:
FdoPtr<FdoIDelete> deleteCmd = (FdoIDelete*)mConnection->CreateCommand(FdoCommandType_Delete);
deleteCmd->SetFeatureClassName(ArcSDETestConfig::QClassNameTestUserManagedId());
- FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", Data[0]->mPropertyName, updatedId1);
+ FdoCommonOSUtil::swprintf(buff, ELEMENTS(buff), L"%ls = '%ls'", (FdoString*)Data[0]->mPropertyName, updatedId1);
deleteCmd->SetFilter(buff);
deleteCmd->Execute();
Modified: trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.cpp
===================================================================
--- trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.cpp 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.cpp 2007-02-16 14:08:13 UTC (rev 2548)
@@ -675,7 +675,7 @@
// Clean up leftovers from previous tests:
FdoPtr<FdoIDelete> deleteCmd = (FdoIDelete*)mConnection->CreateCommand (FdoCommandType_Delete);
deleteCmd->SetFeatureClassName(ArcSDETestConfig::QClassNameSoils());
- deleteCmd->SetFilter(L"NAME like '%\\_%' ESCAPE '\\'");
+ deleteCmd->SetFilter(L"NAME like '%\\_%'");
deleteCmd->Execute();
// Insert some test data (there is no native data that has names containing "[" special character):
@@ -701,7 +701,7 @@
// Test LIKE operator with escape character:
FdoPtr<FdoISelect> select = (FdoISelect*)mConnection->CreateCommand (FdoCommandType_Select);
select->SetFeatureClassName (ArcSDETestConfig::QClassNameSoils());
- select->SetFilter (FdoPtr<FdoFilter>(FdoFilter::Parse (L"NAME like '%\\_%' ESCAPE '\\'")));
+ select->SetFilter (FdoPtr<FdoFilter>(FdoFilter::Parse (L"NAME like '%\\_%'")));
reader = select->Execute ();
long lCount=0;
FdoPtr<FdoFeatureClass> classDef = (FdoFeatureClass*)reader->GetClassDefinition();
@@ -718,7 +718,7 @@
// Clean up after test:
deleteCmd = (FdoIDelete*)mConnection->CreateCommand (FdoCommandType_Delete);
deleteCmd->SetFeatureClassName(ArcSDETestConfig::QClassNameSoils());
- deleteCmd->SetFilter(L"NAME like '%\\_%' ESCAPE '\\'");
+ deleteCmd->SetFilter(L"NAME like '%\\_%'");
deleteCmd->Execute();
@@ -1704,3 +1704,29 @@
fail (ge);
}
}
+
+
+void SelectTests::simple_unique ()
+{
+ if (CreateSchemaOnly()) return;
+
+ try
+ {
+ // Close/re-open the connection, to flush schema cache to make sure we are exercising the code in
+ // DescribeSchema that optimally fetches only the requested class even if its name is not qualified:
+ mConnection->Close ();
+ mConnection->Open ();
+
+ FdoPtr<FdoISelect> select = (FdoISelect*)mConnection->CreateCommand (FdoCommandType_Select);
+ select->SetFeatureClassName (ArcSDETestConfig::ClassNameTreesUniqueName());
+ FdoPtr<FdoIFeatureReader> reader = select->Execute ();
+ FdoPtr<FdoFeatureClass> classDef = (FdoFeatureClass*)reader->GetClassDefinition();
+ while (reader->ReadNext ())
+ ProcessFeature (reader, classDef);
+ reader->Close();
+ }
+ catch (FdoException *e)
+ {
+ fail(e);
+ }
+}
Modified: trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.h
===================================================================
--- trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.h 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/UnitTest/SelectTests.h 2007-02-16 14:08:13 UTC (rev 2548)
@@ -46,6 +46,7 @@
CPPUNIT_TEST (spatial_query_outside_coordsys_extents);
CPPUNIT_TEST (multiple_databases);
CPPUNIT_TEST (spatial_filter_buffer_outside_extents);
+ CPPUNIT_TEST (simple_unique);
CPPUNIT_TEST_SUITE_END ();
static FdoPtr<FdoIConnection> mConnection;
@@ -81,6 +82,7 @@
void multiple_databases();
void spatial_filter_buffer_outside_extents();
void select_large_table_with_geom();
+ void simple_unique();
// helper methods:
void create_large_table_with_geom();
Modified: trunk/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp
===================================================================
--- trunk/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp 2007-02-16 14:08:13 UTC (rev 2548)
@@ -121,7 +121,7 @@
int iRandomIndex = rand() % iFeatureCount;
iFeatNum = iFeatNums[iRandomIndex];
- swprintf (filter, 1023, L"%ls = %d", property0->mPropertyName, iFeatNum);
+ swprintf (filter, 1023, L"%ls = %d", (FdoString*)property0->mPropertyName, iFeatNum);
//printf ("\nthread %d: id %d", context->mId, iFeatNum);
//fflush (stdout);
Modified: trunk/Providers/ArcSDE/TestData/SetupTestData.perl
===================================================================
--- trunk/Providers/ArcSDE/TestData/SetupTestData.perl 2007-02-15 21:34:40 UTC (rev 2547)
+++ trunk/Providers/ArcSDE/TestData/SetupTestData.perl 2007-02-16 14:08:13 UTC (rev 2548)
@@ -325,7 +325,7 @@
# On both Oracle and SQL Server:
- print "\n" . $ACTION . " tables TREES, SOILS and PARCELS for " . $RDBMS . " ... \n";
+ print "\n" . $ACTION . " tables TREES, TREES_" . $DATASETNAME . ", SOILS and PARCELS for " . $RDBMS . " ... \n";
if ($INSTALLACTION ne "U") {
system "shp2sde -o create -l TREES,SHAPE -f " . $SHP_ROOT . "\\Metadcov\\Trees.shp -e p -a all -C OBJECTID,USER,0 -u " . $username_metadcov . " -p test " . $DB_INST;
@@ -334,10 +334,15 @@
system "echo y | sdetable -o alter_reg -t SOILS -V MULTI -c FID -C SDE -u " . $username_australia . " -p test " . $DB_INST;
system "shp2sde -o create -l PARCELS,SHAPE -f " . $SHP_ROOT . "\\Australia\\PARCELS.shp -e a -a all -C FID,USER,0 -u " . $username_australia . " -p test " . $DB_INST;
system "echo y | sdetable -o alter_reg -t PARCELS -c FID -C SDE -u " . $username_australia . " -p test " . $DB_INST;
+
+ # create a table with a unique name, to test code that deals with unqualified FDO class names:
+ system "shp2sde -o create -l TREES_" . $DATASETNAME . ",SHAPE -f " . $SHP_ROOT . "\\Metadcov\\Trees.shp -e p -a all -C OBJECTID,USER,0 -u " . $username_metadcov . " -p test " . $DB_INST;
+ system "echo y | sdetable -o alter_reg -t TREES_" . $DATASETNAME . " -V MULTI -c OBJECTID -C SDE -u " . $username_metadcov . " -p test " . $DB_INST;
} else {
system "echo y | sdetable -o delete -t TREES -u " . $username_metadcov . " -p test " . $DB_INST;
system "echo y | sdetable -o delete -t SOILS -u " . $username_australia . " -p test " . $DB_INST;
system "echo y | sdetable -o delete -t PARCELS -u " . $username_australia . " -p test " . $DB_INST;
+ system "echo y | sdetable -o delete -t TREES_" . $DATASETNAME . " -u " . $username_metadcov . " -p test " . $DB_INST;
}
# On both Oracle and SQL Server:
More information about the fdo-commits
mailing list