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
d666fd06
Commit
d666fd06
authored
9 years ago
by
Jorge Canizales
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup GRPCClientTests.m
parent
22b50c93
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/tests/GRPCClientTests.m
+35
-34
35 additions, 34 deletions
src/objective-c/tests/GRPCClientTests.m
with
35 additions
and
34 deletions
src/objective-c/tests/GRPCClientTests.m
+
35
−
34
View file @
d666fd06
...
@@ -43,24 +43,38 @@
...
@@ -43,24 +43,38 @@
// These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall)
// These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall)
// rather than a generated proto library on top of it.
// rather than a generated proto library on top of it.
static
NSString
*
const
kHostAddress
=
@"grpc-test.sandbox.google.com"
;
static
NSString
*
const
kPackage
=
@"grpc.testing"
;
static
NSString
*
const
kService
=
@"TestService"
;
static
GRPCMethodName
*
kInexistentMethod
;
static
GRPCMethodName
*
kEmptyCallMethod
;
static
GRPCMethodName
*
kUnaryCallMethod
;
@interface
GRPCClientTests
:
XCTestCase
@interface
GRPCClientTests
:
XCTestCase
@end
@end
@implementation
GRPCClientTests
@implementation
GRPCClientTests
-
(
void
)
setUp
{
// This method isn't implemented by the remote server.
kInexistentMethod
=
[[
GRPCMethodName
alloc
]
initWithPackage
:
kPackage
interface:
kService
method:
@"Inexistent"
];
kEmptyCallMethod
=
[[
GRPCMethodName
alloc
]
initWithPackage
:
kPackage
interface:
kService
method:
@"EmptyCall"
];
kUnaryCallMethod
=
[[
GRPCMethodName
alloc
]
initWithPackage
:
kPackage
interface:
kService
method:
@"UnaryCall"
];
}
-
(
void
)
testConnectionToRemoteServer
{
-
(
void
)
testConnectionToRemoteServer
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Server reachable."
];
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Server reachable."
];
// This method isn't implemented by the remote server.
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
kHostAddress
GRPCMethodName
*
method
=
[[
GRPCMethodName
alloc
]
initWithPackage
:
@"grpc.testing"
method:
kInexistentMethod
interface:
@"TestService"
requestsWriter:
[
GRXWriter
writerWithValue
:[
NSData
data
]]];
method:
@"Nonexistent"
];
id
<
GRXWriter
>
requestsWriter
=
[
GRXWriter
writerWithValue
:[
NSData
data
]];
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
@"grpc-test.sandbox.google.com"
method:
method
requestsWriter:
requestsWriter
];
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
XCTFail
(
@"Received unexpected response: %@"
,
value
);
XCTFail
(
@"Received unexpected response: %@"
,
value
);
...
@@ -80,15 +94,9 @@
...
@@ -80,15 +94,9 @@
__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.testing"
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
kHostAddress
interface:
@"TestService"
method:
kEmptyCallMethod
method:
@"EmptyCall"
];
requestsWriter:
[
GRXWriter
writerWithValue
:[
NSData
data
]]];
id
<
GRXWriter
>
requestsWriter
=
[
GRXWriter
writerWithValue
:[
NSData
data
]];
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
@"grpc-test.sandbox.google.com"
method:
method
requestsWriter:
requestsWriter
];
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
XCTAssertNotNil
(
value
,
@"nil value received as response."
);
XCTAssertNotNil
(
value
,
@"nil value received as response."
);
...
@@ -105,34 +113,27 @@
...
@@ -105,34 +113,27 @@
}
}
-
(
void
)
testSimpleProtoRPC
{
-
(
void
)
testSimpleProtoRPC
{
__weak
XCTestExpectation
*
response
=
[
self
expectationWithDescription
:
@"Response received."
];
__weak
XCTestExpectation
*
response
=
[
self
expectationWithDescription
:
@"Expected response."
];
__weak
XCTestExpectation
*
expectedResponse
=
[
self
expectationWithDescription
:
@"Expected response."
];
__weak
XCTestExpectation
*
completion
=
[
self
expectationWithDescription
:
@"RPC completed."
];
__weak
XCTestExpectation
*
completion
=
[
self
expectationWithDescription
:
@"RPC completed."
];
GRPCMethodName
*
method
=
[[
GRPCMethodName
alloc
]
initWithPackage
:
@"grpc.testing"
RMTSimpleRequest
*
request
=
[
RMTSimpleRequest
message
];
interface:
@"TestService"
method:
@"UnaryCall"
];
RMTSimpleRequest
*
request
=
[[
RMTSimpleRequest
alloc
]
init
];
request
.
responseSize
=
100
;
request
.
responseSize
=
100
;
request
.
fillUsername
=
YES
;
request
.
fillUsername
=
YES
;
request
.
fillOauthScope
=
YES
;
request
.
fillOauthScope
=
YES
;
id
<
GRXWriter
>
requestsWriter
=
[
GRXWriter
writerWithValue
:[
request
data
]];
id
<
GRXWriter
>
requestsWriter
=
[
GRXWriter
writerWithValue
:[
request
data
]];
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
@"grpc-test.sandbox.google.com"
GRPCCall
*
call
=
[[
GRPCCall
alloc
]
initWithHost
:
kHostAddress
method:
m
ethod
method:
kUnaryCallM
ethod
requestsWriter:
requestsWriter
];
requestsWriter:
requestsWriter
];
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
id
<
GRXWriteable
>
responsesWriteable
=
[[
GRXWriteable
alloc
]
initWithValueHandler
:
^
(
NSData
*
value
)
{
XCTAssertNotNil
(
value
,
@"nil value received as response."
);
XCTAssertNotNil
(
value
,
@"nil value received as response."
);
[
response
fulfill
];
XCTAssertGreaterThan
(
value
.
length
,
0
,
@"Empty response received."
);
XCTAssertGreaterThan
(
value
.
length
,
0
,
@"Empty response received."
);
RMTSimpleResponse
*
response
=
[
RMTSimpleResponse
parseFromData
:
value
error
:
NULL
];
RMTSimpleResponse
*
response
Proto
=
[
RMTSimpleResponse
parseFromData
:
value
error
:
NULL
];
// We expect empty strings, not nil:
// We expect empty strings, not nil:
XCTAssertNotNil
(
response
.
username
,
@"Response's username is nil."
);
XCTAssertNotNil
(
response
Proto
.
username
,
@"Response's username is nil."
);
XCTAssertNotNil
(
response
.
oauthScope
,
@"Response's OAuth scope is nil."
);
XCTAssertNotNil
(
response
Proto
.
oauthScope
,
@"Response's OAuth scope is nil."
);
[
expectedR
esponse
fulfill
];
[
r
esponse
fulfill
];
}
completionHandler
:
^
(
NSError
*
errorOrNil
)
{
}
completionHandler
:
^
(
NSError
*
errorOrNil
)
{
XCTAssertNil
(
errorOrNil
,
@"Finished with unexpected error: %@"
,
errorOrNil
);
XCTAssertNil
(
errorOrNil
,
@"Finished with unexpected error: %@"
,
errorOrNil
);
[
completion
fulfill
];
[
completion
fulfill
];
...
...
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