TsDataSource.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file TsDataSource.h
22 
23  \brief A test suit for the DataSource interface.
24  */
25 
26 #ifndef __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_H
27 #define __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_H
28 
29 // TerraLib
30 #include <terralib/dataaccess_fw.h>
31 #include <terralib/geometry_fw.h>
32 #include <terralib/dataaccess/datasource/DataSourceFactory.h> //por algum motivo se nao colocar essa linha pega o antigo.
33 
34 // STL
35 #include <string>
36 
37 // cppUnit
38 #include <cppunit/extensions/HelperMacros.h>
39 
40 /*!
41  \class TsDataSource
42 
43  \brief A test suit for the DataSource interface.
44 
45  ....
46  <br>
47  This test suite will check the following:
48  <ul>
49  <li>;</li>
50  <li>;</li>
51  <li>;</li>
52  <li>;</li>
53  <li>;</li>
54  </ul>
55  */
56 class TsDataSource : public CPPUNIT_NS::TestFixture
57 {
58 
59 // It registers this class as a Test Suit
61 
62 // It registers the class methods as Test Cases belonging to the suit
65 
67 
69 
75 
76  //getDataset methods...
84 
89 
92  //CPPUNIT_TEST( tcGetConnection );
94 
97 
101  //CPPUNIT_TEST( tcGetDataSources );
102 
104 
105  public:
106 // It sets up context before running the test.
107  void setUp();
108 
109 // It cleann up after the test run.
110  void tearDown();
111 
112  protected:
113  void tcOpenWithMap();//
114  void tcOpenWithStr();//?
115  void tcGetType();//
116  void tcGetId();//
117  void tcSetId();
118 
119  void tcClose();
120  void tcIsOpened();
121  void tcIsValid();
122  void tcGetCatalog();//??
123  void tcGetCatalogFull(); //??
124  void tcGetCapabilities();
125  void tcGetTransactor();
126  void tcGetConnectionInfo();
127  //void tcGetConnection();
128  void tcSQLDialect();
129 
130 
131  void tcSetConnectionInfo();
132  void tcCloseConnection();
133  void tcExist();
134  void tcCreate();
135  void tcDrop();
136  void tcGetEncodings();
137  ////void tcGetDataSources();
138 
139 // Transaction Methods...ponly ion transactor will be tested
140  //void tcIsIntransaction();
141  //void tcBegin();
142  //void tcCommit();
143  //void tcEnd();
144  //void tcRollBack();
145 
146 // Methods for retrieving data from the datasource (old DataSourceTranstator)
147 
148  void tcGetDataSetByName();
149  void tcGetDataSetByEnvRec();
150  void tcGetDataSetByEnvRec1();
151  void tcGetDataSetByEnvRec2();
152  void tcGetDataSetByGeometry();
153  void tcGetDataSetByProperty();
154  void tcGetDataSetByOids();
155 
156  void tcQueryByString();
157  void tcQueryBySelect();
158 
159  void tcExecuteQuery();
160  void tcExecuteString();
161  void tcCancel();
162 
163 // Methods for retrieving the metadata about datasets from the dataSource
164  void tcGetDataSetNames();
165  void tcGetNumberOfDataSets();
166 
167  void tcGetDataSetType();
168  void tcGetProperties();
169  void tcGetPropertyByName();//dataset name and property name
170  void tcGetPropertyNames();
172  void tcPropertyExists();
173  void tcGetPropertyByPos(); //dataset name and property position
174 
175 
176  void tcGetPrimaryKey();
177  void tcPrimaryKeyExists();
178  void tcGetForeingKey();
179  void tcGetForeignKeyNames();
180  void tcForeignKeyExists();
181 
182  void tcGetUniqueKey();
183  void tcGetUniqueKeyNames();
184  void tcUniqueKeyExists();
185 
186  void tcGetCheckConstraint();
189 
190  void tcGetIndex();
191  void tcGetIndexNames();
192  void tcIndexExists();
193 
194  void tcGetSequence();
195  void tcGetSequenceNames();
196  void tcSequenceExists();
197 
198  void tcGetExtentByPropName();
199  void tcGetExtentByPropPos();
200 
201  void tcGetNumberOfItems();
202 
203 // Auxiliary commands
204  void tcEscape();
205  void tcIsDataSetNameValid();
206  void tcIsPropertyNameValid ();
207 
208 // Changing schema and content
209 
210  void tcAddProperty();
211  void tcDropProperty();
212  void tcRenameProperty();
213 
214  void tcAddPrimaryKey();
215  void tcDropPrimaryKey();
216 
217  void tcAddForeignKey();
218  void tcDropForeignKey();
219 
220  void tcAddUniqueKey();
221  void tcDropUniqueKey();
222 
223  void tcAddCheckConstraint();
224  void tcDropCheckConstraint();
225 
226  void tcAddIndex();
227  void tcDropIndex();
228 
229  void tcAddSequence();
230  void tcDropSequence();
231 
232 // DataSource inquire (colocar junto com os metodos do inicio)
233 
234  void tcHasDataSets();
235  void tcDataSetExists();
236 
237 // Dataset Schema Persistence Methods
238 // Methods for dealing with datasource and dataset schema changes
239 
240  void tcCreateDataSet();
241  void tcCloneDataSet();
242  void tcDropDataSet();
243  void tcRenameDataSet();
244 
245  void tcAddDataSet();
246  void tcRemoveOids();
247  void tcUpdateDataSet();
248  //void tcOptimize();
249 
250 // Methods to deal with repository
251 
252  void tcCreateNewDS();
253  void tcDropDS();
254  void tcExistsDS();
255  void tcGetDataSourceNames();
256  void tcGetEncodingsOfDS();
257 
258  public:
259 // It will come from the setUp of the derived database class (see:TsPostGIS, TsSQLite, etc)
261  //std::auto_ptr<te::da::DataSource> m_ds;
263  std::map<std::string, std::string> m_connInfo;
264  std::map<std::string, std::string> m_connInfoExist;
265 
266  std::string m_connStr;
267  std::string m_dsType;
268  std::map<std::string, std::string> m_connInfoNewDs;
269  std::map<std::string, std::string> m_connInfoDropDs;
270 
271 // Now I need these vars to use in methods of the datasource directly...(without transactor)
272  std::vector<std::string> m_vecDtNames;
273  std::vector<te::gm::Envelope> m_vecEnvelops;
274  std::vector<std::pair<std::string, te::gm::Envelope> > m_vecDtNamesAndEnvelops;
275  std::vector<std::pair<std::string, te::gm::Envelope> > m_vecNamesAndRecs;
276  std::vector<std::pair<std::string, size_t> > m_vecNamesSizes;
277  std::vector<std::pair<std::string, size_t> > m_vecNamesSizesRec;
278 
284 
285 
286 /*
287  std::string m_connInfoStr;
288  std::map<std::string, std::string> m_connInfoDropDs;
289  te::da::DataSourceCatalog* m_dsCatalog;
290  size_t m_nroDataSets;
291 */
292 };
293 /*
294 #define INSERT_DATASOURCE_TC CPPUNIT_TEST( tcOpenWithMap ); \
295  CPPUNIT_TEST( tcGetTransactor ); \
296  CPPUNIT_TEST( tcIsValid ); \
297  CPPUNIT_TEST( tcIsOpened ); \
298  CPPUNIT_TEST( tcGetCapabilities ); \
299  CPPUNIT_TEST( tcClose ); \
300  CPPUNIT_TEST( tcSetConnectionInfo ); \
301  CPPUNIT_TEST( tcGetConnectionInfo ); \
302  CPPUNIT_TEST( tcGetConnectionStr ); \
303  CPPUNIT_TEST( tcSQLDialect ); \
304  CPPUNIT_TEST( tcOpen ); \
305  CPPUNIT_TEST( tcIsOpened ); \
306  CPPUNIT_TEST( tcGetType ); \
307  CPPUNIT_TEST( tcGetTransactor ); \
308  CPPUNIT_TEST( tcGetCapabilities ); \
309  CPPUNIT_TEST( tcClose ); \
310  CPPUNIT_TEST( tcOpen ); \
311  CPPUNIT_TEST( tcGetCatalogFull ); \
312  CPPUNIT_TEST( tcCreate ); \
313  CPPUNIT_TEST( tcDrop ); \
314 */
315 #endif // __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_H
316 
std::map< std::string, std::string > m_connInfoDropDs
Definition: TsDataSource.h:269
std::string m_dsType
Definition: TsDataSource.h:267
void tcDropDS()
void tcGetForeingKey()
void tcDropProperty()
void tcExecuteString()
void tcGetIndexNames()
void tcGetCheckConstraint()
void tcCancel()
void tcGetNumberOfItems()
te::gm::Geometry * m_geom
Definition: TsDataSource.h:283
CPPUNIT_TEST_SUITE(TsDataSource)
void tcHasDataSets()
void tcQueryBySelect()
Forward declarations for the Data Access module.
void tcGetIndex()
void tcGetProperties()
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
std::vector< std::string > m_vecDtNames
Definition: TsDataSource.h:272
void tcGetEncodingsOfDS()
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
void tcExistsDS()
std::vector< std::pair< std::string, size_t > > m_vecNamesSizesRec
Definition: TsDataSource.h:277
std::map< std::string, std::string > m_connInfoExist
Definition: TsDataSource.h:264
CPPUNIT_TEST_SUITE_END()
std::map< std::string, std::string > m_connInfo
Definition: TsDataSource.h:263
void tcSequenceExists()
void tcGetForeignKeyNames()
void tcDropSequence()
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
void tcGetExtentByPropName()
te::gm::Envelope m_box
Definition: TsDataSource.h:279
void tcDropUniqueKey()
void tcUniqueKeyExists()
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
void tcCloneDataSet()
void tcGetPrimaryKey()
This file contains forward declarations for the Vector Geometry model of TerraLib.
void tcExecuteQuery()
te::gm::Polygon * m_pol
Definition: TsDataSource.h:282
void tcGetSequence()
void tcAddForeignKey()
std::vector< std::pair< std::string, te::gm::Envelope > > m_vecNamesAndRecs
Definition: TsDataSource.h:275
A factory for data sources.
std::string m_connStr
Definition: TsDataSource.h:266
te::da::DataSource * m_ds
Definition: TsDataSource.h:260
te::gm::Point m_pt
Definition: TsDataSource.h:280
void tcUpdateDataSet()
void tcGetUniqueKeyNames()
void tcGetPropertyNames()
std::vector< std::pair< std::string, size_t > > m_vecNamesSizes
Definition: TsDataSource.h:276
void tcGetUniqueKey()
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void tcDropForeignKey()
void tcDataSetExists()
CPPUNIT_TEST(tcOpenWithStr)
void tcGetDataSetType()
std::map< std::string, std::string > m_connInfoNewDs
Definition: TsDataSource.h:268
void tcDropPrimaryKey()
te::da::DataSourceCapabilities m_capabilit
Definition: TsDataSource.h:262
void tcCheckConstraintExists()
void tcIsPropertyNameValid()
void tcGetDataSourceNames()
void tcAddDataSet()
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void tcPropertyExists()
void tcForeignKeyExists()
void tcPrimaryKeyExists()
void tcGetSequenceNames()
void tcGetCheckConstraintNames()
void tcCreateNewDS()
void tcGetExtentByPropPos()
void tcAddIndex()
void tcDropIndex()
void tcGetNumberOfDataSets()
void tcIndexExists()
void tcGetPropertyByName()
te::gm::LinearRing * m_linearRing
Definition: TsDataSource.h:281
void tcGetPropertyByPos()
void tcRenameDataSet()
void tcRenameProperty()
std::vector< std::pair< std::string, te::gm::Envelope > > m_vecDtNamesAndEnvelops
Definition: TsDataSource.h:274
void tcAddProperty()
void tcAddCheckConstraint()
std::vector< te::gm::Envelope > m_vecEnvelops
Definition: TsDataSource.h:273
A test suit for the DataSource interface.
Definition: TsDataSource.h:56
void tcGetNumberOfProperties()
void tcDropCheckConstraint()
void tcAddSequence()
void tcQueryByString()
void tcIsDataSetNameValid()
void tcRemoveOids()
void tcCreateDataSet()
void tcAddUniqueKey()
void tcDropDataSet()
void tcEscape()
void tcAddPrimaryKey()
void tcGetDataSetNames()