void KmfCppTest::testKmfLoader() { DefaultkevoreeFactory factory; JSONModelLoader loader; loader.setFactory(&factory); ifstream myfile; myfile.open ("model1.json"); if(!myfile){ cout << "no file trace" << endl; } CPPUNIT_ASSERT(myfile != NULL); ContainerRoot *model = (ContainerRoot*)loader.loadModelFromStream(myfile)->front(); CPPUNIT_ASSERT(model != NULL); CPPUNIT_ASSERT(model->nodes.size() ==1); CPPUNIT_ASSERT(model->groups.size() ==2); CPPUNIT_ASSERT( model->findByPath("nodes[node0]") != NULL); ContainerNode *node = (ContainerNode*)model->findByPath("nodes[node0]"); CPPUNIT_ASSERT( node->name.compare("node0") == 0); delete model; }
void MergeResolver::merge(ContainerRoot *model, std::string type, std::string url){ if(type.compare("mvn") == 0) { std::list<std::string> urls; std::map<std::string, Repository*> map = model->repositories ; for(std::map<std::string, Repository*>::iterator it = model->repositories.begin(); it != model->repositories.end(); ++it) { string url = it->first ; urls.push_back(url) ; } // FIX ME USAGE THE GLOBAL maven::resolver::MavenResolver mvnResol; boost::filesystem::path temp = boost::filesystem::temp_directory_path(); const std::string tempstr = temp.native()+"/.m2"; mvnResol.setBasePath(tempstr); // FIX ME std::vector<string> splitted_chain; Utils::split(splitted_chain , url ,":") ; JSONModelLoader loader; string file = mvnResol.resolve(splitted_chain.at(0),splitted_chain.at(1),splitted_chain.at(2),"json",urls) ; ifstream target; target.open (file); if(!target){ throw KevoreeException("\nTypedefinition <"+splitted_chain.at(1)+"> not found in repositories"); } LOGGER_WRITE(Logger::DEBUG,"TypeDefintion found " + splitted_chain.at(1)); DefaultkevoreeFactory factory; loader.setFactory(&factory) ; ContainerRoot *remote = (ContainerRoot*) loader.loadModelFromStream(target)->front(); ModelCompare *compare= new ModelCompare(); TraceSequence* trace = compare->merge(model,remote); //LOGGER_WRITE(Logger::DEBUG,"Merge trace " + trace->exportToString()); ModelTraceApplicator* MTA = new ModelTraceApplicator(model,&factory) ; MTA->applyTraceOnModel(trace); delete MTA ; delete remote ; delete compare ; }else { LOGGER_WRITE(Logger::WARNING,"Not resolved typeDef" + url); } }
void KevScriptTest::theUltimeTest(){ DefaultkevoreeFactory factory; JSONModelLoader loader; JSONModelSerializer jml ; KevScriptEngine kse; ContainerRoot *model=NULL; ifstream f; f.open ("./dataTest/KevScriptTest/kevscriptKevCPP.kevs"); loader.setFactory(&factory); ifstream json_file; json_file.open ("./dataTest/KevScriptTest/model_to_check.json"); if(!json_file){ cout << "no json_file trace" << endl; } ContainerRoot *model_to_compare = (ContainerRoot*)loader.loadModelFromStream(json_file)->front(); CPPUNIT_ASSERT(model_to_compare !=NULL); try { model = factory.createContainerRoot(); CPPUNIT_ASSERT(model !=NULL); if(f){ kse.executeFromStream(f,model); ofstream myfile; myfile.open ("/Users/Aymeric/Documents/dev_Kevoree/kevoree-cpp/debug/bin/kev.json"); myfile << jml.serialize(model); myfile.close(); ModelCompare *compare= new ModelCompare(); list<ModelTrace*>* lst2 =model->toTraces(true, true) ; for(list<ModelTrace*>::iterator it = lst2->begin() ; it != lst2->end(); ++it){ ModelTrace* mt = *it ; //cout << mt->toString()<< endl ; } // cout <<"-----------"<< endl ; lst2 =model_to_compare->toTraces(true, true) ; for(list<ModelTrace*>::iterator it = lst2->begin() ; it != lst2->end(); ++it){ ModelTrace* mt = *it ; //cout << mt->toString()<< endl ; } // cout <<"-----------"<< endl ; // FIX ME TraceSequence *sequencediff = compare->diff(model,model_to_compare); list<ModelTrace*> lst = sequencediff->traces; //cout <<sequencediff->traces.size() << endl ; for(list<ModelTrace*>::iterator it = lst.begin() ; it != lst.end(); ++it){ ModelTrace* mt = *it ; //cout << mt->toString()<< endl ; } CPPUNIT_ASSERT(sequencediff->traces.size() != 0); delete compare; delete sequencediff; } } catch(std::exception const& e) { LOGGER_WRITE(Logger::ERROR," "+string(e.what())); } // TODO AYMERIC CPPUNIT_ASSERT(1); delete model; }