[fdo-commits] r2608 - trunk/Providers/SDF/Src/UnitTest

svn_fdo at osgeo.org svn_fdo at osgeo.org
Fri Feb 23 11:54:57 EST 2007


Author: pierredalcourt
Date: 2007-02-23 11:54:57 -0500 (Fri, 23 Feb 2007)
New Revision: 2608

Added:
   trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp
   trunk/Providers/SDF/Src/UnitTest/SchemaTest.h
Modified:
   trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp
Log:
TRAC Ticket #17 "SHP/SDF: fix various Select/SelectAggregates defects"

Added: trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp	                        (rev 0)
+++ trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp	2007-02-23 16:54:57 UTC (rev 2608)
@@ -0,0 +1,96 @@
+// 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 "SchemaTest.h"
+#include <ctime>
+#include <cppunit/extensions/HelperMacros.h>
+#include "SDF/SdfCommandType.h"
+#include "SDF/ICreateSDFFile.h"
+
+#define SDF_FILE_MG  L"../../TestData/HYDRANTSMULTIGEOM.sdf"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SchemaTest );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SchemaTest, "SchemaTest");
+
+SchemaTest::SchemaTest(void)
+{
+    
+}
+
+SchemaTest::~SchemaTest(void)
+{
+    
+}
+
+void SchemaTest::setUp ()
+{
+
+}
+
+void SchemaTest::tearDown ()
+{
+}
+
+void SchemaTest::OpenConnection(FdoIConnection* conn, const wchar_t* path , bool placeDQ)
+{
+#ifdef _WIN32
+    wchar_t fullpath[1024];
+    _wfullpath(fullpath, path, 1024);
+#else
+    char cpath[1024];
+    char cfullpath[1024];
+    wcstombs(cpath, path, 1024);
+    realpath(cpath, cfullpath);
+    wchar_t fullpath[1024];
+    mbstowcs(fullpath, cfullpath, 1024);
+#endif
+
+    std::wstring connStr;
+    if (placeDQ)
+        connStr = std::wstring(L"File=\"") + std::wstring(fullpath) + std::wstring(L"\"");
+    else
+        connStr = std::wstring(L"File=") + std::wstring(fullpath);
+    connStr += std::wstring(L";ReadOnly=TRUE");
+
+    conn->SetConnectionString(connStr.c_str());
+    conn->Open();
+}
+
+void SchemaTest::TestMultipleGeom()
+{
+    try
+    {
+        FdoPtr<IConnectionManager> manager = FdoFeatureAccessManager::GetConnectionManager ();
+        FdoPtr<FdoIConnection> conn = manager->CreateConnection (L"OSGeo.SDF.3.2");
+
+        OpenConnection(conn, SDF_FILE_MG);
+        
+        FdoPtr<FdoIDescribeSchema>pDescSchemaCmd = (FdoIDescribeSchema*) conn->CreateCommand(FdoCommandType_DescribeSchema);
+        FdoPtr<FdoFeatureSchemaCollection> pfsc = pDescSchemaCmd->Execute();
+        
+        FdoIoFileStreamP schemaFileStream = FdoIoFileStream::Create(L"SDFTestDescribeSchema.xml", L"w+");
+        pfsc->WriteXml(schemaFileStream);
+        schemaFileStream = NULL;
+
+        conn->Close();
+    }
+    catch (FdoException *ex )
+    {
+        printf("FDO error: %ls\n", ex->GetExceptionMessage());
+        ex->Release();
+        CPPUNIT_FAIL ("Failed to export schema!");
+    }
+}
+


Property changes on: trunk/Providers/SDF/Src/UnitTest/SchemaTest.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/Providers/SDF/Src/UnitTest/SchemaTest.h
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SchemaTest.h	                        (rev 0)
+++ trunk/Providers/SDF/Src/UnitTest/SchemaTest.h	2007-02-23 16:54:57 UTC (rev 2608)
@@ -0,0 +1,52 @@
+// 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 _SCHEMATEST_H_
+#define _SCHEMATEST_H_
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "Fdo.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <map>
+#include <TestCommonMiscUtil.h>
+
+/* 
+ * The unit test for schema.
+ */
+
+class SchemaTest : public CppUnit::TestCase
+{
+  CPPUNIT_TEST_SUITE( SchemaTest );
+  CPPUNIT_TEST( TestMultipleGeom );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+    SchemaTest(void);
+    virtual ~SchemaTest(void);
+    void setUp ();
+	void tearDown ();
+
+    void TestMultipleGeom();
+
+private:
+    void OpenConnection(FdoIConnection* conn, const wchar_t* path , bool placeDQ = false);
+};
+
+#endif
+


Property changes on: trunk/Providers/SDF/Src/UnitTest/SchemaTest.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp
===================================================================
--- trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp	2007-02-23 14:42:21 UTC (rev 2607)
+++ trunk/Providers/SDF/Src/UnitTest/SelectTest.cpp	2007-02-23 16:54:57 UTC (rev 2608)
@@ -352,11 +352,15 @@
         FdoPtr <FdoIdentifierCollection> ids = select->GetPropertyNames ();
         FdoPtr <FdoIdentifier> id = FdoComputedIdentifier::Create(L"AVG_ID", FdoPtr<FdoExpression>(FdoExpression::Parse(L"Avg(Prop1)")));
         ids->Add(id);
-        FdoPtr<FdoIFeatureReader> reader = select->Execute ();
-        while (reader->ReadNext ())
+        try
         {
-            double avg_computed_id = reader->GetDouble (L"AVG_ID");
+            FdoPtr<FdoIFeatureReader> reader = select->Execute ();
+            CPPUNIT_FAIL("Expected an exception due to using aggregate functions in select command, but didn't get one");
         }
+        catch(FdoException *e)
+        {
+            e->Release();
+        }
     }
     catch (FdoException* e)
     {



More information about the fdo-commits mailing list