Showing
6 changed files
with
71 additions
and
3 deletions
@@ -78,9 +78,6 @@ | @@ -78,9 +78,6 @@ | ||
78 | CFHTTPAuthenticationRef requestAuthentication; | 78 | CFHTTPAuthenticationRef requestAuthentication; |
79 | NSMutableDictionary *requestCredentials; | 79 | NSMutableDictionary *requestCredentials; |
80 | 80 | ||
81 | - // Credentials associated with the authentication (reused until server says no) | ||
82 | - //CFMutableDictionaryRef credentials; | ||
83 | - | ||
84 | // HTTP status code, eg: 200 = OK, 404 = Not found etc | 81 | // HTTP status code, eg: 200 = OK, 404 = Not found etc |
85 | int responseStatusCode; | 82 | int responseStatusCode; |
86 | 83 |
@@ -11,6 +11,18 @@ | @@ -11,6 +11,18 @@ | ||
11 | 11 | ||
12 | @implementation ASIHTTPRequestTests | 12 | @implementation ASIHTTPRequestTests |
13 | 13 | ||
14 | +/* | ||
15 | +More tests needed for: | ||
16 | + - Delegates | ||
17 | + - Progress delegates | ||
18 | + - Content length | ||
19 | + - POSTing | ||
20 | + - File downloads | ||
21 | + - Authentication | ||
22 | + - Keychains | ||
23 | + - Session persistence | ||
24 | +*/ | ||
25 | + | ||
14 | - (void)testBasicDownload | 26 | - (void)testBasicDownload |
15 | { | 27 | { |
16 | //Grab data | 28 | //Grab data |
@@ -45,4 +57,62 @@ | @@ -45,4 +57,62 @@ | ||
45 | STAssertNotNil(error,@"Failed to generate an error for a bad host"); | 57 | STAssertNotNil(error,@"Failed to generate an error for a bad host"); |
46 | } | 58 | } |
47 | 59 | ||
60 | +- (void)testOperationQueue | ||
61 | +{ | ||
62 | + NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease]; | ||
63 | + | ||
64 | + NSURL *url; | ||
65 | + url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request-tests/first"] autorelease]; | ||
66 | + ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
67 | + [queue addOperation:request1]; | ||
68 | + | ||
69 | + url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request-tests/second"] autorelease]; | ||
70 | + ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
71 | + [queue addOperation:request2]; | ||
72 | + | ||
73 | + url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request-tests/third"] autorelease]; | ||
74 | + ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
75 | + [queue addOperation:request3]; | ||
76 | + | ||
77 | + url = [[[NSURL alloc] initWithString:@"http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaab.com"] autorelease]; | ||
78 | + ASIHTTPRequest *request4 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
79 | + [queue addOperation:request4]; | ||
80 | + | ||
81 | + url = [[[NSURL alloc] initWithString:@"http://asi/asi-http-request-tests/broken"] autorelease]; | ||
82 | + ASIHTTPRequest *request5 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | ||
83 | + [queue addOperation:request5]; | ||
84 | + | ||
85 | + [queue waitUntilAllOperationsAreFinished]; | ||
86 | + | ||
87 | + BOOL success; | ||
88 | + | ||
89 | + success = ([request1 error] == nil); | ||
90 | + STAssertTrue(success,@"Request 1 failed"); | ||
91 | + | ||
92 | + success = [[request1 dataString] isEqualToString:@"This is the expected content for the first string"]; | ||
93 | + STAssertTrue(success,@"Failed to download the correct data for request 1"); | ||
94 | + | ||
95 | + success = ([request2 error] == nil); | ||
96 | + STAssertTrue(success,@"Request 2 failed"); | ||
97 | + | ||
98 | + success = [[request2 dataString] isEqualToString:@"This is the expected content for the second string"]; | ||
99 | + STAssertTrue(success,@"Failed to download the correct data for request 2"); | ||
100 | + | ||
101 | + success = ([request3 error] == nil); | ||
102 | + STAssertTrue(success,@"Request 3 failed"); | ||
103 | + | ||
104 | + success = [[request3 dataString] isEqualToString:@"This is the expected content for the third string"]; | ||
105 | + STAssertTrue(success,@"Failed to download the correct data for request 3"); | ||
106 | + | ||
107 | + success = ([request4 error] != nil); | ||
108 | + STAssertTrue(success,@"Request 4 succeed when it should have failed"); | ||
109 | + | ||
110 | + success = ([request5 error] == nil); | ||
111 | + STAssertTrue(success,@"Request 5 failed"); | ||
112 | + | ||
113 | + success = ([request5 responseStatusCode] == 404); | ||
114 | + STAssertTrue(success,@"Failed to obtain the correct status code for request 5"); | ||
115 | + | ||
116 | +} | ||
117 | + | ||
48 | @end | 118 | @end |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff was suppressed by a .gitattributes entry.
-
Please register or login to post a comment