You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by pw...@apache.org on 2013/04/24 16:50:11 UTC
svn commit: r1471446 - in /chemistry/objectivecmis/trunk:
ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
ObjectiveCMISTests/ObjectiveCMISTests.m
Author: pweschmidt
Date: Wed Apr 24 14:50:11 2013
New Revision: 1471446
URL: http://svn.apache.org/r1471446
Log:
replaced malloc with foundation classes. some adjustments for the unit tests were necessary due to restructuring of test data on Amazon server
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m?rev=1471446&r1=1471445&r2=1471446&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m Wed Apr 24 14:50:11 2013
@@ -90,10 +90,8 @@ const NSUInteger kRawBufferSize = 24576;
@property (nonatomic, strong) NSOutputStream * encoderStream;
@property (nonatomic, strong) NSData * streamStartData;
@property (nonatomic, strong) NSData * streamEndData;
-@property (nonatomic, strong) NSMutableData * residualDataBuffer;
@property (nonatomic, assign) unsigned long long encodedLength;
-@property (nonatomic, assign, readwrite) const uint8_t * buffer;
-@property (nonatomic, assign, readwrite) uint8_t * bufferOnHeap;
+@property (nonatomic, strong) NSData * dataBuffer;
@property (nonatomic, assign, readwrite) size_t bufferOffset;
@property (nonatomic, assign, readwrite) size_t bufferLimit;
@@ -339,10 +337,6 @@ totalBytesExpectedToWrite:(NSInteger)tot
self.streamStartData = nil;
self.bufferOffset = 0;
self.bufferLimit = 0;
- self.bufferOnHeap = malloc(kFullBufferSize);
- if (NULL != self.bufferOnHeap) {
- self.buffer = self.bufferOnHeap;
- }
}
if (self.inputStream != nil) {
NSInteger rawBytesRead;
@@ -353,24 +347,16 @@ totalBytesExpectedToWrite:(NSInteger)tot
}
else if (0 != rawBytesRead){
NSData *encodedBuffer = [CMISBase64Encoder dataByEncodingText:[NSData dataWithBytes:rawBuffer length:rawBytesRead]];
- NSUInteger encodedLength = (encodedBuffer.length <= kFullBufferSize) ? encodedBuffer.length : kFullBufferSize;
- if (encodedBuffer.length > kFullBufferSize) {
- NSLog(@"encoded buffer length is %d but we should only have %d", encodedBuffer.length, kFullBufferSize);
- }
- [encodedBuffer getBytes:self.bufferOnHeap length:encodedLength];
+ self.dataBuffer = [NSData dataWithData:encodedBuffer];
self.bufferOffset = 0;
- self.bufferLimit = encodedLength;
+ self.bufferLimit = encodedBuffer.length;
}
else{
[self.inputStream close];
self.inputStream = nil;
- if (self.bufferOnHeap != NULL) {
- free(self.bufferOnHeap);
- }
- self.bufferOnHeap = NULL;
- self.buffer = [self.streamEndData bytes];
self.bufferOffset = 0;
self.bufferLimit = self.streamEndData.length;
+ self.dataBuffer = [NSData dataWithData:self.streamEndData];
}
if ((self.bufferLimit == self.bufferOffset) && self.encoderStream != nil) {
self.encoderStream.delegate = nil;
@@ -385,8 +371,11 @@ totalBytesExpectedToWrite:(NSInteger)tot
}
if (self.bufferOffset != self.bufferLimit) {
+ NSUInteger length = self.dataBuffer.length;
+ uint8_t buffer[length];
+ [self.dataBuffer getBytes:buffer length:length];
NSInteger bytesWritten;
- bytesWritten = [self.encoderStream write:&self.buffer[self.bufferOffset] maxLength:self.bufferLimit - self.bufferOffset];
+ bytesWritten = [self.encoderStream write:&buffer[self.bufferOffset] maxLength:self.bufferLimit - self.bufferOffset];
if (bytesWritten <= 0) {
[self stopSendWithStatus:@"Network write error"];
}
@@ -420,9 +409,8 @@ totalBytesExpectedToWrite:(NSInteger)tot
NSString *start = [NSString stringWithFormat:@"%@%@", xmlStart, xmlContentStart];
self.streamStartData = [NSMutableData dataWithData:[start dataUsingEncoding:NSUTF8StringEncoding]];
- self.buffer = [self.streamStartData bytes];
self.bufferLimit = self.streamStartData.length;
- self.bufferOnHeap = NULL;
+ self.dataBuffer = [NSData dataWithData:self.streamStartData];
NSString *xmlContentEnd = [writer xmlContentEndElement];
NSString *xmlProperties = [writer xmlPropertiesElements];
@@ -470,13 +458,9 @@ totalBytesExpectedToWrite:(NSInteger)tot
{
if(nil != statusString)
CMISLogDebug([NSString stringWithFormat:@"Upload request terminated: Message is %@", statusString]);
- if (self.bufferOnHeap) {
- free(self.bufferOnHeap);
- self.bufferOnHeap = NULL;
- }
- self.buffer = NULL;
self.bufferOffset = 0;
self.bufferLimit = 0;
+ self.dataBuffer = nil;
if (self.connection != nil) {
[self.connection cancel];
self.connection = nil;
Modified: chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1471446&r1=1471445&r2=1471446&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m Wed Apr 24 14:50:11 2013
@@ -664,7 +664,7 @@
// Get all the versions of the document
[document retrieveAllVersionsWithCompletionBlock:^(CMISCollection *allVersionsOfDocument, NSError *error) {
STAssertNil(error, @"Error while retrieving all versions of document : %@", [error description]);
- STAssertTrue(allVersionsOfDocument.items.count == 6, @"Expected 6 versions of document, but was %d", allVersionsOfDocument.items.count);
+ STAssertTrue(allVersionsOfDocument.items.count >= 5, @"Expected at least 5 versions of document, but was %d", allVersionsOfDocument.items.count);
// Print out the version labels and verify them, while also verifying that they are ordered by creation date, descending
NSDate *previousModifiedDate = document.lastModificationDate;
@@ -1612,7 +1612,7 @@
{
[self runTest:^ {
// Fetch test document
- NSString *path = [NSString stringWithFormat:@"%@ios-test/test-word-doc.docx", self.rootFolder.path];
+ NSString *path = [NSString stringWithFormat:@"%@ios-test/millenium-dome-exif.jpg", self.rootFolder.path];
CMISOperationContext *operationContext = [CMISOperationContext defaultOperationContext];
operationContext.renditionFilterString = @"*";
[self.session retrieveObjectByPath:path operationContext:operationContext completionBlock:^(CMISObject *object, NSError *error) {
@@ -1662,7 +1662,7 @@
{
[self runTest:^ {
// Fetch test document
- NSString *path = [NSString stringWithFormat:@"%@ios-test/test-word-doc.docx", self.rootFolder.path];
+ NSString *path = [NSString stringWithFormat:@"%@ios-test/millenium-dome-exif.jpg", self.rootFolder.path];
CMISOperationContext *operationContext = [CMISOperationContext defaultOperationContext];
operationContext.renditionFilterString = @"*";
[self.session retrieveObjectByPath:path operationContext:operationContext completionBlock:^(CMISObject *object, NSError *error) {