1 #include "Salome_file_i.hxx"
5 #include "HDFascii.hxx"
9 void print_infos(Engines::file * infos)
11 cerr << "-------------------------------------------------------------------" << endl;
12 cerr << "file_name = " << infos->file_name << endl;
13 cerr << "path = " << infos->path << endl;
14 cerr << "type = " << infos->type << endl;
15 cerr << "source_file_name = " << infos->source_file_name << endl;
16 cerr << "status = " << infos->status << endl;
19 void print_state(Engines::SfState * state)
21 cerr << "-------------------------------------------------------------------" << endl;
22 cerr << "name = " << state->name << endl;
23 cerr << "hdf5_file_name = " << state->hdf5_file_name << endl;
24 cerr << "number_of_files = " << state->number_of_files << endl;
25 cerr << "files_ok = " << state->files_ok << endl;
29 int main (int argc, char * argv[])
31 system("rm toto cat test.hdf test2.hdf");
38 Engines::file * infos;
39 Engines::SfState * state;
40 Engines::files * all_infos;
41 PortableServer::POA_var root_poa;
42 PortableServer::POAManager_var pman;
43 CORBA::Object_var obj;
45 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
46 cerr << "Test of setLocalFile()" << endl;
47 file.setLocalFile("/tmp/toto");
48 infos = file.getFileInfos("toto");
52 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
53 cerr << "Test of getFilesInfos()" << endl;
54 all_infos = file.getFilesInfos();
55 for (int i = 0; i < all_infos->length(); i++)
57 print_infos(&((*all_infos)[i]));
60 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
61 cerr << "Test of getSalome_fileState()" << endl;
62 state = file.getSalome_fileState();
66 CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
67 obj = orb->resolve_initial_references("RootPOA");
68 root_poa = PortableServer::POA::_narrow(obj);
69 pman = root_poa->the_POAManager();
72 file2.setLocalFile("/tmp/toto_distributed_source");
73 Engines::Salome_file_ptr file2_ref = file2._this();
75 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
76 cerr << "Test of setDistributedFile()" << endl;
77 file.setDistributedFile("/tmp/toto_distributed");
78 file.connectDistributedFile("toto_distributed", file2_ref);
79 // file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
80 infos = file.getFileInfos("toto_distributed");
83 // We create the files ...
84 std::ostringstream oss;
86 std::ofstream f(oss.str().c_str());
88 f << "blablabla" << std::endl;
90 std::ostringstream oss2;
91 oss2 << "/tmp/toto_distributed_source";
92 std::ofstream f2(oss2.str().c_str());
94 f2 << "bliblibli" << std::endl;
100 catch (SALOME::SALOME_Exception & e)
102 cerr << "Exception : " << e.details.text << endl;
105 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
106 cerr << "Test of getFilesInfos()" << endl;
107 all_infos = file.getFilesInfos();
108 for (int i = 0; i < all_infos->length(); i++)
110 print_infos(&((*all_infos)[i]));
113 cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
114 cerr << "Test of getSalome_fileState()" << endl;
115 state = file.getSalome_fileState();
120 file3.setLocalFile("/tmp/toto");
121 file3.setLocalFile("/bin/cat");
122 state = file3.getSalome_fileState();
124 file3.save_all("test.hdf");
125 file3.setLocalFile("/bin/tutu");
126 file3.save("test2.hdf");
128 file4.load("test.hdf");
129 all_infos = file4.getFilesInfos();
130 for (int i = 0; i < all_infos->length(); i++)
132 print_infos(&((*all_infos)[i]));
134 state = file4.getSalome_fileState();
136 file5.load("test2.hdf");
137 all_infos = file5.getFilesInfos();
138 for (int i = 0; i < all_infos->length(); i++)
140 print_infos(&((*all_infos)[i]));
142 state = file5.getSalome_fileState();
145 // Test of ConvertFromHDFToASCII
146 // and ConvertFromASCIIToHDF
147 cerr << "Test of ConvertFromASCIIToHDF" << endl;
148 HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
149 cerr << "Test of ConvertFromHDFToASCII" << endl;
150 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << endl;
151 cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << endl;
153 cerr << "End of tests" << endl;