Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
ceb43623
Commit
ceb43623
authored
9 years ago
by
Jorge Canizales
Browse files
Options
Downloads
Patches
Plain Diff
Use grpc-common’s route_guide in local tests
parent
3b309d69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/tests/LocalClearTextTests.m
+44
-38
44 additions, 38 deletions
src/objective-c/tests/LocalClearTextTests.m
with
44 additions
and
38 deletions
src/objective-c/tests/LocalClearTextTests.m
+
44
−
38
View file @
ceb43623
...
@@ -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
_g
uide/RouteGuide.pbobjc.h>
#import <Route
G
uide/RouteGuide.pbobjc.h>
#import <Route
_g
uide/RouteGuide.pbrpc.h>
#import <Route
G
uide/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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment