[fdo-commits] r220 - branches/3.2.x/Providers/SDF/Src/UnitTest
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Fri Feb 23 11:47:37 EST 2007
Author: pierredalcourt
Date: 2007-02-23 11:47:37 -0500 (Fri, 23 Feb 2007)
New Revision: 220
Added:
branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.cpp
branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.h
Log:
TRAC Ticket #17 "SHP/SDF: fix various Select/SelectAggregates defects"
Added: branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.cpp (rev 0)
+++ branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.cpp 2007-02-23 16:47:37 UTC (rev 220)
@@ -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: branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Added: branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.h
===================================================================
--- branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.h (rev 0)
+++ branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.h 2007-02-23 16:47:37 UTC (rev 220)
@@ -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: branches/3.2.x/Providers/SDF/Src/UnitTest/SchemaTest.h
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the fdo-commits
mailing list