Skip to content

Commit

Permalink
CBLT-319: Merge branch 'release/1.0.0' into stable
Browse files Browse the repository at this point in the history
* release/1.0.0:
  LiteServ.app: Fixed assertion failure on quit
  CBLT-268: Fix version # displayed in LiteServ About-box
  Fixed bundle version strings.
  Fixed: WebSocket _changes feed wouldn't connect over SSL
  Fixed regression where unchanged attachments get re-sent on every push
  Some build fixes
  Added test for behaviour of attachments not being push replicated for new document revision if only JSON body is updated.
  Verify that revisions with identical content have the same rev id.

Change-Id: I35d8f8ca05388186a31b6c4cd7c6187bd7ace076
  • Loading branch information
Phil Labee committed Jun 16, 2014
2 parents 84f271d + 2d3a97d commit 0688568
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CouchbaseLite.xcodeproj/project.pbxproj
Expand Up @@ -104,7 +104,7 @@
272A690D17B2CCF0000722FA /* CBLFacebookAuthorizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 272A690B17B2CCF0000722FA /* CBLFacebookAuthorizer.h */; };
272A690E17B2CCF0000722FA /* CBLFacebookAuthorizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 272A690C17B2CCF0000722FA /* CBLFacebookAuthorizer.m */; };
272A690F17B2CCF0000722FA /* CBLFacebookAuthorizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 272A690C17B2CCF0000722FA /* CBLFacebookAuthorizer.m */; };
2733022A18F8572700A488F7 /* CBLAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2733022818F8572700A488F7 /* CBLAuthenticator.h */; };
2733022A18F8572700A488F7 /* CBLAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2733022818F8572700A488F7 /* CBLAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
2733022B18F8572700A488F7 /* CBLAuthenticator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2733022918F8572700A488F7 /* CBLAuthenticator.m */; };
2733022C18F8572700A488F7 /* CBLAuthenticator.m in Sources */ = {isa = PBXBuildFile; fileRef = 2733022918F8572700A488F7 /* CBLAuthenticator.m */; };
2733022F18F86C9800A488F7 /* CBLTokenAuthorizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 2733022D18F86C9800A488F7 /* CBLTokenAuthorizer.h */; };
Expand Down Expand Up @@ -366,6 +366,7 @@
278B0CA0152A8B1900577747 /* CBLCanonicalJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 278B0C9E152A8B1900577747 /* CBLCanonicalJSON.h */; };
278B0CA1152A8B1900577747 /* CBLCanonicalJSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 278B0C9F152A8B1900577747 /* CBLCanonicalJSON.m */; };
278B0CA2152A8B1900577747 /* CBLCanonicalJSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 278B0C9F152A8B1900577747 /* CBLCanonicalJSON.m */; };
278D359A19118FBC00C9C8EC /* CBLAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2733022818F8572700A488F7 /* CBLAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
278E4DD81562B40B00DDCEF9 /* MYURLUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 278E4DD61562B40B00DDCEF9 /* MYURLUtils.h */; };
278E4DD91562B40B00DDCEF9 /* MYURLUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 278E4DD71562B40B00DDCEF9 /* MYURLUtils.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
278E4DDA1562B40B00DDCEF9 /* MYURLUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 278E4DD71562B40B00DDCEF9 /* MYURLUtils.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
Expand Down Expand Up @@ -2606,6 +2607,7 @@
27B0B7FC1492BDE800A817AD /* CBLView+Internal.h in Headers */,
27B0B7FD1492BDE800A817AD /* CBL_Body.h in Headers */,
27B0B7FE1492BDE800A817AD /* CBL_Revision.h in Headers */,
278D359A19118FBC00C9C8EC /* CBLAuthenticator.h in Headers */,
27F08C8B15A7A31B003C3E2B /* CBL_Attachment.h in Headers */,
2785B48D18D3F11900CBB41A /* CBLReplication+Transformation.h in Headers */,
27B0B7FF1492BDE800A817AD /* CBL_Server.h in Headers */,
Expand Down
4 changes: 2 additions & 2 deletions Listener/CouchbaseLiteListener-Info.plist
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>${CBL_VERSION_STRING} (${CURRENT_PROJECT_VERSION})</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012-2013 Couchbase, Inc. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
1 change: 0 additions & 1 deletion LiteServ App/AppDelegate.m
Expand Up @@ -101,7 +101,6 @@ - (IBAction) quit:(id)sender {
NSLog(@"Quitting LiteServ.app");

[_listener stop];
[_manager close];

[(NSApplication*)NSApp terminate: self];
}
Expand Down
4 changes: 2 additions & 2 deletions LiteServ App/LiteServ App-Info.plist
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>${CBL_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand All @@ -29,7 +29,7 @@
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright ©2013 Couchbase, Inc.</string>
<string>Copyright © 2013-2014 Couchbase, Inc. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
36 changes: 36 additions & 0 deletions Source/API/APITests.m
Expand Up @@ -183,6 +183,41 @@ static void createDocuments(CBLDatabase* db, unsigned n) {
closeTestDB(db);
}

TestCase(API_RevisionIdEquivalentRevisions) {

NSDictionary* properties = @{@"testName": @"testCreateRevisions",
@"tag": @1337};
NSDictionary* properties2 = @{@"testName": @"testCreateRevisions",
@"tag": @1338};

CBLDatabase* db = createEmptyDB();
CBLDocument* doc = [db createDocument];
CAssert(!doc.isDeleted);
CBLUnsavedRevision* newRev = [doc newRevision];
[newRev setUserProperties:properties];

NSError* error;
CBLSavedRevision* rev1 = [newRev save: &error];
CAssert(rev1, @"Save 1 failed: %@", error);

CBLUnsavedRevision* newRev2a = [rev1 createRevision];
[newRev2a setUserProperties:properties2];
CBLSavedRevision* rev2a = [newRev2a save: &error];
CAssert(rev2a, @"Save rev2a failed: %@", error);
Log(@"rev2a: %@", rev2a);

CBLUnsavedRevision* newRev2b = [rev1 createRevision];
[newRev2b setUserProperties:properties2];
CBLSavedRevision* rev2b = [newRev2b saveAllowingConflict:&error];
CAssert(rev2b, @"Save rev2b failed: %@", error);
Log(@"rev2b: %@", rev2b);

// since both rev2a and rev2b have same content, they should have
// the same rev ids.
CAssertEqual(rev2a.revisionID, rev2b.revisionID);

}

TestCase(API_CreateNewRevisions) {
RequireTestCase(API_CreateRevisions);
NSDictionary* properties = @{@"testName": @"testCreateRevisions",
Expand Down Expand Up @@ -238,6 +273,7 @@ static void createDocuments(CBLDatabase* db, unsigned n) {
CAssert([doc.currentRevisionID hasPrefix: @"2-"],
@"Document revision ID is still %@", doc.currentRevisionID);


// Add a deletion/tombstone revision:
newRev = doc.newRevision;
CAssertEq(newRev.parentRevisionID, rev2.revisionID);
Expand Down
75 changes: 75 additions & 0 deletions Source/API/ReplicationAPITests.m
Expand Up @@ -20,6 +20,7 @@
// This db will get deleted and overwritten during every test.
#define kPushThenPullDBName @"cbl_replicator_pushpull"
#define kNDocuments 1000
#define kAttSize 1*1024
// This one too.
#define kEncodedDBName @"cbl_replicator_encoding"
// This one's never actually read or written to.
Expand Down Expand Up @@ -158,6 +159,80 @@ static void runReplication(CBLReplication* repl, unsigned expectedChangesCount)
[db.manager close];
}

TestCase(RunPushReplicationNoSendAttachmentForUpdatedRev) {

//RequireTestCase(CreateReplicators);
NSURL* remoteDbURL = RemoteTestDBURL(kPushThenPullDBName);
if (!remoteDbURL) {
Warn(@"Skipping test RunPushReplication (no remote test DB URL)");
return;
}

Log(@"Creating %d documents...", kNDocuments);
CBLDatabase* db = createEmptyManagerAndDb();

CBLDocument* doc = [db createDocument];

NSError* error;
CBLSavedRevision *rev1 = [doc putProperties: @{@"dynamic":@1} error: &error];

CAssert(!error);

CAssert(![db sequenceHasAttachments: rev1.sequence]);

unsigned char attachbytes[kAttSize];
for(int i=0; i<kAttSize; i++) {
attachbytes[i] = 1;
}

NSData* attach1 = [NSData dataWithBytes:attachbytes length:kAttSize];

CBLUnsavedRevision *rev2 = [doc newRevision];
[rev2 setAttachmentNamed: @"attach" withContentType: @"text/plain" content:attach1];

[rev2 save:&error];

CAssert(!error);

CAssertEq(rev2.attachments.count, (NSUInteger)1);
CAssertEqual(rev2.attachmentNames, [NSArray arrayWithObject: @"attach"]);

Log(@"Pushing 1...");
CBLReplication* repl = [db createPushReplication: remoteDbURL];
repl.createTarget = NO;
[repl start];

runReplication(repl, 1);
AssertNil(repl.lastError);


// Add a third revision that doesn't update the attachment:
Log(@"Updating doc to rev3");

// copy the document
NSMutableDictionary *contents = [doc.properties mutableCopy];

// toggle value of check property
[contents setObject: @2 forKey: @"dynamic"];

// save the updated document
[doc putProperties: contents error: &error];

CAssert(!error);

Log(@"Pushing 2...");
repl = [db createPushReplication: remoteDbURL];
repl.createTarget = NO;
[repl start];

runReplication(repl, 1);
AssertNil(repl.lastError);


[db.manager close];
}



TestCase(RunPushReplication) {

Expand Down
2 changes: 1 addition & 1 deletion Source/CBLRemoteRequest.m
Expand Up @@ -43,7 +43,7 @@ + (NSString*) userAgentHeader {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if TARGET_OS_IPHONE
const char* platform = @"iOS";
const char* platform = "iOS";
#else
const char* platform = "Mac OS X";
#endif
Expand Down
3 changes: 2 additions & 1 deletion Source/CBL_Pusher.m
Expand Up @@ -276,7 +276,7 @@ - (void) processInbox: (CBL_RevisionList*)changes {
// Strip any attachments already known to the target db:
if (properties.cbl_attachments) {
// Look for the latest common ancestor and stub out older attachments:
int minRevPos = findCommonAncestor(rev, possibleAncestors);
int minRevPos = findCommonAncestor(populatedRev, possibleAncestors);
[CBLDatabase stubOutAttachmentsIn: populatedRev beforeRevPos: minRevPos + 1
attachmentsFollow: NO];
properties = populatedRev.properties;
Expand Down Expand Up @@ -515,6 +515,7 @@ static int findCommonAncestor(CBL_Revision* rev, NSArray* possibleRevIDs) {
if (possibleRevIDs.count == 0)
return 0;
NSArray* history = [CBLDatabase parseCouchDBRevisionHistory: rev.properties];
Assert(history, @"rev is missing _revisions property");
NSString* ancestorID = [history firstObjectCommonWithArray: possibleRevIDs];
if (!ancestorID)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/CouchbaseLite-Info.plist
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>${CBL_VERSION_STRING}</string>
<string>${CBL_VERSION_STRING} (${CURRENT_PROJECT_VERSION})</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion vendor/WebSockets-Cocoa
Submodule WebSockets-Cocoa updated 2 files
+3 −3 WebSocket/WebSocketClient.m
+1 −1 vendor/MYUtilities

0 comments on commit 0688568

Please sign in to comment.