Salome HOME
updated copyright message
[modules/kernel.git] / src / NamingService / Test / NamingServiceTest.hxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _NAMINGSERVICETEST_HXX_
24 #define _NAMINGSERVICETEST_HXX_
25
26 #include <cppunit/extensions/HelperMacros.h>
27 #include "SALOME_NamingService.hxx"
28 #include <string>
29
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(nstest)
32
33 #ifdef WIN32
34 # if defined NAMINGSERVICETEST_EXPORTS || defined NamingServiceTest_EXPORTS
35 #  define NAMINGSERVICETEST_EXPORT __declspec( dllexport )
36 # else
37 #  define NAMINGSERVICETEST_EXPORT __declspec( dllimport )
38 # endif
39 #else
40 # define NAMINGSERVICETEST_EXPORT
41 #endif
42
43 class NAMINGSERVICETEST_EXPORT NSTEST_echo_i : public virtual POA_NSTEST::echo,
44                       public virtual PortableServer::ServantBase
45 {
46 public:
47   NSTEST_echo_i();
48   NSTEST_echo_i(CORBA::Long num);
49   ~NSTEST_echo_i();
50   CORBA::Long getId();
51 private:
52   int _num;
53 };
54
55 class NSTEST_aFactory_i : public virtual POA_NSTEST::aFactory,
56                           public virtual PortableServer::ServantBase
57 {
58 public:
59   NSTEST_aFactory_i();
60   ~NSTEST_aFactory_i();
61   NSTEST::echo_ptr createInstance();
62 private:
63   int _num;
64 };
65
66 class NAMINGSERVICETEST_EXPORT NamingServiceTest : public CppUnit::TestFixture
67 {
68   CPPUNIT_TEST_SUITE( NamingServiceTest );
69   CPPUNIT_TEST( testConstructorDefault );
70   CPPUNIT_TEST( testConstructorOrb );
71   CPPUNIT_TEST( testRegisterResolveAbsNoPath );
72   CPPUNIT_TEST( testRegisterResolveRelativeNoPath );
73   CPPUNIT_TEST( testRegisterResolveAbsWithPath );
74   CPPUNIT_TEST( testRegisterResolveRelativeWithPath );
75   CPPUNIT_TEST( testResolveBadName );
76   CPPUNIT_TEST( testResolveBadNameRelative );
77   CPPUNIT_TEST( testResolveFirst );
78   CPPUNIT_TEST( testResolveFirstRelative );
79   CPPUNIT_TEST( testResolveFirstUnknown );
80   CPPUNIT_TEST( testResolveFirstUnknownRelative );
81   CPPUNIT_TEST( testResolveComponentOK );
82   CPPUNIT_TEST( testResolveComponentEmptyHostname );
83   CPPUNIT_TEST( testResolveComponentUnknownHostname );
84   CPPUNIT_TEST( testResolveComponentEmptyContainerName );
85   CPPUNIT_TEST( testResolveComponentUnknownContainerName );
86   CPPUNIT_TEST( testResolveComponentEmptyComponentName );
87   CPPUNIT_TEST( testResolveComponentUnknownComponentName );
88   CPPUNIT_TEST( testResolveComponentFalseNbproc );
89   CPPUNIT_TEST( testContainerName );
90   CPPUNIT_TEST( testContainerNameParams );
91   CPPUNIT_TEST( testBuildContainerNameForNS );
92   CPPUNIT_TEST( testBuildContainerNameForNSParams );
93   CPPUNIT_TEST( testFind );
94   CPPUNIT_TEST( testCreateDirectory );
95   CPPUNIT_TEST( testChangeDirectory );
96   CPPUNIT_TEST( testCurrentDirectory );
97   CPPUNIT_TEST( testList );
98   CPPUNIT_TEST( testListDirectory );
99   CPPUNIT_TEST( testListDirectoryRecurs );
100   CPPUNIT_TEST( testListSubdirs );
101   CPPUNIT_TEST( testDestroyName );
102   CPPUNIT_TEST( testDestroyDirectory );
103   CPPUNIT_TEST( testDestroyFullDirectory );
104   CPPUNIT_TEST( testGetIorAddr );
105 //   CPPUNIT_TEST(  );
106 //   CPPUNIT_TEST(  );
107 //   CPPUNIT_TEST(  );
108
109   CPPUNIT_TEST_SUITE_END();
110
111 public:
112
113   void setUp();
114   void tearDown();
115
116   void testConstructorDefault();
117   void testConstructorOrb();
118   void testRegisterResolveAbsNoPath();
119   void testRegisterResolveRelativeNoPath();
120   void testRegisterResolveAbsWithPath();
121   void testRegisterResolveRelativeWithPath();
122   void testResolveBadName();
123   void testResolveBadNameRelative();
124   void testResolveFirst();
125   void testResolveFirstRelative();
126   void testResolveFirstUnknown();
127   void testResolveFirstUnknownRelative();
128   void testResolveComponentOK();
129   void testResolveComponentEmptyHostname();
130   void testResolveComponentUnknownHostname();
131   void testResolveComponentEmptyContainerName();
132   void testResolveComponentUnknownContainerName();
133   void testResolveComponentEmptyComponentName();
134   void testResolveComponentUnknownComponentName();
135   void testResolveComponentFalseNbproc();
136   void testContainerName();
137   void testContainerNameParams();
138   void testBuildContainerNameForNS();
139   void testBuildContainerNameForNSParams();
140   void testFind();
141   void testCreateDirectory();
142   void testChangeDirectory();
143   void testCurrentDirectory();
144   void testList();
145   void testListDirectory();
146   void testListDirectoryRecurs();
147   void testListSubdirs();
148   void testDestroyName();
149   void testDestroyDirectory();
150   void testDestroyFullDirectory();
151   void testGetIorAddr();
152
153  private:
154   std::string _getTraceFileName();
155
156 protected:
157   void _destroyDirectoryRecurs(std::string path);
158
159   CORBA::ORB_var _orb;
160   SALOME_NamingService _NS;
161
162   PortableServer::POA_var _root_poa;
163   PortableServer::POAManager_var _pman;
164   PortableServer::ObjectId_var _myFactoryId;
165   NSTEST_aFactory_i * _myFactory;
166   CORBA::Object_var _factoryRef;
167 };
168
169 #endif