Adds two tests that pass with the RouteGuide Java server

pull/1327/head
Jorge Canizales 10 years ago
parent 7502bd29c3
commit 5f0c0f1427
  1. 2
      src/objective-c/examples/Sample/Podfile
  2. 23094
      src/objective-c/examples/Sample/Pods/Pods.xcodeproj/project.pbxproj
  3. 71
      src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj
  4. 72
      src/objective-c/examples/Sample/SampleTests/SampleTests.m

@ -4,6 +4,8 @@ platform :ios, '8.0'
pod 'gRPC', :path => "../../../.."
pod 'RxLibrary', :path => "../../../.."
link_with 'Sample', 'SampleTests'
target 'Sample' do
end

File diff suppressed because it is too large Load Diff

@ -77,6 +77,13 @@ fi
<key>showEnvVarsInLog</key>
<string>0</string>
</dict>
<key>60BBBBB15823BBF7639D7AA9</key>
<dict>
<key>fileRef</key>
<string>2DC7B7C4C0410F43B9621631</string>
<key>isa</key>
<string>PBXBuildFile</string>
</dict>
<key>6369A2611A9322E20015FC5C</key>
<dict>
<key>children</key>
@ -481,7 +488,9 @@ fi
<key>buildActionMask</key>
<string>2147483647</string>
<key>files</key>
<array/>
<array>
<string>60BBBBB15823BBF7639D7AA9</string>
</array>
<key>isa</key>
<string>PBXFrameworksBuildPhase</string>
<key>runOnlyForDeploymentPostprocessing</key>
@ -504,9 +513,11 @@ fi
<string>6369A2901A9322E20015FC5C</string>
<key>buildPhases</key>
<array>
<string>75C393B2FDC60A22B2121058</string>
<string>6369A27F1A9322E20015FC5C</string>
<string>6369A2801A9322E20015FC5C</string>
<string>6369A2811A9322E20015FC5C</string>
<string>7B8CDC152F76D6014A96C798</string>
</array>
<key>buildRules</key>
<array/>
@ -831,6 +842,8 @@ fi
</dict>
<key>6369A2911A9322E20015FC5C</key>
<dict>
<key>baseConfigurationReference</key>
<string>AC29DD6FCDF962F519FEBB0D</string>
<key>buildSettings</key>
<dict>
<key>BUNDLE_LOADER</key>
@ -861,6 +874,8 @@ fi
</dict>
<key>6369A2921A9322E20015FC5C</key>
<dict>
<key>baseConfigurationReference</key>
<string>C68330F8D451CC6ACEABA09F</string>
<key>buildSettings</key>
<dict>
<key>BUNDLE_LOADER</key>
@ -884,6 +899,60 @@ fi
<key>name</key>
<string>Release</string>
</dict>
<key>75C393B2FDC60A22B2121058</key>
<dict>
<key>buildActionMask</key>
<string>2147483647</string>
<key>files</key>
<array/>
<key>inputPaths</key>
<array/>
<key>isa</key>
<string>PBXShellScriptBuildPhase</string>
<key>name</key>
<string>Check Pods Manifest.lock</string>
<key>outputPaths</key>
<array/>
<key>runOnlyForDeploymentPostprocessing</key>
<string>0</string>
<key>shellPath</key>
<string>/bin/sh</string>
<key>shellScript</key>
<string>diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" &gt; /dev/null
if [[ $? != 0 ]] ; then
cat &lt;&lt; EOM
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
EOM
exit 1
fi
</string>
<key>showEnvVarsInLog</key>
<string>0</string>
</dict>
<key>7B8CDC152F76D6014A96C798</key>
<dict>
<key>buildActionMask</key>
<string>2147483647</string>
<key>files</key>
<array/>
<key>inputPaths</key>
<array/>
<key>isa</key>
<string>PBXShellScriptBuildPhase</string>
<key>name</key>
<string>Copy Pods Resources</string>
<key>outputPaths</key>
<array/>
<key>runOnlyForDeploymentPostprocessing</key>
<string>0</string>
<key>shellPath</key>
<string>/bin/sh</string>
<key>shellScript</key>
<string>"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"
</string>
<key>showEnvVarsInLog</key>
<string>0</string>
</dict>
<key>AB3331C9AE6488E61B2B094E</key>
<dict>
<key>children</key>

@ -40,62 +40,62 @@
#import <RxLibrary/GRXWriteable.h>
@interface SampleTests : XCTestCase
@end
@implementation SampleTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
}
- (void)testConnectionToLocalServer {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
- (void)testConnectionToSandboxServer {
XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
// This method isn't implemented by the local server.
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.testing"
interface:@"TestService"
method:@"EmptyCall"];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"grpc-test.sandbox.google.com:443"
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"127.0.0.1:8980"
method:method
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
NSLog(@"Received unexpected response: %@", value);
XCTFail(@"Received unexpected response: %@", value);
} completionHandler:^(NSError *errorOrNil) {
if (errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
} else {
[expectation fulfill];
}
XCTAssertNotNil(errorOrNil, @"Finished without error!");
XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil);
[expectation fulfill];
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {
if(error) {
XCTFail(@"Server unreachable. Error: %@", error);
}
[self waitForExpectationsWithTimeout:10.0 handler:nil];
}
- (void)testEmptyRPC {
__weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide"
interface:@"RouteGuide"
method:@"RecordRoute"];
id<GRXWriter> requestsWriter = [GRXWriter emptyWriter];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"127.0.0.1:8980"
method:method
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
[response fulfill];
} completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:10.0 handler:nil];
}
@end

Loading…
Cancel
Save