// // Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file is distributed // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. // #import #import #import "OCMock.h" #import "AWSTestUtility.h" #import "AWSSimpleDBService.h" static id mockNetworking = nil; @interface AWSGeneralSimpleDBTests : XCTestCase @end @implementation AWSGeneralSimpleDBTests - (void)setUp { [super setUp]; [AWSTestUtility setupFakeCognitoCredentialsProvider]; mockNetworking = OCMClassMock([AWSNetworking class]); AWSTask *errorTask = [AWSTask taskWithError:[NSError errorWithDomain:@"OCMockExpectedNetworkingError" code:8848 userInfo:nil]]; OCMStub([mockNetworking sendRequest:[OCMArg isKindOfClass:[AWSNetworkingRequest class]]]).andReturn(errorTask); } - (void)tearDown { [super tearDown]; } - (void)testConstructors { NSString *key = @"testSimpleDBConstructors"; XCTAssertNotNil([AWSSimpleDB defaultSimpleDB]); XCTAssertEqual([[AWSSimpleDB defaultSimpleDB] class], [AWSSimpleDB class]); XCTAssertNil([AWSSimpleDB SimpleDBForKey:key]); AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionSAEast1 credentialsProvider:[AWSServiceManager defaultServiceManager].defaultServiceConfiguration.credentialsProvider]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; XCTAssertNotNil([AWSSimpleDB SimpleDBForKey:key]); XCTAssertEqual([[AWSSimpleDB SimpleDBForKey:key] class], [AWSSimpleDB class]); XCTAssertEqual([AWSSimpleDB SimpleDBForKey:key].configuration.regionType, AWSRegionSAEast1); [AWSSimpleDB removeSimpleDBForKey:key]; XCTAssertNil([AWSSimpleDB SimpleDBForKey:key]); } - (void)testBatchDeleteAttributes { NSString *key = @"testBatchDeleteAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] batchDeleteAttributes:[AWSSimpleDBBatchDeleteAttributesRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testBatchDeleteAttributesCompletionHandler { NSString *key = @"testBatchDeleteAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] batchDeleteAttributes:[AWSSimpleDBBatchDeleteAttributesRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testBatchPutAttributes { NSString *key = @"testBatchPutAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] batchPutAttributes:[AWSSimpleDBBatchPutAttributesRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testBatchPutAttributesCompletionHandler { NSString *key = @"testBatchPutAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] batchPutAttributes:[AWSSimpleDBBatchPutAttributesRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testCreateDomain { NSString *key = @"testCreateDomain"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] createDomain:[AWSSimpleDBCreateDomainRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testCreateDomainCompletionHandler { NSString *key = @"testCreateDomain"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] createDomain:[AWSSimpleDBCreateDomainRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDeleteAttributes { NSString *key = @"testDeleteAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] deleteAttributes:[AWSSimpleDBDeleteAttributesRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDeleteAttributesCompletionHandler { NSString *key = @"testDeleteAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] deleteAttributes:[AWSSimpleDBDeleteAttributesRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDeleteDomain { NSString *key = @"testDeleteDomain"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] deleteDomain:[AWSSimpleDBDeleteDomainRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDeleteDomainCompletionHandler { NSString *key = @"testDeleteDomain"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] deleteDomain:[AWSSimpleDBDeleteDomainRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDomainMetadata { NSString *key = @"testDomainMetadata"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] domainMetadata:[AWSSimpleDBDomainMetadataRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testDomainMetadataCompletionHandler { NSString *key = @"testDomainMetadata"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] domainMetadata:[AWSSimpleDBDomainMetadataRequest new] completionHandler:^(AWSSimpleDBDomainMetadataResult* _Nullable response, NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); XCTAssertNil(response); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testGetAttributes { NSString *key = @"testGetAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] getAttributes:[AWSSimpleDBGetAttributesRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testGetAttributesCompletionHandler { NSString *key = @"testGetAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] getAttributes:[AWSSimpleDBGetAttributesRequest new] completionHandler:^(AWSSimpleDBGetAttributesResult* _Nullable response, NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); XCTAssertNil(response); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testListDomains { NSString *key = @"testListDomains"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] listDomains:[AWSSimpleDBListDomainsRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testListDomainsCompletionHandler { NSString *key = @"testListDomains"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] listDomains:[AWSSimpleDBListDomainsRequest new] completionHandler:^(AWSSimpleDBListDomainsResult* _Nullable response, NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); XCTAssertNil(response); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testPutAttributes { NSString *key = @"testPutAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] putAttributes:[AWSSimpleDBPutAttributesRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testPutAttributesCompletionHandler { NSString *key = @"testPutAttributes"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] putAttributes:[AWSSimpleDBPutAttributesRequest new] completionHandler:^(NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testSelect { NSString *key = @"testSelect"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; [[[[AWSSimpleDB SimpleDBForKey:key] select:[AWSSimpleDBSelectRequest new]] continueWithBlock:^id(AWSTask *task) { XCTAssertNotNil(task.error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", task.error.domain); XCTAssertEqual(8848, task.error.code); XCTAssertNil(task.result); return nil; }] waitUntilFinished]; OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } - (void)testSelectCompletionHandler { NSString *key = @"testSelect"; AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:nil]; [AWSSimpleDB registerSimpleDBWithConfiguration:configuration forKey:key]; AWSSimpleDB *awsClient = [AWSSimpleDB SimpleDBForKey:key]; XCTAssertNotNil(awsClient); XCTAssertNotNil(mockNetworking); [awsClient setValue:mockNetworking forKey:@"networking"]; dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[AWSSimpleDB SimpleDBForKey:key] select:[AWSSimpleDBSelectRequest new] completionHandler:^(AWSSimpleDBSelectResult* _Nullable response, NSError * _Nullable error) { XCTAssertNotNil(error); XCTAssertEqualObjects(@"OCMockExpectedNetworkingError", error.domain); XCTAssertEqual(8848, error.code); XCTAssertNil(response); dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int)(2.0 * NSEC_PER_SEC))); OCMVerify([mockNetworking sendRequest:[OCMArg isNotNil]]); [AWSSimpleDB removeSimpleDBForKey:key]; } @end