1 // Copyright (C) 2007-2014 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"
28 #include <SALOMEconfig.h>
29 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
31 // ============================================================================
33 * Set up the environment
35 // ============================================================================
37 void KernelHelpersUnitTests::setUp()
41 // ============================================================================
45 // ============================================================================
47 void KernelHelpersUnitTests::tearDown()
51 // ============================================================================
53 * Check SalomeApp functionality
55 // ============================================================================
56 void KernelHelpersUnitTests::TEST_corba()
58 CORBA::ORB_var orb = KERNEL::getORB();
59 CPPUNIT_ASSERT(!CORBA::is_nil(orb));
62 SALOME_NamingService * ns = KERNEL::getNamingService();
63 CPPUNIT_ASSERT(ns!=NULL);
65 SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
66 CPPUNIT_ASSERT(lcc!=NULL);
69 void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() {
70 Engines::EngineComponent_var component =
71 KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
73 Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
74 char * coucou_res = engine->Coucou(123.);
75 const char * coucou_ref = "TestComponent_i : L = 123";
77 CPPUNIT_ASSERT( strcmp(coucou_res, coucou_ref) == 0 );
80 void KernelHelpersUnitTests::TEST_getStudyManager() {
81 SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest");
82 CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy));
84 // One can use the study to store some general properties
85 myTestStudy->SetString("material","wood");
86 myTestStudy->SetReal("volume",3.23);
88 // The study is characterized by an ID
89 int myTestStudyId = myTestStudy->StudyId();
90 LOG("TestComponentImpl::testkernel: study id = "<<myTestStudyId);
93 void KernelHelpersUnitTests::TEST_getSalomeLauncher() {
94 Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
96 int pid = salomeLauncher->getPID();
97 LOG("SALOME launcher PID = " << pid);
99 catch (const SALOME::SALOME_Exception & ex) {
100 LOG("SALOME Exception in createJob !" <<ex.details.text.in());
101 CPPUNIT_ASSERT(false);
103 catch (const CORBA::SystemException& ex) {
104 LOG("Receive SALOME System Exception: "<<ex);
105 LOG("Check SALOME servers...");
106 CPPUNIT_ASSERT(false);
108 catch (const std::exception& ex) {
109 LOG("Receive undefined exception : "<<ex.what());
110 CPPUNIT_ASSERT(false);