pvolT.cc

Go to the documentation of this file.
00001 // pvolT.cc
00002 
00003 #include <iostream>
00004 
00005 using std::cerr ;
00006 using std::cout ;
00007 using std::endl ;
00008 
00009 #include "pvolT.h"
00010 #include "BESContainerStorageVolatile.h"
00011 #include "BESContainer.h"
00012 #include "TheBESKeys.h"
00013 #include "BESException.h"
00014 #include "BESTextInfo.h"
00015 #include <test_config.h>
00016 
00017 int pvolT::
00018 run(void)
00019 {
00020     cout << endl << "*****************************************" << endl;
00021     cout << "Entered pvolT::run" << endl;
00022     int retVal = 0;
00023 
00024     cout << endl << "*****************************************" << endl;
00025     cout << "Create volatile and add five elements" << endl;
00026     BESContainerStorageVolatile cpv( "volatile" ) ;
00027     cpv.add_container( "sym1", "real1", "type1" ) ;
00028     cpv.add_container( "sym2", "real2", "type2" ) ;
00029     cpv.add_container( "sym3", "real3", "type3" ) ;
00030     cpv.add_container( "sym4", "real4", "type4" ) ;
00031     cpv.add_container( "sym5", "real5", "type5" ) ;
00032 
00033     cout << endl << "*****************************************" << endl;
00034     cout << "show containers" << endl;
00035     BESTextInfo info ;
00036     cpv.show_containers( info ) ;
00037     info.print( cout ) ;
00038 
00039     cout << endl << "*****************************************" << endl;
00040     cout << "try to add sym1 again" << endl;
00041     try
00042     {
00043         cpv.add_container( "sym1", "real1", "type1" ) ;
00044         cerr << "succesfully added sym1 again, bad things man" << endl ;
00045         return 1 ;
00046     }
00047     catch( BESException &e )
00048     {
00049         cout << "unable to add sym1 again, good" << endl ;
00050         cout << e.get_message() << endl ;
00051     }
00052 
00053     {
00054         char s[10] ;
00055         char r[10] ;
00056         char c[10] ;
00057         for( int i = 1; i < 6; i++ )
00058         {
00059             sprintf( s, "sym%d", i ) ;
00060             sprintf( r, "./real%d", i ) ;
00061             sprintf( c, "type%d", i ) ;
00062             cout << endl << "*****************************************" << endl;
00063             cout << "Looking for " << s << endl;
00064             BESContainer *d = cpv.look_for( s ) ;
00065             if( d )
00066             {
00067                 if( d->get_real_name() == r && d->get_container_type() == c )
00068                 {
00069                     cout << "found " << s << endl ;
00070                 }
00071                 else
00072                 {
00073                     cerr << "found " << s << " but:" << endl ;
00074                     cerr << "real = " << r << ", should be " << d->get_real_name() << endl ;
00075                     cerr << "type = " << c << ", should be " << d->get_container_type() << endl ;
00076                     return 1 ;
00077                 }
00078             }
00079             else
00080             {
00081                 cerr << "couldn't find " << s << endl ;
00082                 return 1 ;
00083             }
00084         }
00085     }
00086 
00087     cout << endl << "*****************************************" << endl;
00088     cout << "remove sym1" << endl;
00089     bool rem = cpv.del_container( "sym1" ) ;
00090     if( rem )
00091     {
00092         cout << "successfully removed sym1" << endl ;
00093     }
00094 
00095     {
00096         cout << endl << "*****************************************" << endl;
00097         cout << "find sym1" << endl;
00098         BESContainer *d = cpv.look_for( "sym1" ) ;
00099         if( d )
00100         {
00101             cerr << "found " << d->get_symbolic_name() << " with "
00102                  << "real = " << d->get_real_name() << " and "
00103                  << "type = " << d->get_container_type() << endl ;
00104             return 1 ;
00105         }
00106         else
00107         {
00108             cout << "didn't remove it, good" << endl ;
00109         }
00110     }
00111 
00112     cout << endl << "*****************************************" << endl;
00113     cout << "remove sym5" << endl;
00114     rem = cpv.del_container( "sym5" ) ;
00115     if( rem )
00116     {
00117         cout << "successfully removed sym5" << endl ;
00118     }
00119 
00120     {
00121         cout << endl << "*****************************************" << endl;
00122         cout << "find sym5" << endl;
00123         BESContainer *d = cpv.look_for( "sym5" ) ;
00124         if( d )
00125         {
00126             cerr << "found " << d->get_symbolic_name() << " with "
00127                  << "real = " << d->get_real_name() << " and "
00128                  << "type = " << d->get_container_type() << endl ;
00129             return 1 ;
00130         }
00131         else
00132         {
00133             cout << "didn't remove it, good" << endl ;
00134         }
00135     }
00136 
00137     cout << endl << "*****************************************" << endl;
00138     cout << "remove nosym" << endl;
00139     rem = cpv.del_container( "nosym" ) ;
00140     if( !rem )
00141     {
00142         cout << "didn't find nosym, good" << endl ;
00143     }
00144     else
00145     {
00146         cerr << "removed a container, bad things man" << endl ;
00147         return 1 ;
00148     }
00149 
00150     {
00151         char s[10] ;
00152         char r[10] ;
00153         char c[10] ;
00154         for( int i = 2; i < 5; i++ )
00155         {
00156             sprintf( s, "sym%d", i ) ;
00157             sprintf( r, "./real%d", i ) ;
00158             sprintf( c, "type%d", i ) ;
00159             cout << endl << "*****************************************" << endl;
00160             cout << "Looking for " << s << endl;
00161             BESContainer *d = cpv.look_for( s ) ;
00162             if( d )
00163             {
00164                 if( d->get_real_name() == r && d->get_container_type() == c )
00165                 {
00166                     cout << "found " << s << endl ;
00167                 }
00168                 else
00169                 {
00170                     cerr << "found " << s << " but real = " << r
00171                          << " and container = " << c << endl ;
00172                     return 1 ;
00173                 }
00174             }
00175             else
00176             {
00177                 cerr << "couldn't find " << s << endl ;
00178                 return 1 ;
00179             }
00180         }
00181     }
00182 
00183     cout << endl << "*****************************************" << endl;
00184     cout << "show containers" << endl;
00185     BESTextInfo info2 ;
00186     cpv.show_containers( info2 ) ;
00187     info2.print( cout ) ;
00188 
00189     cout << endl << "*****************************************" << endl;
00190     cout << "Returning from pvolT::run" << endl;
00191     return retVal;
00192 }
00193 
00194 int
00195 main(int argC, char **argV) {
00196     string env_var = (string)"BES_CONF=" + TEST_SRC_DIR
00197                      + "/persistence_cgi_test.ini" ;
00198     putenv( (char *)env_var.c_str() ) ;
00199     Application *app = new pvolT();
00200     return app->main(argC, argV);
00201 }
00202 

Generated on Sat Jan 19 04:05:37 2008 for OPeNDAP Back End Server (BES) by  doxygen 1.5.4