1 // Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "KernelHelpersUnitTests.hxx"
25 #include "SALOME_KernelServices.hxx"
26 #include "Basics_Utils.hxx"
27 #include "KernelBasis.hxx"
29 #include <SALOMEconfig.h>
30 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
32 // ============================================================================
34 * Set up the environment
36 // ============================================================================
38 void KernelHelpersUnitTests::setUp()
43 // ============================================================================
47 // ============================================================================
49 void KernelHelpersUnitTests::tearDown()
53 // ============================================================================
55 * Check SalomeApp functionality
57 // ============================================================================
58 void KernelHelpersUnitTests::TEST_corba()
60 CORBA::ORB_var orb = KERNEL::getORB();
61 CPPUNIT_ASSERT(!CORBA::is_nil(orb));
64 SALOME_NamingService_Abstract * ns = KERNEL::getNamingService();
65 CPPUNIT_ASSERT(ns!=NULL);
67 SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
68 CPPUNIT_ASSERT(lcc!=NULL);
71 void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() {
72 Engines::EngineComponent_var component =
73 KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
75 Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
76 char * coucou_res = engine->Coucou(123.);
77 const char * coucou_ref = "TestComponent_i : L = 123";
79 CPPUNIT_ASSERT( strcmp(coucou_res, coucou_ref) == 0 );
82 void KernelHelpersUnitTests::TEST_getStudy() {
83 SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyServant();
84 CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy));
86 // One can use the study to store some general properties
87 myTestStudy->SetString("material","wood");
88 myTestStudy->SetReal("volume",3.23);
90 // The study with properties was opened
91 LOG("TestComponentImpl::testkernel: study with properties was opened");
94 void KernelHelpersUnitTests::TEST_getSalomeLauncher() {
95 Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
97 int pid = salomeLauncher->getPID();
98 SALOME_UNUSED(pid); // unused in release mode
99 LOG("SALOME launcher PID = " << pid);
101 catch (const SALOME::SALOME_Exception & ex) {
102 LOG("SALOME Exception in createJob !" <<ex.details.text.in());
103 CPPUNIT_ASSERT(false);
105 catch (const CORBA::SystemException& ex) {
106 LOG("Receive SALOME System Exception: "<<ex);
107 LOG("Check SALOME servers...");
108 CPPUNIT_ASSERT(false);
110 catch (const std::exception& ex) {
111 LOG("Receive undefined exception : "<<ex.what());
112 CPPUNIT_ASSERT(false);