1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author: Guillaume Boulant (EDF/R&D)
22 #include "SALOME_KernelServices.hxx"
23 #include "Basics_Utils.hxx"
25 #include <SALOMEconfig.h>
26 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
29 CORBA::ORB_var orb = KERNEL::getORB();
30 if ( CORBA::is_nil(orb) ) {
31 LOG("TEST_Corba: orb ERROR");
34 SALOME_NamingService * ns = KERNEL::getNamingService();
36 LOG("TEST_Corba: ns ERROR");
40 SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
42 LOG("TEST_Corba: lcc ERROR");
45 LOG("TEST_Corba: OK");
50 bool TEST_getLifeCycleCORBA() {
51 Engines::EngineComponent_var component =
52 KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
54 Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
55 char * coucou_res = engine->Coucou(123.);
56 const char * coucou_ref = "L = 123";
58 if ( strcmp(coucou_res, coucou_ref) == 0 ) {
64 bool TEST_getStudy() {
65 SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyServant();
66 if ( CORBA::is_nil(myTestStudy) ) {
70 // One can use the study to store some general properties
71 myTestStudy->SetString("material","wood");
72 myTestStudy->SetReal("volume",3.23);
74 // The study with properties was opened
75 LOG("TestComponentImpl::testkernel: study with properties was opened");
80 bool TEST_getSalomeLauncher() {
81 Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
82 for (int i=0; i<10; i++) {
84 int pid = salomeLauncher->getPID();
85 LOG("["<<i<<"] SALOME launcher PID = " << pid);
87 catch (const SALOME::SALOME_Exception & ex) {
88 LOG("SALOME Exception in createJob !" <<ex.details.text.in());
91 catch (const CORBA::SystemException& ex) {
92 LOG("Receive SALOME System Exception: "<<ex);
93 LOG("Check SALOME servers...");
96 catch (const std::exception& ex) {
97 LOG("Receive undefined exception : "<<ex.what());
109 // - complete the coverture of the KernelService interface
110 // - provide use case for the StudyEditor
114 int main (int argc, char * argv[]) {
116 TEST_getLifeCycleCORBA();
118 TEST_getSalomeLauncher();