testServiceTypeDescription.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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 };