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 "Document.h"
00027 #include "Broker.h"
00028
00029 using namespace std;
00030 using namespace unitpp;
00031
00032 namespace
00033 {
00034 class BrokerTestSuite : public suite
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044 void testGetCounter()
00045 {
00046 Broker myBroker;
00047 assert_eq("broker counter check", 1, myBroker.getCounter() );
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 void testIncreaseCounter()
00059 {
00060 Broker myBroker;
00061 assert_eq("initial counter check", 1, myBroker.getCounter() );
00062 Broker anotherBroker;
00063 assert_eq("increase counter check", 2, anotherBroker.getCounter() );
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 void testDecreaseCounter()
00075 {
00076 {
00077 Broker myBroker;
00078 Broker anotherBroker;
00079 int mycounter = anotherBroker.getCounter();
00080 assert_eq("pre decrease counter check", 2, mycounter );
00081 }
00082 Broker yetAnotherBroker;
00083 int yetanothercounter = yetAnotherBroker.getCounter();
00084 assert_eq("decreased counter check", 1, yetanothercounter );
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 void testGetFile()
00097 {
00098 Broker myBroker;
00099 Document myDocument("http://www.google.com/index.html", "html2pdbtxt");
00100 if ( myBroker.getFile(myDocument) )
00101 {
00102 int match;
00103 if ( myDocument.getFileLocation() == "/tmp/index.html" )
00104 {
00105 match = 0;
00106 }
00107 else
00108 {
00109 match = 1;
00110 }
00111 assert_eq( "get file check", 0, match );
00112 }
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 void testGetDocumentUrl()
00125 {
00126 Document myDocument("http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf", "pdf2ps");
00127 string myUrl = myDocument.getDocumentUrl();
00128 int match;
00129 if ( myUrl == "http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf" )
00130 {
00131 match = 0;
00132 }
00133 else
00134 {
00135 match = 1;
00136 }
00137 assert_eq("get Document url check", 0, match);
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 void testGetDocumentFile()
00150 {
00151 Document myDocument("http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf", "pdf2ps");
00152 string myFile = myDocument.getDocumentFile();
00153 int match;
00154 if ( myFile == "tech_clearinghouse.pdf" )
00155 {
00156 match = 0;
00157 }
00158 else
00159 {
00160 match = 1;
00161 }
00162 assert_eq("get Document file check", 0, match);
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 void testGetDocumentConversion()
00175 {
00176 Document myDocument("http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf", "pdf2ps");
00177 string myConversion = myDocument.getDocumentConversion();
00178 int match;
00179 if ( myConversion == "pdf2ps" )
00180 {
00181 match = 0;
00182 }
00183 else
00184 {
00185 match = 1;
00186 }
00187 assert_eq("get Document conversion check", 0, match);
00188 }
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 void testGetDocumentConLocation()
00201 {
00202 Document myDocument("http://infolab.uvt.nl/people/erics/docs/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 myDocument("http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf", "pdf2ps");
00230 myDocument.setFileLocation("/tmp");
00231 string myFileLocation = myDocument.getFileLocation();
00232 int match;
00233 if ( myFileLocation == "/tmp" )
00234 {
00235 match = 0;
00236 }
00237 else
00238 {
00239 match = 1;
00240 }
00241 assert_eq("get Document file location check", 0, match);
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 void testConvertDocument()
00254 {
00255 Broker myBroker;
00256 Document myDocument("http://infolab.uvt.nl/people/erics/docs/tech_clearinghouse.pdf", "pdf2ps");
00257 if ( myBroker.convertDocument(myDocument) )
00258 {
00259 assert_true( "Conversion results", true );
00260 }
00261 else
00262 {
00263 assert_true( "Conversion results", false );
00264 }
00265 }
00266
00267 public:
00268 BrokerTestSuite() : suite("BrokerTestSuite")
00269 {
00270 add
00271 ("DocumentGetDocumentConLocation", testcase(this, "testGetDocumentConLocation",
00272 &BrokerTestSuite::testGetDocumentConLocation));
00273 add
00274 ("BrokerDecreaseCounter", testcase(this, "testDecreaseCounter",
00275 &BrokerTestSuite::testDecreaseCounter));
00276 add
00277 ("BrokerIncreaseCounter", testcase(this, "testIncreaseCounter",
00278 &BrokerTestSuite::testIncreaseCounter));
00279 add
00280 ("BrokerGetCounter", testcase(this, "testGetCounter",
00281 &BrokerTestSuite::testGetCounter));
00282 add
00283 ("BrokerGetFile", testcase(this, "testGetFile",
00284 &BrokerTestSuite::testGetFile));
00285 add
00286 ("DocumentGetDocumentUrl", testcase(this, "testGetDocumentUrl",
00287 &BrokerTestSuite::testGetDocumentUrl));
00288 add
00289 ("DocumentGetDocumentFile", testcase(this, "testGetDocumentFile",
00290 &BrokerTestSuite::testGetDocumentFile));
00291 add
00292 ("DocumentGetDocumentConversion", testcase(this, "testGetDocumentConversion",
00293 &BrokerTestSuite::testGetDocumentConversion));
00294 add
00295 ("DocumentGetDocumentFileLocation", testcase(this, "testGetDocumentFileLocation",
00296 &BrokerTestSuite::testGetDocumentFileLocation));
00297 add
00298 ("DocumentConvertDocument", testcase(this, "testConvertDocument",
00299 &BrokerTestSuite::testConvertDocument));
00300 suite::main().add("BrokerTestSuite",this);
00301 }
00302
00303 };
00304
00305 BrokerTestSuite* theBrokerTest = new BrokerTestSuite();
00306 }
00307