Commit f461be81 authored by Sebastien Robin's avatar Sebastien Robin

corrected bugs when a message is splitted


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@871 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 405ad021
...@@ -674,7 +674,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -674,7 +674,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
""" """
if type(xml) in (type('a'),type(u'a')): if type(xml) in (type('a'),type(u'a')):
LOG('Conduit.convertToXml xml',0,repr(xml)) LOG('Conduit.convertToXml xml',0,repr(xml))
if xml is type(u'a'): if type(xml) is type(u'a'):
xml = xml.encode('utf-8') xml = xml.encode('utf-8')
xml = parseString(xml) xml = parseString(xml)
LOG('Conduit.convertToXml not failed',0,'ok') LOG('Conduit.convertToXml not failed',0,'ok')
......
...@@ -252,10 +252,14 @@ class Signature(SyncCode): ...@@ -252,10 +252,14 @@ class Signature(SyncCode):
# and we just get the confirmation # and we just get the confirmation
self.setXML(self.getTempXML()) self.setXML(self.getTempXML())
self.setTempXML(None) self.setTempXML(None)
self.setPartialXML(None)
self.setSubscriberXupdate(None) self.setSubscriberXupdate(None)
self.setPublisherXupdate(None) self.setPublisherXupdate(None)
if len(self.getConflictList())>0: if len(self.getConflictList())>0:
self.resetConflictList() self.resetConflictList()
if status == self.NOT_SYNCHRONIZED:
self.setTempXML(None)
self.setPartialXML(None)
elif status in (self.PUB_CONFLICT_MERGE,self.SENT): elif status in (self.PUB_CONFLICT_MERGE,self.SENT):
# We have a solution for the conflict, don't need to keep the list # We have a solution for the conflict, don't need to keep the list
self.resetConflictList() self.resetConflictList()
...@@ -393,9 +397,11 @@ class Signature(SyncCode): ...@@ -393,9 +397,11 @@ class Signature(SyncCode):
Set the partial string we will have to Set the partial string we will have to
deliver in the future deliver in the future
""" """
#LOG('Subscriber.setPartialXML before',0,'partial_xml: %s' % str(self.partial_xml)) LOG('Subscriber.setPartialXML before',0,'partial_xml: %s' % str(self.partial_xml))
if type(xml) is type(u'a'):
xml = xml.encode('utf-8')
self.partial_xml = xml self.partial_xml = xml
#LOG('Subscriber.setPartialXML after',0,'partial_xml: %s' % str(self.partial_xml)) LOG('Subscriber.setPartialXML after',0,'partial_xml: %s' % str(self.partial_xml))
def getPartialXML(self): def getPartialXML(self):
""" """
......
...@@ -446,7 +446,10 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject): ...@@ -446,7 +446,10 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject):
#if subnode3.data.find('<!--')>=0: #if subnode3.data.find('<!--')>=0:
# data = subnode3.data # data = subnode3.data
# data = data[data.find('<!--')+4:data.rfind('-->')] # data = data[data.find('<!--')+4:data.rfind('-->')]
return subnode3.data xml = subnode3.data
if type(xml) is type(u'a'):
xml = xml.encode('utf-8')
return xml
return None return None
...@@ -713,7 +716,7 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject): ...@@ -713,7 +716,7 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject):
LOG('SyncModif',0,'data_subnode: %s' % data_subnode) LOG('SyncModif',0,'data_subnode: %s' % data_subnode)
#data_subnode = FromXml(data_subnode) #data_subnode = FromXml(data_subnode)
data_subnode = parseString(data_subnode) data_subnode = parseString(data_subnode)
data_subnode = data_subnode.childNodes[1] # Because we just created a new xml data_subnode = data_subnode.childNodes[0] # Because we just created a new xml
# document, with childNodes[0] a DocumentType and childNodes[1] the Element Node # document, with childNodes[0] a DocumentType and childNodes[1] the Element Node
else: else:
data_subnode = self.getDataSubNode(next_action) data_subnode = self.getDataSubNode(next_action)
...@@ -787,8 +790,8 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject): ...@@ -787,8 +790,8 @@ class XMLSyncUtilsMixin(SyncCode, ActiveObject):
signature.setStatus(self.PARTIAL) signature.setStatus(self.PARTIAL)
#LOG('SyncModif',0,'setPartialXML: %s' % str(previous_partial)) #LOG('SyncModif',0,'setPartialXML: %s' % str(previous_partial))
previous_partial = signature.getPartialXML() or '' previous_partial = signature.getPartialXML() or ''
if previous_partial.find(partial_data)<0: #if previous_partial.find(partial_data)<0: # XXX bad thing
previous_partial += partial_data previous_partial += partial_data
signature.setPartialXML(previous_partial) signature.setPartialXML(previous_partial)
#LOG('SyncModif',0,'previous_partial: %s' % str(previous_partial)) #LOG('SyncModif',0,'previous_partial: %s' % str(previous_partial))
LOG('SyncModif',0,'waiting more data for :%s' % signature.getId()) LOG('SyncModif',0,'waiting more data for :%s' % signature.getId())
......
...@@ -46,6 +46,7 @@ from Testing import ZopeTestCase ...@@ -46,6 +46,7 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
from Products.ERP5SyncML.SyncCode import SyncCode
from zLOG import LOG from zLOG import LOG
import time import time
...@@ -408,10 +409,11 @@ class TestERP5SyncML(ERP5TypeTestCase): ...@@ -408,10 +409,11 @@ class TestERP5SyncML(ERP5TypeTestCase):
for sub in portal_sync.getSubscriptionList(): for sub in portal_sync.getSubscriptionList():
for m in sub.getSignatureList(): for m in sub.getSignatureList():
self.assertEquals(m.getTempXML(),None) self.assertEquals(m.getTempXML(),None)
self.assertEquals(m.getPartialXML(),None)
for pub in portal_sync.getPublicationList(): for pub in portal_sync.getPublicationList():
for sub in pub.getSubscriberList(): for sub in pub.getSubscriberList():
for m in sub.getSignatureList(): for m in sub.getSignatureList():
self.assertEquals(m.getTempXML(),None) self.assertEquals(m.getPartialXML(),None)
def checkSynchronizationStateIsConflict(self, quiet=0, run=run_all_test): def checkSynchronizationStateIsConflict(self, quiet=0, run=run_all_test):
portal_sync = self.getSynchronizationTool() portal_sync = self.getSynchronizationTool()
...@@ -1000,6 +1002,41 @@ class TestERP5SyncML(ERP5TypeTestCase): ...@@ -1000,6 +1002,41 @@ class TestERP5SyncML(ERP5TypeTestCase):
self.assertEqual(role_1_s,role_1_c) self.assertEqual(role_1_s,role_1_c)
self.assertEqual(role_2_s,role_2_c) self.assertEqual(role_2_s,role_2_c)
def testPartialData(self, quiet=0, run=run_all_test):
"""
We will do a first synchronization, then we will do a change, then
we will modify the SyncCode max_line value so it
it will generate many messages
"""
if not run: return
self.testFirstSynchronization(quiet=1,run=1)
if not quiet:
ZopeTestCase._print('\nTest Partial Data ')
LOG('Testing... ',0,'testPartialData')
previous_max_lines = SyncCode.MAX_LINES
SyncCode.MAX_LINES = 10
self.populatePersonServerWithSubObject(quiet=1,run=1)
self.synchronize(self.sub_id1)
self.synchronize(self.sub_id2)
self.checkSynchronizationStateIsSynchronized()
person_client1 = self.getPersonClient1()
person1_c = person_client1._getOb(self.id1)
sub_person1_c = person1_c._getOb(self.id1)
sub_sub_person1 = sub_person1_c._getOb(self.id1)
sub_sub_person2 = sub_person1_c._getOb(self.id2)
# remove ('','portal...','person_server')
len_path = len(sub_sub_person1.getPhysicalPath()) - 3
self.failUnless(len_path==3)
len_path = len(sub_sub_person2.getPhysicalPath()) - 3
self.failUnless(len_path==3)
self.failUnless(sub_sub_person1.getDescription()==self.description1)
self.failUnless(sub_sub_person1.getFirstName()==self.first_name1)
self.failUnless(sub_sub_person1.getLastName()==self.last_name1)
self.failUnless(sub_sub_person2.getDescription()==self.description2)
self.failUnless(sub_sub_person2.getFirstName()==self.first_name2)
self.failUnless(sub_sub_person2.getLastName()==self.last_name2)
SyncCode.MAX_LINES = previous_max_lines
# We may add a test in order to check if the slow_sync mode works fine, ie # We may add a test in order to check if the slow_sync mode works fine, ie
# if we do have both object on the client and server side, we must make sure # if we do have both object on the client and server side, we must make sure
# that the server first sends is own data # that the server first sends is own data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment