Author: ericwa
Date: Sun Mar 23 22:58:23 2014
New Revision: 10620
URL: http://svn.gna.org/viewcvs/etoile?rev=10620&view=rev
Log:
COSynchronizerClient: set metadata on received branch & persistent root
Modified:
trunk/Etoile/Frameworks/CoreObject/Core/COPersistentRoot+Private.h
trunk/Etoile/Frameworks/CoreObject/Synchronization/COSynchronizerClient.m
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizer.m
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.h
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.m
Modified: trunk/Etoile/Frameworks/CoreObject/Core/COPersistentRoot+Private.h
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Core/COPersistentRoot%2BPrivate.h?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Core/COPersistentRoot+Private.h
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Core/COPersistentRoot+Private.h Sun Mar
23 22:58:23 2014
@@ -6,6 +6,11 @@
*/
#import <CoreObject/COPersistentRoot.h>
+
+/**
+ * Metadata dictionary key used by the `name` property.
+ */
+extern NSString * const COPersistentRootName;
@class COStoreTransaction;
Modified:
trunk/Etoile/Frameworks/CoreObject/Synchronization/COSynchronizerClient.m
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Synchronization/COSynchronizerClient.m?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Synchronization/COSynchronizerClient.m
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Synchronization/COSynchronizerClient.m
Sun Mar 23 22:58:23 2014
@@ -64,6 +64,7 @@
if (persistentRoot == nil)
{
[txn createPersistentRootWithUUID: message.persistentRootUUID
persistentRootForCopy: nil];
+ [txn setMetadata: message.persistentRootMetadata
forPersistentRoot: message.persistentRootUUID];
}
// 2. Do we have the branch?
@@ -74,6 +75,10 @@
parentBranch: nil
initialRevision:
message.currentRevision.revisionUUID
forPersistentRoot: message.persistentRootUUID];
+
+ [txn setMetadata: message.branchMetadata
+ forBranch: message.branchUUID
+ ofPersistentRoot: message.persistentRootUUID];
[txn setCurrentBranch: message.branchUUID
forPersistentRoot: message.persistentRootUUID];
Modified:
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizer.m
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizer.m?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizer.m
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizer.m
Sun Mar 23 22:58:23 2014
@@ -11,6 +11,16 @@
@end
@implementation TestSynchronizer
+
+- (void) testPersistentRootMetadataReplicated
+{
+ UKObjectsEqual([self persistentRootMetadataForTest],
clientPersistentRoot.metadata);
+}
+
+- (void) testBranchMetadataReplicated
+{
+ UKObjectsEqual([self branchMetadataForTest], clientBranch.metadata);
+}
- (void) testBasicReplicationToClient
{
@@ -202,8 +212,8 @@
// Before the merged changes arrives at the client, make another commit
on the client
[[clientBranch rootObject] setLabel: @"more changes"];
- [clientPersistentRoot commitWithMetadata: [self clientMetadataForTest]];
- UKObjectsEqual([self clientMetadataForTest], [[clientPersistentRoot
currentRevision] metadata]);
+ [clientPersistentRoot commitWithMetadata: [self
clientRevisionMetadataForTest]];
+ UKObjectsEqual([self clientRevisionMetadataForTest],
[[clientPersistentRoot currentRevision] metadata]);
// This should not produce any more messages
@@ -214,7 +224,7 @@
[transport deliverMessagesToClient];
UKObjectsEqual(@"more changes", [[clientBranch rootObject] label]);
- UKObjectsEqual([self clientMetadataForTest], [[clientPersistentRoot
currentRevision] metadata]);
+ UKObjectsEqual([self clientRevisionMetadataForTest],
[[clientPersistentRoot currentRevision] metadata]);
// The client should push back the @"more changes" change to the server
Modified:
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.h
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.h?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
---
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.h
(original)
+++
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.h
Sun Mar 23 22:58:23 2014
@@ -31,8 +31,11 @@
- (UnorderedGroupNoOpposite *) addAndCommitServerChild;
- (UnorderedGroupNoOpposite *) addAndCommitClientChild;
-- (NSDictionary *)serverMetadataForTest;
-- (NSDictionary *)clientMetadataForTest;
+- (NSDictionary *)serverRevisionMetadataForTest;
+- (NSDictionary *)clientRevisionMetadataForTest;
+
+- (NSDictionary *)branchMetadataForTest;
+- (NSDictionary *)persistentRootMetadataForTest;
- (NSArray *)serverMessages;
- (NSArray *)clientMessages;
Modified:
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.m
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.m?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
---
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.m
(original)
+++
trunk/Etoile/Frameworks/CoreObject/Tests/Synchronization/TestSynchronizerCommon.m
Sun Mar 23 22:58:23 2014
@@ -17,7 +17,9 @@
[[[COSQLiteStore alloc] initWithURL: CLIENT_STORE_URL] clearStore];
serverPersistentRoot = [ctx insertNewPersistentRootWithEntityName:
@"UnorderedGroupNoOpposite"];
+ serverPersistentRoot.metadata = [self persistentRootMetadataForTest];
serverBranch = [serverPersistentRoot currentBranch];
+ serverBranch.metadata = [self branchMetadataForTest];
[ctx commit];
server = [[COSynchronizerServer alloc] initWithBranch: serverBranch];
@@ -26,6 +28,7 @@
clientCtx = [COEditingContext contextWithURL: CLIENT_STORE_URL];
client = [[COSynchronizerClient alloc] initWithClientID: @"client"
editingContext: clientCtx];
+ // Transmits the persistent root to the client
[transport addClient: client];
clientPersistentRoot = client.persistentRoot;
@@ -45,21 +48,31 @@
ETAssert(error == nil);
}
-- (NSDictionary *)serverMetadataForTest
+- (NSDictionary *)serverRevisionMetadataForTest
{
return @{ @"testMetadata" : @"server"};
}
-- (NSDictionary *)clientMetadataForTest
+- (NSDictionary *)clientRevisionMetadataForTest
{
return @{ @"testMetadata" : @"client"};
+}
+
+- (NSDictionary *)branchMetadataForTest
+{
+ return @{ kCOBranchLabel : @"my branch" };
+}
+
+- (NSDictionary *)persistentRootMetadataForTest
+{
+ return @{ COPersistentRootName : @"my persistent root" };
}
- (UnorderedGroupNoOpposite *) addAndCommitServerChild
{
UnorderedGroupNoOpposite *serverChild1 = [[serverBranch
objectGraphContext] insertObjectWithEntityName:
@"Anonymous.UnorderedGroupNoOpposite"];
[[[serverBranch rootObject] mutableSetValueForKey: @"contents"]
addObject: serverChild1];
- [serverPersistentRoot commitWithMetadata: [self serverMetadataForTest]];
+ [serverPersistentRoot commitWithMetadata: [self
serverRevisionMetadataForTest]];
return serverChild1;
}
@@ -67,7 +80,7 @@
{
UnorderedGroupNoOpposite *clientChild1 = [[clientBranch
objectGraphContext] insertObjectWithEntityName:
@"Anonymous.UnorderedGroupNoOpposite"];
[[[clientBranch rootObject] mutableSetValueForKey: @"contents"]
addObject: clientChild1];
- [clientPersistentRoot commitWithMetadata: [self clientMetadataForTest]];
+ [clientPersistentRoot commitWithMetadata: [self
clientRevisionMetadataForTest]];
return clientChild1;
}
_______________________________________________
Etoile-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-cvs