Back to index

nordugrid-arc-nox  1.1.0~rc6
SoftwareTest.cpp
Go to the documentation of this file.
00001 #include <cppunit/extensions/HelperMacros.h>
00002 
00003 #include <list>
00004 
00005 #include <arc/Logger.h>
00006 #include <arc/client/Software.h>
00007 #include <arc/client/ExecutionTarget.h>
00008 
00009 #define SV Arc::Software
00010 #define SR Arc::SoftwareRequirement
00011 
00012 class SoftwareTest
00013   : public CppUnit::TestFixture {
00014 
00015   CPPUNIT_TEST_SUITE(SoftwareTest);
00016   CPPUNIT_TEST(EqualityTest);
00017   CPPUNIT_TEST(ComparisonTest);
00018   CPPUNIT_TEST(BasicRequirementsTest);
00019   CPPUNIT_TEST(RequirementsAndTest);
00020   CPPUNIT_TEST(RequirementsOrTest);
00021   CPPUNIT_TEST(RequirementsNotTest);
00022   CPPUNIT_TEST(RequirementsGreaterThanTest);
00023   CPPUNIT_TEST(RequirementsLessThanTest);
00024   CPPUNIT_TEST(RequirementsRangeTest);
00025   CPPUNIT_TEST(RequirementsGreaterThanAndTest);
00026   CPPUNIT_TEST(RequirementsLessThanAndTest);
00027   CPPUNIT_TEST(ApplicationEnvironmentCastTest);
00028   CPPUNIT_TEST_SUITE_END();
00029 
00030 public:
00031   SoftwareTest()
00032     : logger(Arc::Logger::getRootLogger(), "SoftwareTest"),
00033       logcerr(std::cerr) {}
00034   void setUp();
00035   void tearDown();
00036   void EqualityTest();
00037   void ComparisonTest();
00038   void BasicRequirementsTest();
00039   void RequirementsAndTest();
00040   void RequirementsOrTest();
00041   void RequirementsNotTest();
00042   void RequirementsGreaterThanTest();
00043   void RequirementsLessThanTest();
00044   void RequirementsRangeTest();
00045   void RequirementsGreaterThanAndTest();
00046   void RequirementsLessThanAndTest();
00047   void ApplicationEnvironmentCastTest();
00048 
00049 private:
00050   Arc::LogStream logcerr;
00051   Arc::Logger logger;
00052   std::list<SV> versions;
00053 };
00054 
00055 
00056 void SoftwareTest::setUp() {
00057   Arc::Logger::getRootLogger().setThreshold(Arc::WARNING);
00058   Arc::Logger::getRootLogger().addDestination(logcerr);
00059 }
00060 
00061 void SoftwareTest::tearDown() {
00062 }
00063 
00064 void SoftwareTest::EqualityTest() {
00065   CPPUNIT_ASSERT(SV("XX") == SV("XX"));
00066   CPPUNIT_ASSERT(!(SV("XX") != SV("XX")));
00067   CPPUNIT_ASSERT(!(SV("XX-YY") != SV("XX.YY")));
00068   CPPUNIT_ASSERT(!(SV("XX") != SV("YY")));
00069   CPPUNIT_ASSERT(!(SV("XX-1.2") != SV("XX")));
00070   CPPUNIT_ASSERT(!(SV("XX") != SV("XX-1.2")));
00071   CPPUNIT_ASSERT(!(SV("XX-1.2") != SV("XX-1.2")));
00072   CPPUNIT_ASSERT(SV("XX-1.2") != SV("XX-1.3"));
00073 }
00074 
00075 void SoftwareTest::ComparisonTest() {
00076   CPPUNIT_ASSERT(!(SV("XX-YY") < SV("XX-YY-ZZ")));
00077   CPPUNIT_ASSERT(!(SV("XX-YY") > SV("XX-YY-ZZ")));
00078   CPPUNIT_ASSERT(!(SV("XX-YY-ZZ") < SV("XX-YY")));
00079   CPPUNIT_ASSERT(!(SV("XX-YY-ZZ") > SV("XX-YY")));
00080 
00081   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3.ZZ.4") > SV("XX-YY-1.2.3.ZZ.4")));
00082   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3.ZZ.4") < SV("XX-YY-1.2.3.ZZ.4")));
00083   CPPUNIT_ASSERT(SV("XX-YY-1.4.3.ZZ.4") > SV("XX-YY-1.2.3.ZZ.4"));
00084   CPPUNIT_ASSERT(SV("XX-YY-1.2.3.ZZ.4") < SV("XX-YY-1.4.3.ZZ.4"));
00085   CPPUNIT_ASSERT(SV("XX-YY-1.2.3.ZZ.4") < SV("XX-YY-1.2.3.ZZ.10"));
00086   CPPUNIT_ASSERT(SV("XX-YY-1.3.3.ZZ.4") > SV("XX-YY-1.2.7.ZZ.4"));
00087   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3.ZZ1.4") > SV("XX-YY-1.2.3.ZZ2.4")));
00088   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3.ZZ1.4") < SV("XX-YY-1.2.3.ZZ2.4")));
00089 
00090   CPPUNIT_ASSERT(SV("XX-YY-1.2.3") < SV("XX-YY-1-2-3-4"));
00091   CPPUNIT_ASSERT(SV("XX-YY-1.2.3.4") > SV("XX-YY-1-2-3"));
00092   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3.4") < SV("XX-YY-1-2-3")));
00093   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3") > SV("XX-YY-1-2-3-4")));
00094 
00095   CPPUNIT_ASSERT(SV("XX-YY-1.2") < SV("XX-YY-1.2.3"));
00096   CPPUNIT_ASSERT(SV("XX-YY-1.2.3") > SV("XX-YY-1.2"));
00097   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.ZZ") > SV("XX-YY-1.2")));
00098   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3") < SV("XX-YY-1.2.ZZ")));
00099 
00100   CPPUNIT_ASSERT(SV("XX-YY-1.3") > SV("XX-YY-1.2.3"));
00101   CPPUNIT_ASSERT(SV("XX-YY-1.2.3") < SV("XX-YY-1.3"));
00102   CPPUNIT_ASSERT(SV("XX-YY-1.2.3") > SV("XX-YY-1.2"));
00103   CPPUNIT_ASSERT(SV("XX-YY-1.2") < SV("XX-YY-1.2.3"));
00104   CPPUNIT_ASSERT(!(SV("XX-YY-1.2") > SV("XX-YY-1.2.3")));
00105   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3") < SV("XX-YY-1.2")));
00106   CPPUNIT_ASSERT(!(SV("XX-YY-1.2") < SV("XX-YY-1.2.ZZ")));
00107   CPPUNIT_ASSERT(!(SV("XX-YY-1.2") > SV("XX-YY-1.2.ZZ")));
00108   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.ZZ") < SV("XX-YY-1.2")));
00109   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.ZZ") > SV("XX-YY-1.2")));
00110 
00111   CPPUNIT_ASSERT(SV("XX-YY-1.3.2") > SV("XX-YY-1.2.3"));
00112   CPPUNIT_ASSERT(!(SV("XX-YY-1.3.2") < SV("XX-YY-1.2.3")));
00113   CPPUNIT_ASSERT(SV("XX-YY-1.2.3") < SV("XX-YY-1.3.2"));
00114   CPPUNIT_ASSERT(!(SV("XX-YY-1.2.3") > SV("XX-YY-1.3.2")));
00115 }
00116 
00117 void SoftwareTest::BasicRequirementsTest() {
00118   versions.push_back(SV("A-1.03"));
00119 
00120   CPPUNIT_ASSERT(SR(versions.back()).isSatisfied(versions));
00121   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator!=).isSatisfied(versions));
00122   CPPUNIT_ASSERT(SR(versions.back(), &SV::operator<=).isSatisfied(versions));
00123   CPPUNIT_ASSERT(SR(versions.back(), &SV::operator>=).isSatisfied(versions));
00124   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator> ).isSatisfied(versions));
00125   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator< ).isSatisfied(versions));
00126 
00127   CPPUNIT_ASSERT(!SR(SV("A-1.5")).isSatisfied(versions));
00128   CPPUNIT_ASSERT(SR(SV("A-1.5"), &SV::operator !=).isSatisfied(versions));
00129 
00130   CPPUNIT_ASSERT(SR(versions.back(), &SV::operator==, false).isSatisfied(versions));
00131   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator!=, false).isSatisfied(versions));
00132   CPPUNIT_ASSERT(SR(versions.back(), &SV::operator<=, false).isSatisfied(versions));
00133   CPPUNIT_ASSERT(SR(versions.back(), &SV::operator>=, false).isSatisfied(versions));
00134   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator>, false).isSatisfied(versions));
00135   CPPUNIT_ASSERT(!SR(versions.back(), &SV::operator<, false).isSatisfied(versions));
00136 
00137   CPPUNIT_ASSERT(!SR(SV("A-1.5"), &SV::operator==, false).isSatisfied(versions));
00138   CPPUNIT_ASSERT(SR(SV("A-1.5"), &SV::operator!=, false).isSatisfied(versions));
00139 }
00140 
00141 void SoftwareTest::RequirementsAndTest() {
00142   SR sr(true); sr.add(SV("A-1.03")); sr.add(SV("B-2.12"));
00143 
00144   versions.push_back(SV("A-1.03"));
00145   versions.push_back(SV("B-2.12"));
00146   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00147   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00148   CPPUNIT_ASSERT_EQUAL(2, (int) sr.getSoftwareList().size());
00149   CPPUNIT_ASSERT(sr.isResolved());
00150   versions.clear();
00151 }
00152 
00153 void SoftwareTest::RequirementsOrTest() {
00154   SR sr(false);
00155 
00156   // Test: A-3.83 OR A-3.84
00157   sr.add(SV("A-3.83")); sr.add(SV("A-3.84"));
00158   versions.push_back(SV("A-3.83"));
00159   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00160   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00161   CPPUNIT_ASSERT_EQUAL(1, (int) sr.getSoftwareList().size()); // Only 1 software should be chosen.
00162   CPPUNIT_ASSERT_EQUAL(versions.front(), sr.getSoftwareList().front()); // The chosen software should equal the one from the list.
00163   CPPUNIT_ASSERT(sr.isResolved());
00164   versions.clear();
00165   sr.clear();
00166 
00167   // Test: Order should have no influence.
00168   sr.add(SV("A-3.83"));
00169   sr.add(SV("A-3.84"));
00170   versions.push_back(SV("A-3.84"));
00171   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00172   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00173   CPPUNIT_ASSERT_EQUAL(1, (int) sr.getSoftwareList().size());
00174   CPPUNIT_ASSERT_EQUAL(versions.front(), sr.getSoftwareList().front());
00175   CPPUNIT_ASSERT(sr.isResolved());
00176   versions.clear();
00177   sr.clear();
00178 
00179   // Test if chosen software has highest version number.
00180   sr.add(SV("A-3.83"));
00181   sr.add(SV("A-3.84"));
00182   versions.push_back(SV("A-3.83"));
00183   versions.push_back(SV("A-3.84"));
00184   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00185   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00186   CPPUNIT_ASSERT_EQUAL(1, (int) sr.getSoftwareList().size());
00187   CPPUNIT_ASSERT_EQUAL(versions.back(), sr.getSoftwareList().front());
00188   CPPUNIT_ASSERT(sr.isResolved());
00189   versions.clear();
00190 }
00191 
00192 void SoftwareTest::RequirementsNotTest() {
00193   SR sr(false);
00194 
00195   sr.add(SV("A-1.3"), &Arc::Software::operator!=);
00196   versions.push_back(SV("A-1.3"));
00197   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00198   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00199   CPPUNIT_ASSERT(!sr.isResolved());
00200   versions.push_back(SV("A-1.2"));
00201   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00202   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00203   CPPUNIT_ASSERT_EQUAL(1, (int) sr.getSoftwareList().size());
00204   CPPUNIT_ASSERT_EQUAL(SV("A-1.2"), sr.getSoftwareList().front());
00205   CPPUNIT_ASSERT(sr.isResolved());
00206   versions.clear();
00207   sr.clear();
00208 
00209   versions.push_back(SV("B-2"));
00210   sr.add(SV("A-1.3"), &Arc::Software::operator!=);
00211   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00212   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00213   CPPUNIT_ASSERT(!sr.isResolved());
00214   sr.clear();
00215 
00216   versions.push_back(SV("B-3"));
00217   versions.push_back(SV("A-1.2"));
00218   versions.push_back(SV("A-1.3"));
00219   sr.setRequirement(true);
00220   sr.add(SV("A-1.3"), &Arc::Software::operator!=);
00221   sr.add(SV("B-2"), &Arc::Software::operator!=);
00222   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00223   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00224   CPPUNIT_ASSERT_EQUAL(2, (int) sr.getSoftwareList().size());
00225   CPPUNIT_ASSERT(SV("A-1.2") == sr.getSoftwareList().front() ||
00226                  SV("A-1.2") == sr.getSoftwareList().back());
00227   CPPUNIT_ASSERT(SV("B-3") == sr.getSoftwareList().front() ||
00228                  SV("B-3") == sr.getSoftwareList().back());
00229   CPPUNIT_ASSERT(sr.isResolved());
00230   versions.clear();
00231 }
00232 
00233 void SoftwareTest::RequirementsGreaterThanTest() {
00234   SR sr1(true), sr2(true);
00235 
00236   sr1.add(SV("A-1.3"), &Arc::Software::operator>);
00237   sr2.add(SV("A-1.3"), &Arc::Software::operator>=);
00238   versions.push_back(SV("A-1.2"));
00239   // A-1.2 > A-1.3 => false.
00240   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00241   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00242   CPPUNIT_ASSERT(!sr1.isResolved());
00243   // A-1.2 >= A-1.3 => false.
00244   CPPUNIT_ASSERT(!sr2.isSatisfied(versions));
00245   CPPUNIT_ASSERT(!sr2.selectSoftware(versions));
00246   CPPUNIT_ASSERT(!sr2.isResolved());
00247   versions.push_back(SV("A-1.3"));
00248   // {A-1.2 , A-1.3} > A-1.3 => false.
00249   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00250   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00251   CPPUNIT_ASSERT(!sr1.isResolved());
00252   // {A-1.2 , A-1.3} >= A-1.3 => true.
00253   CPPUNIT_ASSERT(sr2.isSatisfied(versions));
00254   CPPUNIT_ASSERT(sr2.selectSoftware(versions));
00255   // A-1.3 should be selected.
00256   CPPUNIT_ASSERT_EQUAL(1, (int) sr2.getSoftwareList().size());
00257   CPPUNIT_ASSERT_EQUAL(SV("A-1.3"), sr2.getSoftwareList().front());
00258   CPPUNIT_ASSERT(sr2.isResolved());
00259   sr2.clear();
00260   sr2.add(SV("A-1.3"), &Arc::Software::operator>=);
00261   versions.push_back(SV("A-1.4"));
00262   // {A-1.2 , A-1.3 , A-1.4} > A-1.3 => true.
00263   CPPUNIT_ASSERT(sr1.isSatisfied(versions));
00264   CPPUNIT_ASSERT(sr1.selectSoftware(versions));
00265   // A-1.4 should be selected.
00266   CPPUNIT_ASSERT_EQUAL(1, (int) sr1.getSoftwareList().size());
00267   CPPUNIT_ASSERT_EQUAL(SV("A-1.4"), sr1.getSoftwareList().front());
00268   CPPUNIT_ASSERT(sr1.isResolved());
00269   // {A-1.2 , A-1.3 , A-1.4} >= A-1.3 => true.
00270   CPPUNIT_ASSERT(sr2.isSatisfied(versions));
00271   CPPUNIT_ASSERT(sr2.selectSoftware(versions));
00272   // A-1.4 should be selected.
00273   CPPUNIT_ASSERT_EQUAL(1, (int) sr2.getSoftwareList().size());
00274   CPPUNIT_ASSERT_EQUAL(SV("A-1.4"), sr2.getSoftwareList().front());
00275   CPPUNIT_ASSERT(sr2.isResolved());
00276 
00277   sr1.clear();
00278   sr1.add(SV("A-1.3"), &Arc::Software::operator>);
00279   sr1.add(SV("A-1.4"), &Arc::Software::operator!=);
00280   /*
00281    * {A-1.2 , A-1.3 , A-1.4} >  A-1.3 &&
00282    *                         != A-1.4    => false.
00283    */
00284   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00285   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00286   CPPUNIT_ASSERT(!sr1.isResolved());
00287   versions.push_back(SV("A-1.4.2"));
00288   /*
00289    * {A-1.2 , A-1.3 , A-1.4 , A-1.4.2} >  A-1.3 &&
00290    *                                   != A-1.4    => true.
00291    */
00292   CPPUNIT_ASSERT(sr1.isSatisfied(versions));
00293   CPPUNIT_ASSERT(sr1.selectSoftware(versions));
00294   // A-1.4.2 should be selected.
00295   CPPUNIT_ASSERT_EQUAL(1, (int) sr1.getSoftwareList().size());
00296   CPPUNIT_ASSERT_EQUAL(SV("A-1.4.2"), sr1.getSoftwareList().front());
00297   CPPUNIT_ASSERT(sr1.isResolved());
00298   sr1.clear();
00299   versions.clear();
00300 }
00301 
00302 void SoftwareTest::RequirementsLessThanTest() {
00303   SR sr1(true), sr2(true);
00304 
00305   sr1.add(SV("A-1.3"), &Arc::Software::operator<);
00306   sr2.add(SV("A-1.3"), &Arc::Software::operator<=);
00307   versions.push_back(SV("A-1.4"));
00308   // A-1.2 > A-1.3 => false.
00309   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00310   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00311   CPPUNIT_ASSERT(!sr1.isResolved());
00312   // A-1.2 >= A-1.3 => false.
00313   CPPUNIT_ASSERT(!sr2.isSatisfied(versions));
00314   CPPUNIT_ASSERT(!sr2.selectSoftware(versions));
00315   CPPUNIT_ASSERT(!sr2.isResolved());
00316   versions.push_back(SV("A-1.3"));
00317   // {A-1.2 , A-1.3} > A-1.3 => false.
00318   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00319   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00320   CPPUNIT_ASSERT(!sr1.isResolved());
00321   // {A-1.2 , A-1.3} >= A-1.3 => true.
00322   CPPUNIT_ASSERT(sr2.isSatisfied(versions));
00323   CPPUNIT_ASSERT(sr2.selectSoftware(versions));
00324   // A-1.3 should be selected.
00325   CPPUNIT_ASSERT_EQUAL(1, (int) sr2.getSoftwareList().size());
00326   CPPUNIT_ASSERT_EQUAL(SV("A-1.3"), sr2.getSoftwareList().front());
00327   CPPUNIT_ASSERT(sr2.isResolved());
00328   sr2.clear();
00329   sr2.add(SV("A-1.3"), &Arc::Software::operator<=);
00330   versions.push_back(SV("A-1.2"));
00331   // {A-1.2 , A-1.3 , A-1.4} > A-1.3 => true.
00332   CPPUNIT_ASSERT(sr1.isSatisfied(versions));
00333   CPPUNIT_ASSERT(sr1.selectSoftware(versions));
00334   // A-1.2 should be selected.
00335   CPPUNIT_ASSERT_EQUAL(1, (int) sr1.getSoftwareList().size());
00336   CPPUNIT_ASSERT_EQUAL(SV("A-1.2"), sr1.getSoftwareList().front());
00337   CPPUNIT_ASSERT(sr1.isResolved());
00338   // {A-1.2 , A-1.3 , A-1.4} >= A-1.3 => true.
00339   CPPUNIT_ASSERT(sr2.isSatisfied(versions));
00340   CPPUNIT_ASSERT(sr2.selectSoftware(versions));
00341   // A-1.3 should be selected.
00342   CPPUNIT_ASSERT_EQUAL(1, (int) sr2.getSoftwareList().size());
00343   CPPUNIT_ASSERT_EQUAL(SV("A-1.3"), sr2.getSoftwareList().front());
00344   CPPUNIT_ASSERT(sr2.isResolved());
00345 
00346   sr1.clear();
00347   sr1.add(SV("A-1.3"), &Arc::Software::operator<);
00348   sr1.add(SV("A-1.2"), &Arc::Software::operator!=);
00349   /*
00350    * {A-1.2 , A-1.3 , A-1.4} <  A-1.3 &&
00351    *                         != A-1.2    => false.
00352    */
00353   CPPUNIT_ASSERT(!sr1.isSatisfied(versions));
00354   CPPUNIT_ASSERT(!sr1.selectSoftware(versions));
00355   CPPUNIT_ASSERT(!sr1.isResolved());
00356   versions.push_back(SV("A-1.1.5"));
00357   /*
00358    * {A-1.1.5 , A-1.2 , A-1.3 , A-1.4} <  A-1.3 &&
00359    *                                   != A-1.2    => true.
00360    */
00361   CPPUNIT_ASSERT(sr1.isSatisfied(versions));
00362   CPPUNIT_ASSERT(sr1.selectSoftware(versions));
00363   // A-1.1.5 should be selected.
00364   CPPUNIT_ASSERT_EQUAL(1, (int) sr1.getSoftwareList().size());
00365   CPPUNIT_ASSERT_EQUAL(SV("A-1.1.5"), sr1.getSoftwareList().front());
00366   CPPUNIT_ASSERT(sr1.isResolved());
00367   sr1.clear();
00368   versions.clear();
00369 }
00370 
00371 void SoftwareTest::RequirementsRangeTest() {
00372   SR sr(true);
00373 
00374   sr.add(SV("A-4.17"), &Arc::Software::operator>);
00375   sr.add(SV("A-5.0"), &Arc::Software::operator<);
00376   versions.push_back(SV("A-4.16"));
00377   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00378   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00379   CPPUNIT_ASSERT(!sr.isResolved());
00380   versions.push_back(SV("A-5.1"));
00381   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00382   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00383   CPPUNIT_ASSERT(!sr.isResolved());
00384   versions.push_back(SV("A-4.20"));
00385   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00386   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00387   CPPUNIT_ASSERT_EQUAL(1, (int) sr.getSoftwareList().size());
00388   CPPUNIT_ASSERT_EQUAL(SV("A-4.20"), sr.getSoftwareList().front());
00389   CPPUNIT_ASSERT(sr.isResolved());
00390   versions.clear();
00391   sr.clear();
00392 }
00393 
00394 void SoftwareTest::RequirementsGreaterThanAndTest() {
00395   SR sr(true);
00396 
00397   sr.add(SV("A-4.17"), &Arc::Software::operator>);
00398   sr.add(SV("B-0.15"), &Arc::Software::operator>);
00399   versions.push_back(SV("A-4.16"));
00400   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00401   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00402   CPPUNIT_ASSERT(!sr.isResolved());
00403   versions.push_back(SV("A-4.18"));
00404   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00405   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00406   CPPUNIT_ASSERT(!sr.isResolved());
00407   versions.push_back(SV("B-0.10"));
00408   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00409   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00410   CPPUNIT_ASSERT(!sr.isResolved());
00411   versions.push_back(SV("B-0.20"));
00412   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00413   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00414   CPPUNIT_ASSERT_EQUAL(2, (int) sr.getSoftwareList().size());
00415   CPPUNIT_ASSERT(SV("A-4.18") == sr.getSoftwareList().front() ||
00416                  SV("A-4.18") == sr.getSoftwareList().back());
00417   CPPUNIT_ASSERT(SV("B-0.20") == sr.getSoftwareList().front() ||
00418                  SV("B-0.20") == sr.getSoftwareList().back());
00419   CPPUNIT_ASSERT(sr.isResolved());
00420   versions.clear();
00421   sr.clear();
00422 }
00423 
00424 void SoftwareTest::RequirementsLessThanAndTest() {
00425   SR sr(true);
00426 
00427   sr.add(SV("A-4.17"), &Arc::Software::operator<);
00428   sr.add(SV("B-0.15"), &Arc::Software::operator<);
00429   versions.push_back(SV("A-4.18"));
00430   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00431   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00432   CPPUNIT_ASSERT(!sr.isResolved());
00433   versions.push_back(SV("A-4.16"));
00434   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00435   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00436   CPPUNIT_ASSERT(!sr.isResolved());
00437   versions.push_back(SV("B-0.20"));
00438   CPPUNIT_ASSERT(!sr.isSatisfied(versions));
00439   CPPUNIT_ASSERT(!sr.selectSoftware(versions));
00440   CPPUNIT_ASSERT(!sr.isResolved());
00441   versions.push_back(SV("B-0.10"));
00442   CPPUNIT_ASSERT(sr.isSatisfied(versions));
00443   CPPUNIT_ASSERT(sr.selectSoftware(versions));
00444   CPPUNIT_ASSERT_EQUAL(2, (int) sr.getSoftwareList().size());
00445   CPPUNIT_ASSERT(SV("A-4.16") == sr.getSoftwareList().front() ||
00446                  SV("A-4.16") == sr.getSoftwareList().back());
00447   CPPUNIT_ASSERT(SV("B-0.10") == sr.getSoftwareList().front() ||
00448                  SV("B-0.10") == sr.getSoftwareList().back());
00449   CPPUNIT_ASSERT(sr.isResolved());
00450   versions.clear();
00451   sr.clear();
00452 }
00453 
00454 void SoftwareTest::ApplicationEnvironmentCastTest() {
00455   std::list<Arc::ApplicationEnvironment> appEnvs(1, Arc::ApplicationEnvironment("TEST", "1.0"));
00456   const std::list<Arc::Software>& sw = reinterpret_cast< const std::list<SV>& >(appEnvs);
00457   CPPUNIT_ASSERT_EQUAL(static_cast<SV>(appEnvs.front()), sw.front());
00458 }
00459 
00460 CPPUNIT_TEST_SUITE_REGISTRATION(SoftwareTest);