obj.class->[obj class]

pull/16190/head
Muxi Yan 6 years ago
parent f00be37dd1
commit 6ae2ea643d
  1. 4
      src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
  2. 2
      src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
  3. 2
      src/objective-c/ProtoRPC/ProtoRPC.m
  4. 62
      src/objective-c/tests/InteropTests.m
  5. 4
      src/objective-c/tests/InteropTestsLocalSSL.m

@ -36,7 +36,7 @@ static void CheckIsNonNilASCII(NSString *name, NSString *value) {
// Precondition: key isn't nil.
static void CheckKeyValuePairIsValid(NSString *key, id value) {
if ([key hasSuffix:@"-bin"]) {
if (![value isKindOfClass:NSData.class]) {
if (![value isKindOfClass:[NSData class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSData value for header %@ ending in \"-bin\", "
@ -44,7 +44,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
key, value];
}
} else {
if (![value isKindOfClass:NSString.class]) {
if (![value isKindOfClass:[NSString class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSString value for header %@ not ending in \"-bin\", "

@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
dispatch_once(&loading, ^{
NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
// Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
NSError *error;
// Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the

@ -252,7 +252,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
}
// A writer that serializes the proto messages to send.
GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) {
if (![proto isKindOfClass:GPBMessage.class]) {
if (![proto isKindOfClass:[GPBMessage class]]) {
[NSException raise:NSInvalidArgumentException
format:@"Request must be a proto message: %@", proto];
}

@ -173,11 +173,11 @@ BOOL isRemoteInteropTest(NSString *host) {
[GRPCCall resetHostSettings];
_service = self.class.host ? [RMTTestService serviceWithHost:self.class.host] : nil;
_service = [[self class] host] ? [RMTTestService serviceWithHost:[[self class] host]] : nil;
}
- (void)testEmptyUnaryRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
GPBEmpty *request = [GPBEmpty message];
@ -196,14 +196,14 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testEmptyUnaryRPCWithV2API {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
GPBEmpty *request = [GPBEmpty message];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = self.class.transportType;
options.PEMRootCertificates = self.class.PEMRootCertificates;
options.hostNameOverride = self.class.hostNameOverride;
options.transportType = [[self class] transportType];
options.PEMRootCertificates = [[self class] PEMRootCertificates];
options.hostNameOverride = [[self class] hostNameOverride];
[_service
emptyCallWithMessage:request
@ -223,7 +223,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testLargeUnaryRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@ -247,7 +247,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testPacketCoalescing {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@ -286,7 +286,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)test4MBResponsesAreAccepted {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@ -304,7 +304,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testResponsesOverMaxSizeFailWithActionableMessage {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@ -330,7 +330,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testResponsesOver4MBAreAcceptedIfOptedIn {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"HigherResponseSizeLimit"];
@ -338,7 +338,7 @@ BOOL isRemoteInteropTest(NSString *host) {
const size_t kPayloadSize = 5 * 1024 * 1024; // 5MB
request.responseSize = kPayloadSize;
[GRPCCall setResponseSizeLimit:6 * 1024 * 1024 forHost:self.class.host];
[GRPCCall setResponseSizeLimit:6 * 1024 * 1024 forHost:[[self class] host]];
[_service unaryCallWithRequest:request
handler:^(RMTSimpleResponse *response, NSError *error) {
@ -351,7 +351,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testClientStreamingRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
RMTStreamingInputCallRequest *request1 = [RMTStreamingInputCallRequest message];
@ -386,7 +386,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testServerStreamingRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"];
NSArray *expectedSizes = @[ @31415, @9, @2653, @58979 ];
@ -425,7 +425,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testPingPongRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPong"];
NSArray *requests = @[ @27182, @8, @1828, @45904 ];
@ -472,7 +472,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testPingPongRPCWithV2API {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPong"];
NSArray *requests = @[ @27182, @8, @1828, @45904 ];
@ -483,9 +483,9 @@ BOOL isRemoteInteropTest(NSString *host) {
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
requestedResponseSize:responses[index]];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = self.class.transportType;
options.PEMRootCertificates = self.class.PEMRootCertificates;
options.hostNameOverride = self.class.hostNameOverride;
options.transportType = [[self class] transportType ];
options.PEMRootCertificates = [[self class] PEMRootCertificates];
options.hostNameOverride = [[self class] hostNameOverride];
__block GRPCStreamingProtoCall *call = [_service
fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
@ -523,7 +523,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testEmptyStreamRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"];
[_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter]
eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response,
@ -536,7 +536,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testCancelAfterBeginRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"];
// A buffered pipe to which we never write any value acts as a writer that just hangs.
@ -561,7 +561,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testCancelAfterBeginRPCWithV2API {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"];
// A buffered pipe to which we never write any value acts as a writer that just hangs.
@ -583,7 +583,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testCancelAfterFirstResponseRPC {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"CancelAfterFirstResponse"];
@ -619,7 +619,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testCancelAfterFirstResponseRPCWithV2API {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *completionExpectation =
[self expectationWithDescription:@"Call completed."];
__weak XCTestExpectation *responseExpectation =
@ -630,7 +630,7 @@ BOOL isRemoteInteropTest(NSString *host) {
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = self.class.transportType;
options.PEMRootCertificates = self.class.PEMRootCertificates;
options.hostNameOverride = self.class.hostNameOverride;
options.hostNameOverride = [[self class] hostNameOverride];
id request =
[RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
@ -656,7 +656,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testRPCAfterClosingOpenConnections {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"RPC after closing connection"];
@ -688,10 +688,10 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testCompressedUnaryRPC {
// This test needs to be disabled for remote test because interop server grpc-test
// does not support compression.
if (isRemoteInteropTest(self.class.host)) {
if (isRemoteInteropTest([[self class] host])) {
return;
}
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@ -699,7 +699,7 @@ BOOL isRemoteInteropTest(NSString *host) {
request.responseSize = 314159;
request.payload.body = [NSMutableData dataWithLength:271828];
request.expectCompressed.value = YES;
[GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:self.class.host];
[GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:[[self class] host]];
[_service unaryCallWithRequest:request
handler:^(RMTSimpleResponse *response, NSError *error) {
@ -718,10 +718,10 @@ BOOL isRemoteInteropTest(NSString *host) {
#ifndef GRPC_COMPILE_WITH_CRONET
- (void)testKeepalive {
XCTAssertNotNil(self.class.host);
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"];
[GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:self.class.host];
[GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]];
NSArray *requests = @[ @27182, @8 ];
NSArray *responses = @[ @31415, @9 ];

@ -41,7 +41,7 @@ static int32_t kLocalInteropServerOverhead = 10;
}
+ (NSString *)PEMRootCertificates {
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSError *error;
@ -64,7 +64,7 @@ static int32_t kLocalInteropServerOverhead = 10;
[super setUp];
// Register test server certificates and name.
NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost];

Loading…
Cancel
Save