Back to index

salome-kernel  6.5.0
KernelHelpersUnitTests.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "KernelHelpersUnitTests.hxx"
00024 
00025 #include "SALOME_KernelServices.hxx"
00026 #include "Basics_Utils.hxx"
00027 
00028 #include <SALOMEconfig.h>
00029 #include CORBA_CLIENT_HEADER(SALOME_TestComponent)
00030 
00031 // ============================================================================
00035 // ============================================================================
00036 
00037 void KernelHelpersUnitTests::setUp()
00038 {
00039 }
00040 
00041 // ============================================================================
00045 // ============================================================================
00046 
00047 void KernelHelpersUnitTests::tearDown()
00048 {
00049 }
00050 
00051 // ============================================================================
00055 // ============================================================================
00056 void KernelHelpersUnitTests::TEST_corba()
00057 {
00058   CORBA::ORB_var orb = KERNEL::getORB();
00059   CPPUNIT_ASSERT(!CORBA::is_nil(orb));
00060 
00061   
00062   SALOME_NamingService *  ns  = KERNEL::getNamingService();
00063   CPPUNIT_ASSERT(ns!=NULL);
00064 
00065   SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
00066   CPPUNIT_ASSERT(lcc!=NULL);
00067 }
00068 
00069 void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() {
00070   Engines::EngineComponent_var component =
00071     KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
00072   
00073   Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
00074   char * coucou_res = engine->Coucou(123.);
00075   const char * coucou_ref = "TestComponent_i : L = 123";
00076   LOG(coucou_res);
00077   CPPUNIT_ASSERT( strcmp(coucou_res, coucou_ref) == 0 );
00078 }
00079 
00080 void KernelHelpersUnitTests::TEST_getStudyManager() {
00081   SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest");
00082   CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy));
00083 
00084   // One can use the study to store some general properties
00085   myTestStudy->SetString("material","wood");
00086   myTestStudy->SetReal("volume",3.23);
00087 
00088   // The study is characterized by an ID
00089   int myTestStudyId = myTestStudy->StudyId();
00090   LOG("TestComponentImpl::testkernel: study id = "<<myTestStudyId);
00091 }
00092 
00093 void KernelHelpersUnitTests::TEST_getSalomeLauncher() {
00094   Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
00095   try {
00096     int pid = salomeLauncher->getPID();
00097     LOG("SALOME launcher PID = " << pid);
00098   }
00099   catch (const SALOME::SALOME_Exception & ex) {
00100     LOG("SALOME Exception in createJob !" <<ex.details.text.in());
00101     CPPUNIT_ASSERT(false);
00102   }
00103   catch (const CORBA::SystemException& ex) {
00104     LOG("Receive SALOME System Exception: "<<ex);
00105     LOG("Check SALOME servers...");
00106     CPPUNIT_ASSERT(false);
00107   }
00108   catch (const std::exception& ex) {
00109     LOG("Receive undefined exception : "<<ex.what());
00110     CPPUNIT_ASSERT(false);
00111   }
00112 }