// make_atlaspool_datset_t.cxx #include #include #include "dataset_util/FileStatus.h" #include "dataset_util/getcwd.h" #include "dataset_util/ssystem.h" #include "dataset_util/FileFinder.h" #include "dataset_util/DtdRegistry.h" #include "dataset_xml/XmlParser.h" #include "dataset_id/SimpleUniqueIdGenerator.h" #include "dataset_credential/CredentialSelectionCatalog.h" #include "dataset_credential/GssCredentialManager.h" #include "dataset_base/DatasetCreator.h" #include "dataset_atlaspool/AtlasPoolEventDataset.h" using std::string; using std::cout; using std::endl; using dset::CredentialSelectionCatalog; using dset::GssCredentialManager; using dset::Dataset; using dset::DatasetCreator; using dset::AtlasPoolEventDataset; namespace { void msg(string txt) { cout << "*** "; cout << txt; cout << endl; } } int make_atlaspool_dataset_t() { msg("Testing make_atlaspool_datset"); msg("Set ID generator"); SimpleUniqueIdGenerator::create_collection("Dataset", 501, 0); SimpleUniqueIdGenerator::set_as_default(); string conn = SimpleUniqueIdGenerator::connection(); assert( conn.size() ); msg("Fetch default instance of CSC."); assert( CredentialSelectionCatalog::create_default_instance() == 0 ); CredentialSelectionCatalog& sc = CredentialSelectionCatalog::default_instance(); cout << sc << endl; assert( sc.is_valid() ); string owner = "me"; assert( GssCredentialManager::set_default() == 0 ); assert( GssCredentialManager::set_owner("me") == 0 ); string com0 = "DIAL_CATALOG_CONF=" + getcwd() + "/resolver.dat; " + "export DIAL_CATALOG_CONF; "; msg("Display help message"); int stat = system("make_atlaspool_dataset -h"); assert( stat == 0 ); msg("Find and copy pool file"); string fname = "LArSimTest.root"; FileFinder fnd(getcwd(), 5, -1); string full_fname = fnd.find(fname); assert( full_fname.size() != 0 ); cout << full_fname << endl; ssystem("cp " + full_fname + " ."); assert( FileStatus(fname).is_readable() ); msg("Run command to create dataset"); string com = com0; com += "make_atlaspool_dataset -c ESD"; com += " -u SimpleUniqueIdGenerator:UniqueId::"; com += " -l " + fname; stat = ssystem(com); assert( stat == 0 ); msg("Check file exists"); string xfile = "dataset.xml"; assert( FileStatus(xfile).is_readable() ); msg("Create DTD"); DtdRegistry& dtdreg = DtdRegistry::instance("dataset"); dtdreg.write(); msg("Read dataset"); const XmlElement* pele = XmlParser().parse(xfile); assert( pele != 0 ); const Dataset* pdst = DatasetCreator::create(*pele); assert( pdst != 0 ); cout << *pdst << endl; delete pele; assert( pdst->is_valid() ); assert( pdst->is_locked() ); assert( pdst->id().is_global() ); msg("Cast to AtlasPoolEventDataset"); const AtlasPoolEventDataset* pcdst = dynamic_cast(pdst); assert( pcdst != 0 ); cout << *pcdst << endl; msg("Write a copy of the xml"); const XmlElement* pxdst = pdst->xml(); assert( pxdst != 0 ); cout << *pxdst << endl; assert( XmlParser().write("copy.xml", *pxdst) == 0); delete pdst; return 0; } #ifdef CTEST_MAIN int main() { return make_atlaspool_dataset_t(); } #endif