testServiceTypeDescription.cpp

00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename testServiceDescription.cpp
00024  * @Description Tests the ServiceDescription class
00025  * @Status unknown
00026  * @Version $Id: testServiceTypeDescription.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer Marco Barbosa + Nelson Ramos
00028  */
00029 
00030 #include "config.h"
00031 
00032 #include <iostream>
00033 
00034 #include <ace/Trace.h>
00035 
00036 #include "EntityDescriptionRepository.hpp"
00037 #include "EntityDescriptionFactory.hpp"
00038 #include "ServiceInterfaceDescription.hpp"
00039 #include "ServiceTypeDescription.hpp"
00040 #include "ServiceTypeDescriptionFactory.hpp"
00041 #include "ServiceTypeDescriptionRepository.hpp"
00042 #include "Entity.hpp"
00043 
00044 
00045 
00046 #include <FilePathSearch.hpp>
00047 #include <XmlDocument.hpp>
00048 #include <XmlElement.hpp>
00049 
00050 
00051 
00052 using namespace std;
00053 using boost::shared_ptr;
00054 
00055 using mermaid::support::service::Entity;
00056 using mermaid::support::service::EntityDescriptionFactory;
00057 using mermaid::support::service::EntityDescriptionRepository;
00058 using mermaid::support::service::ServiceInterfaceDescription;
00059 using mermaid::support::service::ServiceTypeDescription;
00060 using mermaid::support::service::ServiceTypeDescriptionRepository;
00061 using mermaid::support::service::ServiceTypeDescriptionFactory;
00062 using mermaid::support::system::FilePathSearch;
00063 using mermaid::support::xml::XmlDocument;
00064 using mermaid::support::xml::XmlElement;
00065 
00066 
00067 int main (int argc, char * const argv[])
00068 {
00069   ACE_Trace::stop_tracing();
00070   std::cerr << "ServiceDescription test\n";
00071   
00072   if (argc != 3) {
00073     std::cerr << "Usage: testServiceDescription [serviceTypeDescriptionList] [entityDescriptionList]" << std::endl;
00074     return (1);
00075   }
00076   
00077   FilePathSearch::addSearchPath ("./");
00078   FilePathSearch::addSearchPath ("/");
00079   
00080   
00081   shared_ptr<XmlDocument> docServiceType (new XmlDocument());
00082   std::cerr << "Reading from file: " << argv[1] << std::endl;
00083   docServiceType->parseFile (std::string (argv[1]));
00084   
00085   
00086   if (docServiceType->isWellFormed()) {
00087     std::cerr << "XML is WELL FORMED" << std::endl;
00088   }
00089   else {
00090     std::cerr << "XML is NOT WELL FORMED" << std::endl;
00091     return (1);
00092   }
00093   
00094   
00095   if (docServiceType->isValid()) {
00096     std::cerr << "XML is VALID" << std::endl;
00097   }
00098   else {
00099     std::cerr << "XML is NOT VALID" << std::endl;
00100     return (1);
00101   }
00102   
00103   
00104   
00105   
00106   shared_ptr<XmlDocument> docEntity (new XmlDocument());
00107   std::cerr << "Reading from file: " << argv[2] << std::endl;
00108   docEntity->parseFile (std::string (argv[2]));
00109   
00110   
00111   if (docEntity->isWellFormed()) {
00112     std::cerr << "XML is WELL FORMED" << std::endl;
00113   }
00114   else {
00115     std::cerr << "XML is NOT WELL FORMED" << std::endl;
00116     return (1);
00117   }
00118   
00119   
00120   if (docEntity->isValid()) {
00121     std::cerr << "XML is VALID" << std::endl;
00122   }
00123   else {
00124     std::cerr << "XML is NOT VALID" << std::endl;
00125     return (1);
00126   }
00127   
00128   
00129   shared_ptr<XmlElement> serviceTypeDescriptionList = docServiceType->getRootElement();
00130   
00131   shared_ptr<ServiceTypeDescriptionRepository> serviceTypeDescriptionRepository = ServiceTypeDescriptionRepository::getInstance();
00132   
00133   ServiceTypeDescriptionFactory::populateServiceTypeDescriptionRepository (serviceTypeDescriptionRepository, serviceTypeDescriptionList);
00134   
00135   
00136   
00137   shared_ptr<XmlElement> entityDescriptionList = docEntity->getRootElement();
00138   
00139   shared_ptr<EntityDescriptionRepository> entityDescriptionRepository = EntityDescriptionRepository::getInstance();
00140   
00141   EntityDescriptionFactory::populateEntityDescriptionRepository (entityDescriptionRepository, entityDescriptionList, serviceTypeDescriptionRepository);
00142   
00143 }; // main
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3