00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <unit++.h>
00025 #include <string>
00026 #include <pqxx/all.h>
00027 #include "Document.h"
00028 #include "Broker.h"
00029 #include "Server.h"
00030
00031 using namespace std;
00032 using namespace unitpp;
00033
00034 namespace
00035 {
00036 class DocConversionTestSuite : public suite
00037 {
00038
00039
00040
00041
00042
00043
00044
00045
00046 void testBrokerRemoteServer()
00047 {
00048 Broker myBroker( "my.conversion.server" );
00049 string myServerName = myBroker.getServerName();
00050 if ( myServerName == "my.conversion.server" )
00051 {
00052 assert_true( "broker remote server check", true );
00053 }
00054 else
00055 {
00056 assert_true( "broker remote server check", false );
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 void testGetCounter()
00069 {
00070 Broker myBroker;
00071 assert_eq("broker counter check", 1, myBroker.getCounter() );
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 void testIncreaseCounter()
00083 {
00084 Broker myBroker;
00085 assert_eq("initial counter check", 1, myBroker.getCounter() );
00086 Broker anotherBroker;
00087 assert_eq("increase counter check", 2, anotherBroker.getCounter() );
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 void testDecreaseCounter()
00099 {
00100 {
00101 Broker myBroker;
00102 Broker anotherBroker;
00103 int mycounter = anotherBroker.getCounter();
00104 assert_eq("pre decrease counter check", 2, mycounter );
00105 }
00106 Broker yetAnotherBroker;
00107 int yetanothercounter = yetAnotherBroker.getCounter();
00108 assert_eq("decreased counter check", 1, yetanothercounter );
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 void testGetDocumentUrl()
00121 {
00122 Document
00123 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00124 string myUrl = myDocument.getDocumentUrl();
00125 int match;
00126 if ( myUrl == "http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse .pdf" )
00127 {
00128 match = 0;
00129 }
00130 else
00131 {
00132 match = 1;
00133 }
00134 assert_eq("get Document url check", 0, match);
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 void testGetDocumentFile()
00147 {
00148 Document
00149 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00150 string myFile = myDocument.getDocumentFile();
00151 int match;
00152 if ( myFile == "tech_clearinghouse.pdf" )
00153 {
00154 match = 0;
00155 }
00156 else
00157 {
00158 match = 1;
00159 }
00160 assert_eq("get Document file check", 0, match);
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 void testGetDocumentConversion()
00173 {
00174 Document
00175 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00176 string myConversion = myDocument.getDocumentConversion();
00177 int match;
00178 if ( myConversion == "pdf2ps" )
00179 {
00180 match = 0;
00181 }
00182 else
00183 {
00184 match = 1;
00185 }
00186 assert_eq("get Document conversion check", 0, match);
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 void testGetDocumentConLocation()
00200 {
00201 Document
00202 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00203 myDocument.setConversionLocation("http://localhost/conversions");
00204 string loc = myDocument.getConversionLocation();
00205 int match;
00206 if ( loc == "http://localhost/conversions" )
00207 {
00208 match = 0;
00209 }
00210 else
00211 {
00212 match = 1;
00213 }
00214 assert_eq("get Document conversion location check", 0, match);
00215 }
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 void testGetDocumentFileLocation()
00228 {
00229 Document
00230 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00231 myDocument.setFileLocation("/tmp");
00232 string myFileLocation = myDocument.getFileLocation();
00233 int match;
00234 if ( myFileLocation == "/tmp" )
00235 {
00236 match = 0;
00237 }
00238 else
00239 {
00240 match = 1;
00241 }
00242 assert_eq("get Document file location check", 0, match);
00243 }
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 void testConvertDocument()
00255 {
00256 Broker myBroker;
00257 Document
00258 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00259 if ( myBroker.convertDocument(myDocument) )
00260 {
00261 assert_true( "Conversion results", true );
00262 }
00263 else
00264 {
00265 assert_true( "Conversion results", false );
00266 }
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 void testServerRequestConversion()
00279 {
00280 Server myServer;
00281 Document
00282 myDocument("http://infolab.uvt.nl/people/erics/papers/tech-clearinghouse/tech_clearinghouse.pdf", "pdf2ps");
00283 if ( myServer.requestConversion( myDocument ) )
00284 {
00285 assert_true( "server request conversion check", true );
00286 }
00287 else
00288 {
00289 assert_true( "server request conversion check", false );
00290 }
00291 }
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 void testListConversionDB()
00303 {
00304 Broker myBroker;
00305 Result myDBQuery = myBroker.getConversionListing();
00306 if ( myDBQuery.size() > 0 )
00307 {
00308 assert_true( "list conversions check", true );
00309 }
00310 else
00311 {
00312 assert_true( "list conversions check", false );
00313 }
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 void
00328 testServerRepresentationTypeQuery()
00329 {
00330 Broker myBroker;
00331 string representationTypeTester = "pdf";
00332
00333 Result myRepresentationQuery =
00334 myBroker.getRepresentationTypeListing( representationTypeTester );
00335 if ( myRepresentationQuery.size() > 0 )
00336 {
00337 assert_true( "representation types listing", true );
00338 }
00339 else
00340 {
00341 assert_true( "representation types listing", false );
00342 }
00343 }
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 void
00357 testServerFeatureTypeQuery()
00358 {
00359 Broker myBroker;
00360 string featureTypeTester = "binary";
00361
00362 Result myFeatureQuery =
00363 myBroker.getFeatureTypeListing( featureTypeTester );
00364 if ( myFeatureQuery.size() > 0 )
00365 {
00366 assert_true( "feature types listing", true );
00367 }
00368 else
00369 {
00370 assert_true( "feature types listing", false );
00371 }
00372 }
00373
00374
00375 public:
00376 DocConversionTestSuite() : suite("DocConversionTestSuite")
00377 {
00378 add
00379 ( "BrokerRemoteServer",
00380 testcase( this, "testBrokerRemoteServer",
00381 &DocConversionTestSuite::testBrokerRemoteServer )
00382 );
00383 add
00384 ( "BrokerListConversionDB",
00385 testcase( this, "testListConversionDB",
00386 &DocConversionTestSuite::testListConversionDB )
00387 );
00388 add
00389 ( "DocumentGetDocumentConLocation",
00390 testcase( this, "testGetDocumentConLocation",
00391
00392 &DocConversionTestSuite::testGetDocumentConLocation ) );
00393 add
00394 ( "BrokerDecreaseCounter",
00395 testcase( this, "testDecreaseCounter",
00396 &DocConversionTestSuite::testDecreaseCounter )
00397 );
00398 add
00399 ( "BrokerIncreaseCounter",
00400 testcase( this, "testIncreaseCounter",
00401 &DocConversionTestSuite::testIncreaseCounter )
00402 );
00403 add
00404 ( "BrokerGetCounter",
00405 testcase( this, "testGetCounter",
00406 &DocConversionTestSuite::testGetCounter )
00407 );
00408 add
00409 ( "DocumentGetDocumentUrl",
00410 testcase( this, "testGetDocumentUrl",
00411 &DocConversionTestSuite::testGetDocumentUrl )
00412 );
00413 add
00414 ( "DocumentGetDocumentFile",
00415 testcase( this, "testGetDocumentFile",
00416 &DocConversionTestSuite::testGetDocumentFile )
00417 );
00418 add
00419 ( "DocumentGetDocumentConversion",
00420 testcase( this, "testGetDocumentConversion",
00421 &DocConversionTestSuite::testGetDocumentConversion
00422 ) );
00423 add
00424 ( "DocumentGetDocumentFileLocation",
00425 testcase( this, "testGetDocumentFileLocation",
00426
00427 &DocConversionTestSuite::testGetDocumentFileLocation ) );
00428 add
00429 ( "DocumentConvertDocument",
00430 testcase( this, "testConvertDocument",
00431 &DocConversionTestSuite::testConvertDocument )
00432 );
00433 add
00434 ( "ServerRequestConversion",
00435 testcase( this, "testServerRequestConversion",
00436 &DocConversionTestSuite::testServerRequestConversion ) );
00437 add
00438 ( "ServerRequestRepresentationTypeQuery",
00439 testcase( this, "testServerRepresentationTypeQuery",
00440 &DocConversionTestSuite::testServerRepresentationTypeQuery ) );
00441 add
00442 ( "ServerRequestFeatureTypeQuery",
00443 testcase( this, "testServerFeatureTypeQuery",
00444 &DocConversionTestSuite::testServerFeatureTypeQuery ) );
00445 suite::main().add("DocConversionTestSuite",this);
00446 }
00447
00448 };
00449
00450 DocConversionTestSuite* theDocConversionsTest = new DocConversionTestSuite();
00451 }
00452