Changeset 11895 for lang/objective-c

Show
Ignore:
Timestamp:
05/18/08 17:56:03 (6 months ago)
Author:
mootoh
Message:

confirmed Bookmark entry updated via API.

Location:
lang/objective-c/HatebuCoreData
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-c/HatebuCoreData/HatenaBookmark.h

    r11864 r11895  
    1111@interface Bookmark (Hatena) 
    1212 
    13 +(NSURLRequest *) makeRequest:(NSURL *)url withFields:(NSDictionary *)fields; 
     13+(NSMutableURLRequest *) makeRequest:(NSURL *)url withFields:(NSDictionary *)fields; 
    1414+(NSString *) sendRequest:(NSURLRequest *)request; 
    1515 
  • lang/objective-c/HatebuCoreData/HatenaBookmark.m

    r11864 r11895  
    2929} 
    3030 
    31 +(NSURLRequest *) makeRequest:(NSURL *)url withFields:(NSDictionary *)fields { 
     31+(NSMutableURLRequest *) makeRequest:(NSURL *)url withFields:(NSDictionary *)fields { 
    3232  NSMutableURLRequest* req = [NSMutableURLRequest 
    3333    requestWithURL: url 
  • lang/objective-c/HatebuCoreData/HatenaBookmarkTest.m

    r11870 r11895  
    7676} 
    7777 
    78    
     78-(void) testEditUriPost { 
     79  NSDictionary *fields = [NSDictionary dictionaryWithObject:cred_ forKey:@"X-WSSE"]; 
     80  NSMutableURLRequest *req = [Bookmark makeRequest:[Bookmark editURL:[self latestBookmark]] withFields:fields]; 
     81  STAssertNotNil(req, @"request create failed"); 
     82 
     83  NSString *entryFeed = [Bookmark sendRequest:req]; 
     84  NSLog(@"entryFeed : %@", entryFeed); 
     85  STAssertNotNil(entryFeed, @"sendRequest failed"); 
     86  STAssertTrue([entryFeed hasPrefix:@"<?xml version="], @"feed should be xml"); 
     87 
     88  // parse entry 
     89  NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString:entryFeed options:NSXMLDocumentTidyXML error:nil];  
     90  STAssertNotNil(doc, @"parse error", nil); 
     91 
     92  NSXMLElement *oldTitleElm = [[[doc rootElement] nodesForXPath: @"/entry/title" error: nil] objectAtIndex:0]; 
     93  STAssertNotNil(oldTitleElm, @"bad title", nil); 
     94  NSString *oldTitle = [oldTitleElm stringValue]; 
     95 
     96  NSXMLElement *oldSummaryElm = [[[doc rootElement] nodesForXPath: @"/entry/summary" error: nil] objectAtIndex:0]; 
     97  NSString *oldSummary = [oldSummaryElm stringValue]; 
     98  STAssertNotNil(oldSummary, @"bad title", nil); 
     99 
     100 
     101  NSString *suffix = @" testEditUriPost"; 
     102  NSString *newTitle = [NSString stringWithFormat:@"%@ %@", oldTitle, suffix]; 
     103 
     104  NSString *newSummary = [NSString stringWithFormat:@"%@ %@", oldSummary, suffix]; 
     105 
     106  [oldTitleElm setStringValue:newTitle]; 
     107  [oldSummaryElm setStringValue:newSummary]; 
     108 
     109  // make POST request 
     110  [req setHTTPMethod:@"PUT"]; 
     111  [req setHTTPBody:[doc XMLData]]; 
     112 
     113  NSString *result = [Bookmark sendRequest:req]; 
     114  STAssertNotNil(result, @"sendRequest failed"); 
     115} 
     116 
    79117@end 
    80118// vim:set ft=objc: