Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / src / MedClient / test / test2 / TestMedCorba6.py
1 # Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
2 #           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either 
6 # version 2.1 of the License.
7
8 # This library is distributed in the hope that it will be useful 
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 # Lesser General Public License for more details.
12
13 # You should have received a copy of the GNU Lesser General Public  
14 # License along with this library; if not, write to the Free Software 
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
19 import os
20
21 ## ne fonctionne pas ?
22 ## import salome
23
24 BASE = os.environ["MED_ROOT_DIR"] + '/share/salome/resources/med/'
25
26 fileName = BASE + 'pointe.med'
27 fileName = BASE + 'carre_en_quad4_seg2.med'
28  
29
30 def compare(x, y):
31     if (len(x) != len(y)):
32         return 0
33     for i in xrange(len(x)):
34         if x[i] != y[i]:
35             return 0
36     return 1
37
38 # MED Mesh read from a (local) file
39
40 from libMEDMEM_Swig import *
41
42 md = MED()
43
44 mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
45
46 mdDriver.open()
47 mdDriver.readFileStruct()
48 mdDriver.close()
49
50 mLocal = md.getMesh(md.getMeshName(0))
51 mLocal.read()
52
53 # MED Mesh received from a distant component (via CORBA)
54
55 from omniORB import CORBA
56 from LifeCycleCORBA import *
57 from libSALOME_Swig import *
58 from libMEDClient import *
59
60 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
61 lcc = LifeCycleCORBA(orb)
62
63 C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
64 C.Initialise(fileName)
65
66 mDistant = C.Calcul1()
67 mDistantCopy = MESHClient(mDistant)
68
69 from libCompo2 import *
70 C2 = Compo2()
71
72 print "Local       ", C2.Calcul(mLocal)
73 print "DistantCopy ", C2.Calcul(mDistantCopy)
74
75 testDistant = 0;
76 try:
77     print "Distant     ", C2.Calcul(mDistant)
78 except:
79     print "an exception has been received, it's the normal behaviour"
80     testDistant = 1
81
82 if (testDistant == 0):
83     raise RuntimeError, "no exception has been received, test failed"
84
85
86 print
87 print "All tests passed"