I have the following Objective C test code in a SenTestCase class. I get no errors, but the httpReceiveDataFinished method never gets called. Is this because the test is ended before the delegate has a chance to process the http method?
If that is the case how can I spin off a thread (or something similar) to make the test wait for a few seconds?
Thanks a million for any help. I have programmed Java for years, but Objective-C only a few days.
- (void)testExample
{
HttpClient *client = [[HttpClient alloc] init];
client.method = METHOD_GET;
client.followRedirects = YES;
[client processRequest:@"http://google.com" delegate:self];
NSLog(@"Test Over");
}
-(void) httpReceiveError:(NSError*)error {
NSLog(@"***\n%@\n***",[error description]);
}
- (void) httpReceiveDataChunk:(NSData *)data {
[self.httpResponseData appendData:data];
}
-(void) httpReceiveDataFinished {
NSString *result = [[NSString alloc]
initWithData:self.httpResponseData
encoding:NSUTF8StringEncoding];
NSLog(@"***\nRESULT: %@ \n***",result);
}