--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: Guillaume Boulant (EDF/R&D)
+
+#include "SALOME_KernelServices.hxx"
+#include "Basics_Utils.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
+
+bool TEST_corba() {
+ CORBA::ORB_var orb = KERNEL::getORB();
+ if ( CORBA::is_nil(orb) ) {
+ LOG("TEST_Corba: orb ERROR");
+ return false;
+ }
+ SALOME_NamingService * ns = KERNEL::getNamingService();
+ if ( ns == NULL ) {
+ LOG("TEST_Corba: ns ERROR");
+ return false;
+
+ }
+ SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
+ if ( lcc == NULL ) {
+ LOG("TEST_Corba: lcc ERROR");
+ return false;
+ }
+ LOG("TEST_Corba: OK");
+ return true;
+}
+
+#include <string.h>
+bool TEST_getLifeCycleCORBA() {
+ Engines::EngineComponent_var component =
+ KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
+
+ Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
+ char * coucou_res = engine->Coucou(123.);
+ char * coucou_ref = "L = 123";
+ LOG(coucou_res);
+ if ( strcmp(coucou_res, coucou_ref) == 0 ) {
+ return false;
+ }
+ return true;
+}
+
+bool TEST_getStudyManager() {
+ SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest");
+ if ( CORBA::is_nil(myTestStudy) ) {
+ return false;
+ }
+
+ // One can use the study to store some general properties
+ myTestStudy->SetString("material","wood");
+ myTestStudy->SetReal("volume",3.23);
+
+ // The study is characterized by an ID
+ int myTestStudyId = myTestStudy->StudyId();
+ LOG("TestComponentImpl::testkernel: study id = "<<myTestStudyId);
+ return true;
+}
+
+
+bool TEST_getSalomeLauncher() {
+ Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
+ for (int i=0; i<10; i++) {
+ try {
+ int pid = salomeLauncher->getPID();
+ LOG("["<<i<<"] SALOME launcher PID = " << pid);
+ }
+ catch (const SALOME::SALOME_Exception & ex) {
+ LOG("SALOME Exception in createJob !" <<ex.details.text.in());
+ return false;
+ }
+ catch (const CORBA::SystemException& ex) {
+ LOG("Receive SALOME System Exception: "<<ex);
+ LOG("Check SALOME servers...");
+ return false;
+ }
+ catch (const std::exception& ex) {
+ LOG("Receive undefined exception : "<<ex.what());
+ }
+
+ sleep(2);
+ }
+ return true;
+}
+
+// TODO:
+// - complete the coverture of the KernelService interface
+// - provide use case for the StudyEditor
+
+
+
+int main (int argc, char * argv[]) {
+ TEST_corba();
+ TEST_getLifeCycleCORBA();
+ TEST_getStudyManager();
+ TEST_getSalomeLauncher();
+ return 0;
+}
OMNIORB_CXXFLAGS=@OMNIORB_CXXFLAGS@ @OMNIORB_INCLUDES@
OMNIORB_LIBS=@OMNIORB_LIBS@
-libSalomeKernelHelpers_la_CPPFLAGS = \
- $(OMNIORB_CXXFLAGS) \
- -I$(srcdir)/../NamingService \
+libSalomeKernelHelpers_la_CPPFLAGS = \
+ $(OMNIORB_CXXFLAGS) \
+ -I$(srcdir)/../NamingService \
-I$(srcdir)/../SALOMELocalTrace \
- -I$(srcdir)/../Basics \
- -I$(srcdir)/../Utils \
- -I$(srcdir)/../LifeCycleCORBA \
- -I$(srcdir)/../Container \
- -I$(srcdir)/../Notification \
- -I$(srcdir)/../GenericObj \
+ -I$(srcdir)/../Basics \
+ -I$(srcdir)/../Utils \
+ -I$(srcdir)/../LifeCycleCORBA \
+ -I$(srcdir)/../Container \
+ -I$(srcdir)/../Notification \
+ -I$(srcdir)/../GenericObj \
-I$(top_builddir)/idl
-libSalomeKernelHelpers_la_LDFLAGS = \
- $(OMNIORB_LIBS) \
- ../NamingService/libSalomeNS.la \
- ../SALOMELocalTrace/libSALOMELocalTrace.la \
- ../Basics/libSALOMEBasics.la \
- ../Utils/libOpUtil.la \
+libSalomeKernelHelpers_la_LDFLAGS = \
+ $(OMNIORB_LIBS) \
+ ../NamingService/libSalomeNS.la \
+ ../SALOMELocalTrace/libSALOMELocalTrace.la \
+ ../Basics/libSALOMEBasics.la \
+ ../Utils/libOpUtil.la \
../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \
- ../Container/libSalomeContainer.la \
- ../Notification/libSalomeNotification.la \
- ../GenericObj/libSalomeGenericObj.la \
+ ../Container/libSalomeContainer.la \
+ ../Notification/libSalomeNotification.la \
+ ../GenericObj/libSalomeGenericObj.la \
$(top_builddir)/idl/libSalomeIDLKernel.la
#
# Executables targets
# ===============================================================
#
-bin_PROGRAMS = TestKernelHelpers
-TestKernelHelpers_SOURCES = TestKernelHelpers.cxx
-TestKernelHelpers_CPPFLAGS =\
+bin_PROGRAMS = KernelHelpersUseCases
+KernelHelpersUseCases_SOURCES = KernelHelpersUseCases.cxx
+KernelHelpersUseCases_CPPFLAGS =\
$(libSalomeKernelHelpers_la_CPPFLAGS)
-TestKernelHelpers_LDADD = \
+KernelHelpersUseCases_LDADD = \
libSalomeKernelHelpers.la \
$(libSalomeKernelHelpers_la_LDFLAGS)
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelHelpersUnitTests.hxx"
+
+#include "SALOME_KernelServices.hxx"
+#include "Basics_Utils.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
+
+// ============================================================================
+/*!
+ * Set up the environment
+ */
+// ============================================================================
+
+void KernelHelpersUnitTests::setUp()
+{
+}
+
+// ============================================================================
+/*!
+ * - delete
+ */
+// ============================================================================
+
+void KernelHelpersUnitTests::tearDown()
+{
+}
+
+// ============================================================================
+/*!
+ * Check SalomeApp functionality
+ */
+// ============================================================================
+void KernelHelpersUnitTests::TEST_corba()
+{
+ CORBA::ORB_var orb = KERNEL::getORB();
+ CPPUNIT_ASSERT(!CORBA::is_nil(orb));
+
+
+ SALOME_NamingService * ns = KERNEL::getNamingService();
+ CPPUNIT_ASSERT(ns!=NULL);
+
+ SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
+ CPPUNIT_ASSERT(lcc!=NULL);
+}
+
+void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() {
+ Engines::EngineComponent_var component =
+ KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
+
+ Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
+ char * coucou_res = engine->Coucou(123.);
+ char * coucou_ref = "TestComponent_i : L = 123";
+ LOG(coucou_res);
+ CPPUNIT_ASSERT( strcmp(coucou_res, coucou_ref) == 0 );
+}
+
+void KernelHelpersUnitTests::TEST_getStudyManager() {
+ SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest");
+ CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy));
+
+ // One can use the study to store some general properties
+ myTestStudy->SetString("material","wood");
+ myTestStudy->SetReal("volume",3.23);
+
+ // The study is characterized by an ID
+ int myTestStudyId = myTestStudy->StudyId();
+ LOG("TestComponentImpl::testkernel: study id = "<<myTestStudyId);
+}
+
+void KernelHelpersUnitTests::TEST_getSalomeLauncher() {
+ Engines::SalomeLauncher_var salomeLauncher = KERNEL::getSalomeLauncher();
+ try {
+ int pid = salomeLauncher->getPID();
+ LOG("SALOME launcher PID = " << pid);
+ }
+ catch (const SALOME::SALOME_Exception & ex) {
+ LOG("SALOME Exception in createJob !" <<ex.details.text.in());
+ CPPUNIT_ASSERT(false);
+ }
+ catch (const CORBA::SystemException& ex) {
+ LOG("Receive SALOME System Exception: "<<ex);
+ LOG("Check SALOME servers...");
+ CPPUNIT_ASSERT(false);
+ }
+ catch (const std::exception& ex) {
+ LOG("Receive undefined exception : "<<ex.what());
+ CPPUNIT_ASSERT(false);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _SalomeAppTEST_HXX_
+#define _SalomeAppTEST_HXX_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class KernelHelpersUnitTests : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( KernelHelpersUnitTests );
+ CPPUNIT_TEST( TEST_corba );
+ CPPUNIT_TEST( TEST_getLifeCycleCORBA );
+ CPPUNIT_TEST( TEST_getStudyManager );
+ CPPUNIT_TEST( TEST_getSalomeLauncher );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+ void setUp();
+ void tearDown();
+
+ void TEST_corba();
+ void TEST_getLifeCycleCORBA();
+ void TEST_getStudyManager();
+ void TEST_getSalomeLauncher();
+};
+
+#endif
--- /dev/null
+# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# Author: Guillaume Boulant (EDF/R&D)
+
+include $(top_srcdir)/salome_adm/unix/make_common_starter.am
+
+lib_LTLIBRARIES = libSalomeKernelHelpersTest.la
+
+salomeinclude_HEADERS = KernelHelpersUnitTests.hxx
+
+dist_libSalomeKernelHelpersTest_la_SOURCES = KernelHelpersUnitTests.cxx
+
+OMNIORB_CXXFLAGS=@OMNIORB_CXXFLAGS@ @OMNIORB_INCLUDES@
+OMNIORB_LIBS=@OMNIORB_LIBS@
+
+libSalomeKernelHelpersTest_la_CXXFLAGS = \
+ @CPPUNIT_INCLUDES@ \
+ $(OMNIORB_CXXFLAGS) \
+ -I$(top_srcdir)/src/Basics/Test \
+ -I$(srcdir)/.. \
+ -I$(top_srcdir)/src/NamingService \
+ -I$(top_srcdir)/src/SALOMELocalTrace \
+ -I$(top_srcdir)/src/Basics \
+ -I$(top_srcdir)/src/Utils \
+ -I$(top_srcdir)/src/LifeCycleCORBA \
+ -I$(top_srcdir)/src/Container \
+ -I$(top_srcdir)/src/Notification \
+ -I$(top_srcdir)/src/GenericObj \
+ -I$(top_builddir)/idl
+
+
+libSalomeKernelHelpersTest_la_LIBADD = \
+ @CPPUNIT_LIBS@ \
+ ../libSalomeKernelHelpers.la \
+ $(OMNIORB_LIBS) \
+ $(top_builddir)/src/NamingService/libSalomeNS.la \
+ $(top_builddir)/src/SALOMELocalTrace/libSALOMELocalTrace.la \
+ $(top_builddir)/src/Basics/libSALOMEBasics.la \
+ $(top_builddir)/src/Utils/libOpUtil.la \
+ $(top_builddir)/src/LifeCycleCORBA/libSalomeLifeCycleCORBA.la \
+ $(top_builddir)/src/Container/libSalomeContainer.la \
+ $(top_builddir)/src/Notification/libSalomeNotification.la \
+ $(top_builddir)/src/GenericObj/libSalomeGenericObj.la \
+ $(top_builddir)/idl/libSalomeIDLKernel.la
+
+
+bin_PROGRAMS = TestKernelHelpers
+
+TestKernelHelpers_SOURCES = TestKernelHelpers.cxx
+
+TestKernelHelpers_CXXFLAGS = $(libSalomeKernelHelpersTest_la_CXXFLAGS)
+TestKernelHelpers_LDADD = $(libSalomeKernelHelpersTest_la_LIBADD) libSalomeKernelHelpersTest.la
+
+dist_salomescript_PYTHON = TestKernelHelpers.py
+UNIT_TEST_PROG = TestKernelHelpers
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelHelpersUnitTests.hxx"
+
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( KernelHelpersUnitTests );
+
+// --- generic Main program from Basic/Test
+
+#include "BasicMainTest.hxx"
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import sys, os,signal,string,commands
+import runSalome
+import orbmodule
+import TestKiller
+
+# get SALOME environment :
+
+args, modules_list, modules_root_dir = runSalome.get_config()
+runSalome.set_env(args, modules_list, modules_root_dir)
+
+# launch CORBA naming server
+
+clt=orbmodule.client()
+
+# launch CORBA logger server
+
+myServer=runSalome.LoggerServer(args)
+myServer.run()
+clt.waitLogger("Logger")
+
+# execute Unit Test
+
+command = ['TestKernelHelpers']
+ret = os.spawnvp(os.P_WAIT, command[0], command)
+
+# kill Test process
+
+TestKiller.killProcess(runSalome.process_id)
+++ /dev/null
-// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author: Guillaume Boulant (EDF/R&D)
-
-#include "SALOME_KernelServices.hxx"
-#include "Basics_Utils.hxx"
-
-#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
-
-void TEST_corba() {
- CORBA::ORB_var orb = KERNEL::getORB();
- SALOME_NamingService * ns = KERNEL::getNamingService();
- SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
-}
-
-void TEST_getLifeCycleCORBA() {
- Engines::EngineComponent_var component =
- KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" );
-
- Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component);
- STDLOG(engine->Coucou(123.));
-}
-
-// TODO:
-// - complete the coverture of the KernelService interface
-// - provide use case for the StudyEditor
-
-int main (int argc, char * argv[]) {
- TEST_getLifeCycleCORBA();
- return 0;
-}
LifeCycleCORBA/Test \
LifeCycleCORBA_SWIG/Test \
SALOMEDSImpl/Test \
- SALOMEDS/Test
+ SALOMEDS/Test \
+ KernelHelpers/Test
SUBDIR_CPPUNIT_GENERAL = \
UnitTests