91 lines
2.5 KiB
Objective-C
91 lines
2.5 KiB
Objective-C
//
|
||
// ScheduleCenterV6Test.m
|
||
// TrustHttpDNSTests
|
||
//
|
||
// Created by xuyecan on 2024/6/17.
|
||
// Copyright 穢 2024 trustapp.com. All rights reserved.
|
||
//
|
||
#import <Foundation/Foundation.h>
|
||
#import <OCMock/OCMock.h>
|
||
#import "TestBase.h"
|
||
#import "HttpdnsHostObject.h"
|
||
#import "HttpdnsScheduleExecutor.h"
|
||
#import "HttpdnsScheduleCenter.h"
|
||
#import "HttpdnsService.h"
|
||
#import "HttpdnsService_Internal.h"
|
||
#import "HttpdnsUtil.h"
|
||
|
||
|
||
/**
|
||
* <20>曹<EFBFBD>雿輻鍂OCMock<63>刻<EFBFBD>蝏剔<E89D8F>瘚贝<E7989A><E8B49D>其<EFBFBD>銝剝<E98A9D>憭𦱆ock撖寡情(<28>喃蝙瘥𤩺活<F0A4A9BA>賢歇蝏𥲑topMocking)隡𡁏<E99AA1><F0A1818F><EFBFBD><EFBFBD><EFBFBD>嗘僚<E59798><E5839A>䔮憸矋<E686B8>
|
||
* <20>桀<EFBFBD>餈䁅圾<E48185>喃<EFBFBD>鈭<EFBFBD><E988AD><EFBFBD><EFBFBD>隞亥<E99A9E>銝芰掩銝剔<E98A9D>瘚贝<E7989A>case嚗屸<E59A97>閬<EFBFBD><E996AC><EFBFBD>典<EFBFBD><E585B8>祆<EFBFBD>銵?
|
||
*/
|
||
@interface ScheduleCenterV6Test : TestBase
|
||
|
||
@end
|
||
|
||
|
||
@implementation ScheduleCenterV6Test
|
||
|
||
+ (void)setUp {
|
||
[super setUp];
|
||
}
|
||
|
||
+ (void)tearDown {
|
||
[super tearDown];
|
||
}
|
||
|
||
- (void)setUp {
|
||
[super setUp];
|
||
|
||
static dispatch_once_t onceToken;
|
||
dispatch_once(&onceToken, ^{
|
||
self.httpdns = [[HttpDnsService alloc] initWithAccountID:100000];
|
||
});
|
||
|
||
[self.httpdns setLogEnabled:YES];
|
||
[self.httpdns setReuseExpiredIPEnabled:NO];
|
||
|
||
[self.httpdns setLogHandler:self];
|
||
|
||
self.currentTimeStamp = [[NSDate date] timeIntervalSince1970];
|
||
}
|
||
|
||
- (void)tearDown {
|
||
[super tearDown];
|
||
}
|
||
|
||
- (void)testUpdateFailureWillMoveToNextUpdateServer {
|
||
[self presetNetworkEnvAsIpv6];
|
||
|
||
HttpdnsScheduleExecutor *realRequest = [HttpdnsScheduleExecutor new];
|
||
id mockRequest = OCMPartialMock(realRequest);
|
||
OCMStub([mockRequest fetchRegionConfigFromServer:[OCMArg any] error:(NSError * __autoreleasing *)[OCMArg anyPointer]])
|
||
.andReturn(nil);
|
||
|
||
id mockRequestClass = OCMClassMock([HttpdnsScheduleExecutor class]);
|
||
OCMStub([mockRequestClass new]).andReturn(mockRequest);
|
||
|
||
HttpdnsScheduleCenter *scheduleCenter = [[HttpdnsScheduleCenter alloc] initWithAccountId:100000];
|
||
|
||
NSArray<NSString *> *updateServerHostList = [scheduleCenter currentUpdateServerV4HostList];
|
||
|
||
int updateServerCount = (int)[updateServerHostList count];
|
||
XCTAssertGreaterThan(updateServerCount, 0);
|
||
|
||
// <20><><EFBFBD>撌脩<E6928C><E884A9>滩<EFBFBD>2甈∴<E79488><E288B4>踹<EFBFBD><E8B8B9>滩<EFBFBD>敶勗<E695B6>霈∠<E99C88>
|
||
[scheduleCenter asyncUpdateRegionScheduleConfigAtRetry:2];
|
||
[NSThread sleepForTimeInterval:0.1];
|
||
|
||
NSString *activeUpdateHost = [scheduleCenter getActiveUpdateServerHost];
|
||
|
||
// <20>牐蛹<E78990>航<EFBFBD><E888AA>臬<EFBFBD><E887AC>㵪<EFBFBD><E3B5AA><EFBFBD>隞亙蘨<E4BA99>斗鱏銝<E9B18F>摰帋<E691B0><E5B88B>疳pv4
|
||
XCTAssertFalse([HttpdnsUtil isIPv4Address:activeUpdateHost]);
|
||
|
||
OCMVerify([mockRequest fetchRegionConfigFromServer:[OCMArg any] error:(NSError * __autoreleasing *)[OCMArg anyPointer]]);
|
||
|
||
[NSThread sleepForTimeInterval:3];
|
||
}
|
||
|
||
@end
|