Skip to content
Snippets Groups Projects
Commit ceb43623 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Use grpc-common’s route_guide in local tests

parent 3b309d69
No related branches found
No related tags found
No related merge requests found
...@@ -38,56 +38,62 @@ ...@@ -38,56 +38,62 @@
#import <gRPC/GRPCMethodName.h> #import <gRPC/GRPCMethodName.h>
#import <gRPC/GRXWriter+Immediate.h> #import <gRPC/GRXWriter+Immediate.h>
#import <gRPC/GRXWriteable.h> #import <gRPC/GRXWriteable.h>
#import <Route_guide/RouteGuide.pbobjc.h> #import <RouteGuide/RouteGuide.pbobjc.h>
#import <Route_guide/RouteGuide.pbrpc.h> #import <RouteGuide/RouteGuide.pbrpc.h>
// These tests require the gRPC-Java "RouteGuide" sample server to be running locally. To do so, // These tests require a gRPC "RouteGuide" sample server to be running locally. You can compile and
// install Gradle by following the instructions here: https://docs.gradle.org/current/userguide/installation.html // run one by following the instructions here: https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md#try-it-out
// And use it to run the server by following the instructions here: https://github.com/grpc/grpc-java/tree/master/examples // Be sure to have the C gRPC library installed in your system (for example, by having followed the
// instructions at https://github.com/grpc/homebrew-grpc
static NSString * const kRouteGuideHost = @"http://localhost:50051";
static NSString * const kPackage = @"examples";
static NSString * const kService = @"RouteGuide";
@interface LocalClearTextTests : XCTestCase @interface LocalClearTextTests : XCTestCase
@end @end
@implementation LocalClearTextTests @implementation LocalClearTextTests
- (void)testConnectionToLocalServer { // This test currently fails: see Issue #1907.
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."]; //- (void)testConnectionToLocalServer {
// __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
// This method isn't implemented by the local server. //
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.testing" // // This method isn't implemented by the local server.
interface:@"TestService" // GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
method:@"EmptyCall"]; // interface:kService
// method:@"EmptyCall"];
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]]; //
// id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" //
method:method // GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
requestsWriter:requestsWriter]; // method:method
// requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { //
XCTFail(@"Received unexpected response: %@", value); // id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
} completionHandler:^(NSError *errorOrNil) { // XCTFail(@"Received unexpected response: %@", value);
XCTAssertNotNil(errorOrNil, @"Finished without error!"); // } completionHandler:^(NSError *errorOrNil) {
XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil); // XCTAssertNotNil(errorOrNil, @"Finished without error!");
[expectation fulfill]; // XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil);
}]; // [expectation fulfill];
// }];
[call startWithWriteable:responsesWriteable]; //
// [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2.0 handler:nil]; //
} // [self waitForExpectationsWithTimeout:8.0 handler:nil];
//}
- (void)testEmptyRPC { - (void)testEmptyRPC {
__weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."]; __weak XCTestExpectation *response = [self expectationWithDescription:@"Empty response received."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide" GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
interface:@"RouteGuide" interface:kService
method:@"RecordRoute"]; method:@"RecordRoute"];
id<GRXWriter> requestsWriter = [GRXWriter emptyWriter]; id<GRXWriter> requestsWriter = [GRXWriter emptyWriter];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
method:method method:method
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
...@@ -109,8 +115,8 @@ ...@@ -109,8 +115,8 @@
__weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."]; __weak XCTestExpectation *response = [self expectationWithDescription:@"Response received."];
__weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."]; __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:@"grpc.example.routeguide" GRPCMethodName *method = [[GRPCMethodName alloc] initWithPackage:kPackage
interface:@"RouteGuide" interface:kService
method:@"GetFeature"]; method:@"GetFeature"];
RGDPoint *point = [RGDPoint message]; RGDPoint *point = [RGDPoint message];
...@@ -118,7 +124,7 @@ ...@@ -118,7 +124,7 @@
point.longitude = -15E7; point.longitude = -15E7;
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]]; id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[point data]];
GRPCCall *call = [[GRPCCall alloc] initWithHost:@"http://127.0.0.1:8980" GRPCCall *call = [[GRPCCall alloc] initWithHost:kRouteGuideHost
method:method method:method
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
...@@ -145,7 +151,7 @@ ...@@ -145,7 +151,7 @@
point.latitude = 28E7; point.latitude = 28E7;
point.longitude = -15E7; point.longitude = -15E7;
RGDRouteGuide *service = [[RGDRouteGuide alloc] initWithHost:@"http://127.0.0.1:8980"]; RGDRouteGuide *service = [[RGDRouteGuide alloc] initWithHost:kRouteGuideHost];
[service getFeatureWithRequest:point handler:^(RGDFeature *response, NSError *error) { [service getFeatureWithRequest:point handler:^(RGDFeature *response, NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error); XCTAssertNil(error, @"Finished with unexpected error: %@", error);
XCTAssertEqualObjects(point, response.location); XCTAssertEqualObjects(point, response.location);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment