Changeset 11865 for lang/objective-c

Show
Ignore:
Timestamp:
05/18/08 13:35:55 (6 months ago)
Author:
mootoh
Message:

add EditURI test case.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-c/HatebuCoreData/HatenaBookmarkTest.m

    r11864 r11865  
    3131  NSURLRequest *req = [Bookmark makeRequest:[Bookmark feedURL] withFields:fields]; 
    3232  STAssertNotNil(req, @"request create failed"); 
     33 
    3334  NSString *result = [Bookmark sendRequest:req]; 
    3435  STAssertNotNil(result, @"sendRequest failed"); 
    35   NSLog(@"result: %@", result); 
    3636  STAssertTrue([result hasPrefix:@"<?xml version="], @"feed should be xml"); 
    3737} 
    3838 
     39-(NSString *)latestBookmark { 
     40  NSDictionary *fields = [NSDictionary dictionaryWithObject:cred_ forKey:@"X-WSSE"]; 
     41  NSURLRequest *req = [Bookmark makeRequest:[Bookmark feedURL] withFields:fields]; 
     42  NSString *recent = [Bookmark sendRequest:req]; 
     43 
     44  NSXMLDocument *doc = [[NSXMLDocument alloc] initWithXMLString:recent options:NSXMLDocumentTidyXML error:nil];  
     45  STAssertNotNil(doc, @"parse error", nil); 
     46 
     47  NSArray *ary = [[doc rootElement] nodesForXPath: @"/feed/entry" error: nil]; 
     48  STAssertNotNil(ary, @"no entries", nil); 
     49 
     50  NSXMLElement *entry = [ary objectAtIndex:0]; 
     51  STAssertNotNil(entry, @"bad entry", nil); 
     52 
     53  return [[[entry elementsForName: @"id"] objectAtIndex:0] stringValue]; 
     54} 
     55 
     56-(void) testLatest { 
     57  NSString *latest = [self latestBookmark]; 
     58  NSLog(@"latest entry id : %@", latest); 
     59  STAssertNotNil(latest, @"latest", nil); 
     60} 
     61 
    3962-(void) testEditUriGet { 
    40   NSDictionary *fields = [NSDictionary dictionary]; 
    41   NSURLRequest *req = [Bookmark makeRequest:[Bookmark editURL:@"XXX"] withFields:fields]; 
     63  NSDictionary *fields = [NSDictionary dictionaryWithObject:cred_ forKey:@"X-WSSE"]; 
     64  NSURLRequest *req = [Bookmark makeRequest:[Bookmark editURL:[self latestBookmark]] withFields:fields]; 
    4265  STAssertNotNil(req, @"request create failed"); 
     66 
     67  NSString *result = [Bookmark sendRequest:req]; 
     68  NSLog(@"result : %@", result); 
     69  STAssertNotNil(result, @"sendRequest failed"); 
     70  STAssertTrue([result hasPrefix:@"<?xml version="], @"feed should be xml"); 
    4371} 
     72 
    4473   
    4574@end