コード例 #1
0
void SuperMapSelectTest::select_no_featureclass()
{
	CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL);
	CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1);

	FdoPtr<FdoISelect> Select;
	Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select);
	Select->SetFeatureClassName(L"");

	FdoPtr<FdoIFeatureReader> ret;
	try
	{
		ret = Select->Execute();
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(ex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
    catch(...)
    {
		CPPUNIT_FAIL("unresolved exception");
    }
}
コード例 #2
0
ファイル: UnitTest.cpp プロジェクト: johanvdw/fdo-git-mirror
void PrintException(FdoException* exception)
{
	FdoException*	currentException = exception;
	FdoInt32		tabLevel = 0;
	while (currentException != NULL) 
	{
		prependTabs(tabLevel++);
                fprintf( stderr, "%ls\n", 
                          currentException->GetExceptionMessage());
		if (currentException != exception)
			currentException->Release();
		currentException = currentException->GetCause();
	}
}
コード例 #3
0
ファイル: GwsObjectImpl.cpp プロジェクト: kanbang/Colt
void CGwsObject::PushFdoException (
    const CGwsStatus & stat,
    FdoException     * fdoEx
) const
{
    FdoException    * e = fdoEx;
    e->AddRef ();

    // do I need to reverse fdo exception chain?
    while (e != NULL) {
        PushStatus (CGwsStatus (eGwsFdoProviderError, e->GetExceptionMessage ()));
        FdoException * e1 = e->GetCause ();
        e->Release ();
        e = e1;

    }
    PushStatus (stat);

}
コード例 #4
0
void CSuperMapGetSpatialContextsCommandTest::testExecute1()
{
	// 测试WKT串是否正确只能通过MAP3D等来测,单元测试只测试对各种类型的坐标系空间语义读取器的迭代是否正确,是否出现死循环
	try
	{
		CPPUNIT_ASSERT_MESSAGE("connection state not closed", FdoConnectionState_Closed == m_connection->GetConnectionState());
		m_connection->SetConnectionString(L"DataSource=" L"\"type=sdb;database=" LOCATION L"普通平面坐标系\"");
		CPPUNIT_ASSERT_MESSAGE("connection state not closed", FdoConnectionState_Closed == m_connection->GetConnectionState());
		FdoConnectionState state = m_connection->Open();
		CPPUNIT_ASSERT_MESSAGE("connection state not open", FdoConnectionState_Open == state);
		CPPUNIT_ASSERT_MESSAGE("connection state not open", FdoConnectionState_Open == m_connection->GetConnectionState());
		
		// Verify results of GetSpatialContext:
		FdoPtr<FdoIGetSpatialContexts> getSpatialContexts = (FdoIGetSpatialContexts*)m_connection->CreateCommand(FdoCommandType_GetSpatialContexts);
		//FdoPtr<FdoISpatialContextReader> spatialReader = getSpatialContexts->Execute();
		       // Get a SC reader
        FdoPtr<FdoISpatialContextReader> reader = getSpatialContexts->Execute();

        // Iterate ...
        while ( reader->ReadNext() )
        {
			reader->GetExtent();
		}

		m_connection->Close();
		CPPUNIT_ASSERT_MESSAGE("connection state not closed", FdoConnectionState_Closed == m_connection->GetConnectionState());
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(nex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
}
コード例 #5
0
void SuperMapSelectTest::select_sdb_date()
{
	CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL);
	CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1);

	FdoPtr<FdoISelect> Select;
	Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select);
	if(Select)
	{
		Select->SetFeatureClassName(L"面");

		FdoString *strFilter = L"TestDate <= TIMESTAMP '2007-12-12 00:00:00'";
		Select->SetFilter( strFilter );

		FdoPtr<FdoIFeatureReader> ret;
		try
		{
			ret = Select->Execute();
		}
		catch (FdoException* ex)
		{
			FdoException* nex = ex;
			while (nex)
			{
				AfxMessageBox(ex->GetExceptionMessage());
				nex = nex->GetCause();
			}
			ex->Release();
		}
		catch(...)
		{
			CPPUNIT_FAIL("unresolved exception");
		}
		CPPUNIT_ASSERT_MESSAGE("返回的要素集合为空!", ret != NULL);

		int count = 0;
		int SmID;
		int UserID;
		FdoDateTime Date;

		FdoPtr<FdoByteArray> geometry;

		try
		{
			while (ret->ReadNext ())
			{
				count++;
				if(!ret->IsNull(L"SmID"))
				{
					SmID = ret->GetInt32 (L"SmID");
				}
				if(!ret->IsNull(L"SmUserID"))
				{
					UserID = ret->GetInt32 (L"SmUserID");
				}
				if(!ret->IsNull(L"TestDate"))
				{
					Date = ret->GetDateTime (L"TestDate");
				}
				if(!ret->IsNull(L"Geometry"))
				{
					geometry = ret->GetGeometry (L"Geometry");
				}
				CPPUNIT_ASSERT_MESSAGE ("几何对象类型不正确", FdoGeometryType_Polygon == *(int*)geometry->GetData());
			}

			CPPUNIT_ASSERT_MESSAGE ("未查出面数据集中的要素", 0 != count);
		}
		catch (FdoException* ex)
		{
			FdoException* nex = ex;
			while (nex)
			{
				AfxMessageBox(ex->GetExceptionMessage());
				nex = nex->GetCause();
			}
			ex->Release();
		}
	}
}
コード例 #6
0
void SuperMapSelectTest::select_region()
{
	CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL);
	CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1);

	FdoPtr<FdoISelect> Select;
	Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select);
	Select->SetFeatureClassName(L"面");

	FdoPtr<FdoIFeatureReader> ret;
	try
	{
		ret = Select->Execute();
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(ex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
    catch(...)
    {
		CPPUNIT_FAIL("unresolved exception");
    }
	CPPUNIT_ASSERT_MESSAGE("返回的要素集合为空!", ret != NULL);

	int count = 0;
	int SmID;
	int UserID;
	double SmArea;
	double SmPerimeter;
	bool TestBoolen;
	short TestShort;
	float TestFloat;
	FdoString *str;
	FdoDateTime date;
	int length;
	FdoPtr<FdoByteArray> geometry;

	try
	{
		while (ret->ReadNext ())
		{
			count++;
			if(!ret->IsNull(L"SmID"))
			{
				SmID = ret->GetInt32 (L"SmID");
			}
			if(!ret->IsNull(L"SmUserID"))
			{
				UserID = ret->GetInt32 (L"SmUserID");
			}
			if(!ret->IsNull(L"SmArea"))
			{
				SmArea = ret->GetDouble (L"SmArea");
			}
			if(!ret->IsNull(L"SmPerimeter"))
			{
				SmPerimeter = ret->GetDouble (L"SmPerimeter");
			}
			if(!ret->IsNull(L"TestBoolen"))
			{
				TestBoolen = ret->GetBoolean (L"TestBoolen");
			}
			if(!ret->IsNull(L"TestShort"))
			{
				TestShort = ret->GetInt16(L"TestShort");
			}
			if(!ret->IsNull(L"TestFloat"))
			{
				TestFloat = ret->GetSingle(L"TestFloat");
			}
			if(!ret->IsNull(L"TestString"))
			{
				str = ret->GetString(L"TestString");
			}
			if(!ret->IsNull(L"TestDate"))
			{
				date = ret->GetDateTime(L"TestDate");
			}
			if(!ret->IsNull(L"长度"))
			{
				length = ret->GetInt32(L"长度");
			}
			if(!ret->IsNull(L"Geometry"))
			{
				geometry = ret->GetGeometry (L"Geometry");
			}
			CPPUNIT_ASSERT_MESSAGE ("几何对象类型不正确", FdoGeometryType_Polygon == *(int*)geometry->GetData());
		}
		CPPUNIT_ASSERT_MESSAGE ("未查出面数据集中的要素", 0 != count);
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(ex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
    catch(...)
    {
		CPPUNIT_FAIL("unresolved exception");
    }
}
コード例 #7
0
void SuperMapSelectTest::select_line()
{
	CPPUNIT_ASSERT_MESSAGE("FDO连接未打开!", m_connection != NULL);
	CPPUNIT_ASSERT_MESSAGE("FDO连接引用次数不为1!", m_connection->GetRefCount() == 1);

	FdoPtr<FdoISelect> Select;
	Select = (FdoISelect *)m_connection->CreateCommand(FdoCommandType_Select);
	Select->SetFeatureClassName(L"线");

	FdoPtr<FdoIFeatureReader> ret;
	try
	{
		ret = Select->Execute();
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(ex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
    catch(...)
    {
		CPPUNIT_FAIL("unresolved exception");
    }
	CPPUNIT_ASSERT_MESSAGE("返回的要素集合为空!", ret != NULL);

	int count = 0;
	int SmID;
	int UserID;
	double Length;
	int ToPoError;
	FdoPtr<FdoByteArray> geometry;

	try
	{
		while (ret->ReadNext ())
		{
			count++;
			if(!ret->IsNull(L"SmID"))
			{
				SmID = ret->GetInt32 (L"SmID");
			}
			if(!ret->IsNull(L"SmUserID"))
			{
				UserID = ret->GetInt32 (L"SmUserID");
			}
			if(!ret->IsNull(L"SmLength"))
			{
				Length = ret->GetDouble (L"SmLength");
			}
			if(!ret->IsNull(L"SmTopoError"))
			{
				ToPoError = ret->GetInt32 (L"SmTopoError");
			}
			if(!ret->IsNull(L"Geometry"))
			{
				geometry = ret->GetGeometry (L"Geometry");
			}
			CPPUNIT_ASSERT_MESSAGE ("几何对象类型不正确", FdoGeometryType_MultiLineString == *(int*)geometry->GetData());
		}
		CPPUNIT_ASSERT_MESSAGE ("未查出点数据集中的要素", 0 != count);
	}
	catch (FdoException* ex)
    {
        FdoException* nex = ex;
        while (nex)
        {
			AfxMessageBox(ex->GetExceptionMessage());
            nex = nex->GetCause();
        }
		ex->Release();
    }
    catch(...)
    {
		CPPUNIT_FAIL("unresolved exception");
    }
}