Permalink
Browse files

Merge pull request #250 from mikelupo/fix_memoryLeaks

In Test cases, Fix potential memory leaks by use of NSURLSession
2 parents bf3232e + ce1642f commit b11843442150082299861ac7d7135aeb00526dc3 @AliSoftware committed on GitHub May 22, 2017
View
@@ -1,7 +1,9 @@
# OHHTTPStubs — CHANGELOG
## Master
-
+* Fixed potential memory leaks with use of NSURLSession as detected by our devs.
+ [@mikelupo](https://github.com/mikelupo
+ [#250](https://github.com/AliSoftware/OHHTTPStubs/pull/250)
* Add precondition assertions in `isScheme` and `isHost` matchers and some documentation in `isHost`, `isScheme` and `isPath`.
[@Liquidsoul](https://github.com/Liquidsoul)
[#248](https://github.com/AliSoftware/OHHTTPStubs/pull/248)
@@ -53,6 +53,7 @@ - (void)setUp
- (void)tearDown
{
[super tearDown];
+ [self.session invalidateAndCancel];
self.session = nil;
}
@@ -195,6 +195,8 @@ - (void)test_SharedNSURLSession
XCTAssertNil(redirectResponse, @"Unexpected redirect response received");
XCTAssertEqualObjects(jsonResponse, json, @"Unexpected data received");
}];
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -220,6 +222,8 @@ - (void)test_NSURLSessionDefaultConfig
XCTAssertNil(redirectResponse, @"Unexpected redirect response received");
XCTAssertEqualObjects(jsonResponse, json, @"Unexpected data received");
}];
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -243,6 +247,8 @@ - (void)test_NSURLSessionDefaultConfig_notFollowingRedirects
XCTAssertEqual(301, [redirectResponse statusCode], @"Expected 301 redirect");
XCTAssertNil(jsonResponse, @"Unexpected data received");
}];
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -268,6 +274,8 @@ - (void)test_NSURLSessionEphemeralConfig
XCTAssertNil(redirectResponse, @"Unexpected redirect response received");
XCTAssertEqualObjects(jsonResponse, json, @"Unexpected data received");
}];
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -296,6 +304,8 @@ - (void)test_NSURLSessionDefaultConfig_Disabled
XCTAssertNil(redirectResponse, @"Redirect response should not have been received as stubs should be disabled");
XCTAssertNil(jsonResponse, @"Data should not have been received as stubs should be disabled");
}];
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -325,6 +335,8 @@ - (void)test_NSURLSession_DataTask_DelegateMethods
[self waitForExpectationsWithTimeout:5 handler:nil];
XCTAssertEqualObjects(_receivedData, expectedResponse, @"Unexpected response");
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -370,6 +382,8 @@ - (void)test_NSURLSessionCustomHTTPBody
[self waitForExpectationsWithTimeout:5 handler:nil];
XCTAssertNil(_receivedData, @"Unexpected response: HTTP body check should not be successful");
+
+ [session finishTasksAndInvalidate];
}
else
{
@@ -403,6 +417,8 @@ - (void)test_NSURLSessionNativeHTTPBody
[self waitForExpectationsWithTimeout:5 handler:nil];
XCTAssertNil(_receivedData, @"[request HTTPBody] is not expected to work. If this has been fixed, the OHHTTPStubs_HTTPBody can be removed.");
+
+ [session finishTasksAndInvalidate];
}
else
{

0 comments on commit b118434

Please sign in to comment.