[fdo-commits] r118 - branches/3.2.x/Providers/ArcSDE/Src/UnitTest
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Fri Jan 26 07:32:08 EST 2007
Author: pierredalcourt
Date: 2007-01-26 07:32:08 -0500 (Fri, 26 Jan 2007)
New Revision: 118
Modified:
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.cpp
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicUpdateTests.cpp
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/RecommitTest.cpp
branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp
Log:
ArcSDE + GenericRDBMS: fix unit test errors
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.cpp
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.cpp 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.cpp 2007-01-26 12:32:08 UTC (rev 118)
@@ -203,8 +203,8 @@
int ArcSDETests::Insert (FdoIConnection* connection, UnitTestClass* definition, size_t index)
{
- wchar_t* id;
- wchar_t* name;
+ FdoString* id;
+ FdoString* name;
FdoPtr<FdoValueExpression> expression;
FdoPtr<FdoPropertyValue> value;
int ret;
@@ -264,7 +264,7 @@
FdoPtr<FdoFilter> filter;
FdoPtr<FdoIUpdate> update;
FdoPtr<FdoPropertyValueCollection> values;
- wchar_t* name;
+ FdoString* name;
FdoPtr<FdoValueExpression> expression;
FdoPtr<FdoPropertyValue> value;
int count;
@@ -723,7 +723,7 @@
}
-void ArcSDETests::checkEqual(FdoPtr<FdoIFeatureReader> reader, wchar_t* propertyName, FdoDataType propertyType, const wchar_t* propertyData)
+void ArcSDETests::checkEqual(FdoPtr<FdoIFeatureReader> reader, FdoString* propertyName, FdoDataType propertyType, FdoString* propertyData)
{
// Get the literal expression we're comparing against:
FdoPtr<FdoExpression> expression = ArcSDETests::ParseByDataType(propertyData,propertyType);
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ArcSDETests.h 2007-01-26 12:32:08 UTC (rev 118)
@@ -23,13 +23,31 @@
#pragma once
#endif // _WIN32
+// Updates the given name based on whether the unit tests are being run in
+// release mode or debug mode. This is necessary following recent performance
+// changes which cause the provider to behave differently if run in
+// debug vs release mode, namely that FDO metadata that impacts FDO class/property
+// names is only retrieved in debug mode since ApplySchema is only supported in debug mode.
+static FdoString* AdjustRdbmsName(FdoString* name)
+{
+ static int bufferIndex=0;
+ static wchar_t buffer[10][1000];
+#ifdef _DEBUG
+ return name;
+#else
+ bufferIndex = (bufferIndex+1) % 10;
+ wcscpy(buffer[bufferIndex], name);
+ return wcsupr(buffer[bufferIndex]);
+#endif
+}
+
// Represents one FDO data property with a corresponding data value
class UnitTestData
{
public:
- wchar_t* mPropertyName;
- wchar_t* mPropertyDescription;
+ FdoString* mPropertyName;
+ FdoString* mPropertyDescription;
FdoDataType mPropertyType;
int mPropertyLength;
int mPropertyPrecision;
@@ -40,8 +58,8 @@
std::vector<const wchar_t*> mPropertyData;
UnitTestData (
- wchar_t* property_name,
- wchar_t* property_description,
+ FdoString* property_name,
+ FdoString* property_description,
FdoDataType property_type,
int property_length,
int property_precision,
@@ -62,6 +80,7 @@
{
const wchar_t* data;
va_list varArgs;
+ mPropertyName = AdjustRdbmsName(mPropertyName);
// Handle random list of property data:
va_start (varArgs, property_auto);
@@ -132,7 +151,7 @@
static FdoExpression* ParseByDataType(const wchar_t* data, FdoDataType dataType);
// Check that the given property in the given reader matches the given value:
- void checkEqual(FdoPtr<FdoIFeatureReader> reader, wchar_t* propertyName, FdoDataType propertyType, const wchar_t* propertyData);
+ void checkEqual(FdoPtr<FdoIFeatureReader> reader, FdoString* propertyName, FdoDataType propertyType, FdoString* propertyData);
// add the given class to the default schema
static void CreateSchema (FdoIConnection* connection, UnitTestClass* cls);
@@ -528,7 +547,7 @@
#define DECLARE_CLASS(DBMETHODNAME, USERMETHODNAME, CLASSMETHODNAME, REALCLASSNAME) \
static FdoStringP ClassSchema##CLASSMETHODNAME() { return FdoStringP::Format(L"%ls%ls", (FdoString*)FdoSchemaPrefix##DBMETHODNAME(), (FdoString*)UserName##USERMETHODNAME()); } \
-static FdoStringP ClassName##CLASSMETHODNAME() { return REALCLASSNAME; } \
+static FdoStringP ClassName##CLASSMETHODNAME() { return AdjustRdbmsName(REALCLASSNAME); } \
static FdoStringP QClassName##CLASSMETHODNAME() { return FdoStringP::Format(L"%ls:%ls", (FdoString*)ClassSchema##CLASSMETHODNAME(), (FdoString*)ClassName##CLASSMETHODNAME()); }
DECLARE_CLASS(Sde, Metadcov, TestClassSimple, L"TESTA");
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicInsertTests.cpp 2007-01-26 12:32:08 UTC (rev 118)
@@ -890,6 +890,8 @@
/* Test default values and read-only properties in insert operation. */
void BasicInsertTests::defaults_insert ()
{
+// This test relies on metadata created by ApplySchema which is only available in Debug mode, so skip this test if not running in debug mode
+#ifdef _DEBUG
if (CreateSchemaOnly()) return;
try
@@ -909,7 +911,7 @@
FdoPtr<FdoPropertyValue> value;
FdoPtr<FdoValueExpression> expression;
expression = (FdoValueExpression*)ArcSDETests::ParseByDataType (L"'Inserted String 1'", FdoDataType_String);
- value = FdoPropertyValue::Create(L"StringWithDefault1", expression);
+ value = FdoPropertyValue::Create(AdjustRdbmsName(L"StringWithDefault1"), expression);
values->Add(value);
}
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
@@ -920,9 +922,9 @@
selectCmd->SetFeatureClassName (ArcSDETestConfig::QClassNameTestClassNew());
reader = selectCmd->Execute ();
CPPUNIT_ASSERT_MESSAGE("Failed to read 1st inserted row", reader->ReadNext());
- checkEqual(reader, L"ReadOnlyInt", FdoDataType_Int32, L"255");
- checkEqual(reader, L"StringWithDefault1", FdoDataType_String, L"'Inserted String 1'");
- checkEqual(reader, L"StringWithDefault2", FdoDataType_String, L"'Default String 2'");
+ checkEqual(reader, AdjustRdbmsName(L"ReadOnlyInt"), FdoDataType_Int32, L"255");
+ checkEqual(reader, AdjustRdbmsName(L"StringWithDefault1"), FdoDataType_String, L"'Inserted String 1'");
+ checkEqual(reader, AdjustRdbmsName(L"StringWithDefault2"), FdoDataType_String, L"'Default String 2'");
CPPUNIT_ASSERT_MESSAGE("Shouldn't be anymore rows", !reader->ReadNext());
reader->Close ();
@@ -936,7 +938,7 @@
FdoPtr<FdoPropertyValue> value;
FdoPtr<FdoValueExpression> expression;
expression = (FdoValueExpression*)ArcSDETests::ParseByDataType (L"123", FdoDataType_Int32);
- value = FdoPropertyValue::Create(L"ReadOnlyInt", expression);
+ value = FdoPropertyValue::Create(AdjustRdbmsName(L"ReadOnlyInt"), expression);
values->Add(value);
}
try
@@ -956,6 +958,7 @@
{
fail (ge);
}
+#endif
}
@@ -1090,7 +1093,7 @@
FdoPtr<FdoIGeometry> aGeometry = collection->GetItem(i);
FdoPtr<FdoByteArray> byteArray = gf->GetFgf(aGeometry);
FdoPtr<FdoGeometryValue> geomExpression = FdoGeometryValue::Create(byteArray);
- FdoPtr<FdoPropertyValue> value = FdoPropertyValue::Create (L"MyGeometry", geomExpression);
+ FdoPtr<FdoPropertyValue> value = FdoPropertyValue::Create (AdjustRdbmsName(L"MyGeometry"), geomExpression);
values->Add (value);
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
// none returned: reader->Close ();
@@ -1100,7 +1103,7 @@
selectCmd->SetFeatureClassName (ArcSDETestConfig::QClassNameTestClassGeomZm3());
reader = selectCmd->Execute ();
CPPUNIT_ASSERT_MESSAGE("Should have retrieved 1 row, got 0 rows", reader->ReadNext());
- FdoPtr<FdoByteArray> fetched = reader->GetGeometry (L"MyGeometry");
+ FdoPtr<FdoByteArray> fetched = reader->GetGeometry (AdjustRdbmsName(L"MyGeometry"));
FdoPtr<FdoByteArray> reference = geomExpression->GetGeometry ();
FdoPtr<FdoIGeometry> fetchedGeom = gf->CreateGeometryFromFgf(fetched);
FdoPtr<FdoIGeometry> referenceGeom = gf->CreateGeometryFromFgf(reference);
@@ -1188,7 +1191,7 @@
propValues->Add (propVal);
FdoPtr<FdoExpression> valueExpr1 = FdoExpression::Parse(geom1);
FdoGeometryValue* geomVal1 = dynamic_cast<FdoGeometryValue*>(valueExpr1.p);
- propVal = FdoPropertyValue::Create (L"MyGeometry", geomVal1);
+ propVal = FdoPropertyValue::Create (AdjustRdbmsName(L"MyGeometry"), geomVal1);
propValues->Add (propVal);
reader = insert->Execute();
CPPUNIT_ASSERT_MESSAGE("Expected to receive one id from FdoIInsert::Execute(), got none.", reader->ReadNext());
@@ -1204,7 +1207,7 @@
propVal = propValues->GetItem(Data[5]->mPropertyName);
FdoPtr<FdoInt32Value> intValId2 = FdoInt32Value::Create(int2);
propVal->SetValue(intValId2);
- propVal = propValues->GetItem(L"MyGeometry");
+ propVal = propValues->GetItem(AdjustRdbmsName(L"MyGeometry"));
FdoPtr<FdoExpression> valueExpr2 = FdoExpression::Parse(geom2);
FdoGeometryValue* geomVal2 = dynamic_cast<FdoGeometryValue*>(valueExpr2.p);
propVal->SetValue(geomVal2);
@@ -1223,7 +1226,7 @@
propVal = propValues->GetItem(Data[5]->mPropertyName);
FdoPtr<FdoInt32Value> intValId3 = FdoInt32Value::Create(int2);
propVal->SetValue(intValId3);
- propVal = propValues->GetItem(L"MyGeometry");
+ propVal = propValues->GetItem(AdjustRdbmsName(L"MyGeometry"));
FdoPtr<FdoExpression> valueExpr3 = FdoExpression::Parse(geom2);
FdoGeometryValue* geomVal3 = dynamic_cast<FdoGeometryValue*>(valueExpr3.p);
propVal->SetValue(geomVal3);
@@ -1435,7 +1438,7 @@
selectCmd->SetFeatureClassName (ArcSDETestConfig::QClassNameTestClassNullable());
reader = selectCmd->Execute ();
CPPUNIT_ASSERT_MESSAGE("Failed to read 1st inserted row", reader->ReadNext());
- checkEqual(reader, L"String1", FdoDataType_String, L"NULL");
+ checkEqual(reader, AdjustRdbmsName(L"String1"), FdoDataType_String, L"NULL");
CPPUNIT_ASSERT_MESSAGE("Shouldn't be anymore rows", !reader->ReadNext());
reader->Close ();
}
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicUpdateTests.cpp
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicUpdateTests.cpp 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/BasicUpdateTests.cpp 2007-01-26 12:32:08 UTC (rev 118)
@@ -489,21 +489,21 @@
insert->SetFeatureClassName (ArcSDETestConfig::QClassNameSample());
FdoPtr<FdoPropertyValueCollection> values = insert->GetPropertyValues ();
FdoPtr<FdoStringValue> expression = FdoStringValue::Create (L"Zozo");
- FdoPtr<FdoPropertyValue> value = FdoPropertyValue::Create (L"LockProperty", expression);
+ FdoPtr<FdoPropertyValue> value = FdoPropertyValue::Create (AdjustRdbmsName(L"LockProperty"), expression);
values->Add (value);
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
FdoInt32 newId = 0;
if (reader->ReadNext())
- newId = reader->GetInt32(L"Id");
+ newId = reader->GetInt32(AdjustRdbmsName(L"Id"));
FdoPtr<FdoIUpdate> update = (FdoIUpdate*)mConnection->CreateCommand (FdoCommandType_Update);
update->SetFeatureClassName (ArcSDETestConfig::QClassNameSample());
wchar_t filter[1024];
- FdoCommonOSUtil::swprintf(filter, ELEMENTS(filter), L"Id = %d", newId);
+ FdoCommonOSUtil::swprintf(filter, ELEMENTS(filter), L"%ls = %d", AdjustRdbmsName(L"Id"), newId);
update->SetFilter (FdoPtr<FdoFilter>(FdoFilter::Parse (filter)));
values = update->GetPropertyValues ();
value = FdoPropertyValue::Create ();
- value->SetName (L"LockProperty");
+ value->SetName (AdjustRdbmsName(L"LockProperty"));
value->SetValue (L"'All mimsy were the borogoves'");
values->Add (value);
if (1 != update->Execute ())
@@ -515,7 +515,7 @@
reader = select->Execute ();
while (reader->ReadNext ())
{
- CPPUNIT_ASSERT_MESSAGE ("incorrect value", 0 == wcscmp (L"All mimsy were the borogoves", reader->GetString (L"LockProperty")));
+ CPPUNIT_ASSERT_MESSAGE ("incorrect value", 0 == wcscmp (L"All mimsy were the borogoves", reader->GetString (AdjustRdbmsName(L"LockProperty"))));
}
reader->Close();
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/RecommitTest.cpp
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/RecommitTest.cpp 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/RecommitTest.cpp 2007-01-26 12:32:08 UTC (rev 118)
@@ -240,7 +240,7 @@
values->Add (area);
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
reader->ReadNext();
- iCityId1 = reader->GetInt32(L"Id");
+ iCityId1 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
males->SetValue (L"254000");
@@ -248,7 +248,7 @@
area->SetValue (L"'VANCOUVER, BC'");
reader = insert->Execute ();
reader->ReadNext();
- iCityId2 = reader->GetInt32(L"Id");
+ iCityId2 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
insert->SetFeatureClassName (ArcSDETestConfig::QClassNameBeach());
@@ -263,14 +263,14 @@
values->Add (county);
reader = insert->Execute ();
reader->ReadNext();
- iBeachId1 = reader->GetInt32(L"Id");
+ iBeachId1 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
owner->SetValue (L"'LOFT PROPERTIES'");
county->SetValue (L"'OO'");
reader = insert->Execute ();
reader->ReadNext();
- iBeachId2 = reader->GetInt32(L"Id");
+ iBeachId2 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
transaction->Commit ();
@@ -394,7 +394,7 @@
bool found = false;
while (reader->ReadNext ())
{
- if (iCityId2 == reader->GetInt32 (L"Id"))
+ if (iCityId2 == reader->GetInt32 (AdjustRdbmsName(L"Id")))
{
CPPUNIT_ASSERT_MESSAGE ("LT1 edit missing", 0 == wcscmp (L"CALGARY, ALBERTA" , reader->GetString (L"AREANAME")));
found = true;
@@ -408,11 +408,11 @@
bool found4 = false;
while (reader->ReadNext ())
{
- if (iBeachId1 == reader->GetInt32 (L"Id"))
+ if (iBeachId1 == reader->GetInt32 (AdjustRdbmsName(L"Id")))
CPPUNIT_FAIL ("child didn't win the delete");
- else if (iBeachId3 == reader->GetInt32 (L"Id"))
+ else if (iBeachId3 == reader->GetInt32 (AdjustRdbmsName(L"Id")))
found3 = true;
- else if (iBeachId4 == reader->GetInt32 (L"Id"))
+ else if (iBeachId4 == reader->GetInt32 (AdjustRdbmsName(L"Id")))
found4 = true;
}
CPPUNIT_ASSERT_MESSAGE ("LT1 feature not found", found3);
@@ -554,7 +554,7 @@
properties->Add (value);
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
reader->ReadNext();
- iBeachId4 = reader->GetInt32(L"Id");
+ iBeachId4 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
transaction->Commit();
}
@@ -609,7 +609,7 @@
properties->Add (value);
FdoPtr<FdoIFeatureReader> reader = insert->Execute ();
reader->ReadNext();
- iBeachId3 = reader->GetInt32(L"Id");
+ iBeachId3 = reader->GetInt32(AdjustRdbmsName(L"Id"));
reader->Close();
transaction->Commit();
}
Modified: branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp
===================================================================
--- branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp 2007-01-26 00:29:28 UTC (rev 117)
+++ branches/3.2.x/Providers/ArcSDE/Src/UnitTest/ThreadingTests.cpp 2007-01-26 12:32:08 UTC (rev 118)
@@ -325,10 +325,6 @@
/* Test running a couple of threads */
void ThreadingTests::a_few_threads ()
{
-#ifdef _WIN32
- CPPUNIT_FAIL("ThreadingTests::a_few_threads disabled");
-#endif
-
FdoPtr <FdoIConnection> connection;
FDOCOMMON_THREAD_HANDLE* handles;
bool success;
More information about the fdo-commits
mailing list