diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index d70c43349..127b297ba 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -281,9 +281,6 @@ 56190954238C3D3200A862A6 /* CryptoTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 56190953238C3D3200A862A6 /* CryptoTest.m */; }; 56190955238C3D3200A862A6 /* CryptoTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 56190953238C3D3200A862A6 /* CryptoTest.m */; }; 56190956238C3D3200A862A6 /* CryptoTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 56190953238C3D3200A862A6 /* CryptoTest.m */; }; - 8099DE8F2BF18E360071AB2A /* PlaceholderSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8099DE8E2BF18E360071AB2A /* PlaceholderSwift.swift */; }; - 8099DE902BF18E360071AB2A /* PlaceholderSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8099DE8E2BF18E360071AB2A /* PlaceholderSwift.swift */; }; - 8099DE912BF18E360071AB2A /* PlaceholderSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8099DE8E2BF18E360071AB2A /* PlaceholderSwift.swift */; }; 80E519C72BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C82BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; 80E519C92BBCBE21006545B4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */; }; @@ -1231,7 +1228,6 @@ 21FD9F262A015BE400216482 /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Test.swift; sourceTree = ""; }; 560579D824AF1BA900A4D03D /* ARTDefaultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARTDefaultTests.swift; sourceTree = ""; }; 56190953238C3D3200A862A6 /* CryptoTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CryptoTest.m; sourceTree = ""; }; - 8099DE8E2BF18E360071AB2A /* PlaceholderSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceholderSwift.swift; sourceTree = ""; }; 80E519C62BBCBE20006545B4 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 841134772722205400CFA837 /* ARTArchiveTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTArchiveTests.m; sourceTree = ""; }; 8412FDE12661AC37001FE9E6 /* AblyDeltaCodec.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AblyDeltaCodec.xcframework; path = Carthage/Build/AblyDeltaCodec.xcframework; sourceTree = ""; }; @@ -1750,14 +1746,6 @@ path = "Test Utilities"; sourceTree = ""; }; - 8099DE8D2BF18E130071AB2A /* PushSwift */ = { - isa = PBXGroup; - children = ( - 8099DE8E2BF18E360071AB2A /* PlaceholderSwift.swift */, - ); - path = PushSwift; - sourceTree = ""; - }; 856AAC8B1B6E304B00B07119 /* Test */ = { isa = PBXGroup; children = ( @@ -1783,7 +1771,6 @@ D5A22170266F3CB700C87C42 /* Package.swift */, D75B85F921BAF8F900FD8DD2 /* Ably.xcconfig */, D7EE14F51F07964500C178D5 /* Version.xcconfig */, - 8099DE8D2BF18E130071AB2A /* PushSwift */, 96BF61331A35B2AB004CF2B3 /* Source */, 217D17EE25421FC100DFF07E /* SocketRocket */, 856AAC8B1B6E304B00B07119 /* Test */, @@ -3170,7 +3157,6 @@ 961343D91A42E0B7006DC822 /* ARTClientOptions.m in Sources */, 96BF615F1A35C1C8004CF2B3 /* ARTTypes.m in Sources */, 217D1838254222F600DFF07E /* NSRunLoop+ARTSRWebSocket.m in Sources */, - 8099DE8F2BF18E360071AB2A /* PlaceholderSwift.swift in Sources */, D7D8F82E1BC2C706009718F2 /* ARTTokenParams.m in Sources */, D746AE411BBC5B14003ECEF8 /* ARTEventEmitter.m in Sources */, 2104EFA82A4CC30C00CC1184 /* ARTAttachRetryState.m in Sources */, @@ -3411,7 +3397,6 @@ D710D55E21949C97008F54AD /* ARTPushActivationStateMachine.m in Sources */, D710D49C21949ACA008F54AD /* ARTNSMutableRequest+ARTRest.m in Sources */, 217D184F254222F700DFF07E /* NSRunLoop+ARTSRWebSocket.m in Sources */, - 8099DE902BF18E360071AB2A /* PlaceholderSwift.swift in Sources */, D710D66C21949E78008F54AD /* ARTMsgPackEncoder.m in Sources */, D710D48621949A5B008F54AD /* ARTDefault.m in Sources */, 2104EFA92A4CC30C00CC1184 /* ARTAttachRetryState.m in Sources */, @@ -3536,7 +3521,6 @@ D710D56421949C98008F54AD /* ARTPushActivationStateMachine.m in Sources */, D710D4A621949ACB008F54AD /* ARTNSMutableRequest+ARTRest.m in Sources */, 217D1866254222FA00DFF07E /* NSRunLoop+ARTSRWebSocket.m in Sources */, - 8099DE912BF18E360071AB2A /* PlaceholderSwift.swift in Sources */, D710D65221949E77008F54AD /* ARTMsgPackEncoder.m in Sources */, D710D48821949A5C008F54AD /* ARTDefault.m in Sources */, 2104EFAA2A4CC30C00CC1184 /* ARTAttachRetryState.m in Sources */, @@ -3667,7 +3651,6 @@ 856AAC931B6E304B00B07119 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ENABLE_MODULES = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3696,7 +3679,6 @@ 856AAC941B6E304B00B07119 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ENABLE_MODULES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -3935,7 +3917,6 @@ D7093C13219E2DB200723F17 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -3972,7 +3953,6 @@ D7093C14219E2DB200723F17 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -4007,7 +3987,6 @@ D7093C69219EE1AE00723F17 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -4043,7 +4022,6 @@ D7093C6A219EE1AE00723F17 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -4297,7 +4275,6 @@ EB3630A923804F7C00B83598 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -4333,7 +4310,6 @@ EB3630AA23804F7C00B83598 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; diff --git a/PushSwift/PlaceholderSwift.swift b/PushSwift/PlaceholderSwift.swift deleted file mode 100644 index d29080065..000000000 --- a/PushSwift/PlaceholderSwift.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Foundation -import UIKit - -@objc public protocol PlaceholderSwiftProtocol: NSObjectProtocol { - @objc func test() -} - - -@objc public class PlaceholderSwiftClass: NSObject { - -} - -@objc internal class PlaceholderInternalSwiftClass: NSObject { - -} diff --git a/Source/ARTPushAdmin.m b/Source/ARTPushAdmin.m index af4535657..a45c7c116 100644 --- a/Source/ARTPushAdmin.m +++ b/Source/ARTPushAdmin.m @@ -6,12 +6,6 @@ #import "ARTInternalLog.h" #import "ARTJsonEncoder.h" #import "ARTJsonLikeEncoder.h" -#import - -@class PlaceholderSwiftClass; -@interface randomSwift : NSObject - -@end @implementation ARTPushAdmin { ARTQueuedDealloc *_dealloc; diff --git a/Source/PrivateHeaders/Ably/ARTConstants.h b/Source/PrivateHeaders/Ably/ARTConstants.h index 9b45f4829..a8b5389d9 100644 --- a/Source/PrivateHeaders/Ably/ARTConstants.h +++ b/Source/PrivateHeaders/Ably/ARTConstants.h @@ -1,4 +1,4 @@ #import -extern NSString *const ARTHttpHeaderFieldErrorCodeKey; -extern NSString *const ARTHttpHeaderFieldErrorMessageKey; +extern NSString *const ARTHttpHeaderFieldErrorCodeKey NS_SWIFT_NAME(HttpHeaderFieldErrorCodeKey); +extern NSString *const ARTHttpHeaderFieldErrorMessageKey NS_SWIFT_NAME(HttpHeaderFieldErrorMessageKey); diff --git a/Source/PrivateHeaders/Ably/ARTDataEncoder.h b/Source/PrivateHeaders/Ably/ARTDataEncoder.h index 915cf4588..9e9efd0d6 100644 --- a/Source/PrivateHeaders/Ably/ARTDataEncoder.h +++ b/Source/PrivateHeaders/Ably/ARTDataEncoder.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(DataEncoderOutput) @interface ARTDataEncoderOutput : NSObject @property (readonly, nonatomic, nullable) id data; @@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_NAME(DataEncoder) @interface ARTDataEncoder : NSObject - (instancetype)initWithCipherParams:(ARTCipherParams *_Nullable)params logger:(ARTInternalLog *)logger error:(NSError *_Nullable*_Nullable)error; diff --git a/Source/PrivateHeaders/Ably/ARTLocalDeviceStorage.h b/Source/PrivateHeaders/Ably/ARTLocalDeviceStorage.h index d85dbb00b..dc2bf5d7a 100644 --- a/Source/PrivateHeaders/Ably/ARTLocalDeviceStorage.h +++ b/Source/PrivateHeaders/Ably/ARTLocalDeviceStorage.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(LocalDeviceStorage) @interface ARTLocalDeviceStorage : NSObject - (instancetype)initWithLogger:(ARTInternalLog *)logger; diff --git a/Source/PrivateHeaders/Ably/ARTNSMutableRequest+ARTRest.h b/Source/PrivateHeaders/Ably/ARTNSMutableRequest+ARTRest.h index df3d55ae9..132e809d6 100644 --- a/Source/PrivateHeaders/Ably/ARTNSMutableRequest+ARTRest.h +++ b/Source/PrivateHeaders/Ably/ARTNSMutableRequest+ARTRest.h @@ -1,5 +1,6 @@ #import +NS_SWIFT_NAME(Encoder) @protocol ARTEncoder; NS_ASSUME_NONNULL_BEGIN diff --git a/Source/PrivateHeaders/Ably/ARTPush+Private.h b/Source/PrivateHeaders/Ably/ARTPush+Private.h index 10ef409aa..d850f4fa4 100644 --- a/Source/PrivateHeaders/Ably/ARTPush+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPush+Private.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(PushInternal) @interface ARTPushInternal : NSObject @property (nonatomic, readonly) ARTPushAdminInternal *admin; diff --git a/Source/PrivateHeaders/Ably/ARTPushActivationEvent.h b/Source/PrivateHeaders/Ably/ARTPushActivationEvent.h index 9042c92e7..51a5cfe45 100644 --- a/Source/PrivateHeaders/Ably/ARTPushActivationEvent.h +++ b/Source/PrivateHeaders/Ably/ARTPushActivationEvent.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(PushActivationEvent) @interface ARTPushActivationEvent : NSObject - (NSData *)archiveWithLogger:(nullable ARTInternalLog *)logger; @@ -15,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// Event with Error info +NS_SWIFT_NAME(PushActivationErrorEvent) @interface ARTPushActivationErrorEvent : ARTPushActivationEvent @property (nonatomic, readonly) ARTErrorInfo *error; @@ -25,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// Event with Device Identity Token details +NS_SWIFT_NAME(PushActivationDeviceIdentityEvent) @interface ARTPushActivationDeviceIdentityEvent : ARTPushActivationEvent @property (nonatomic, readonly, nullable) ARTDeviceIdentityTokenDetails *identityTokenDetails; @@ -39,33 +42,43 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Events +NS_SWIFT_NAME(PushActivationEventCalledActivate) @interface ARTPushActivationEventCalledActivate : ARTPushActivationEvent @end +NS_SWIFT_NAME(PushActivationEventCalledDeactivate) @interface ARTPushActivationEventCalledDeactivate : ARTPushActivationEvent @end +NS_SWIFT_NAME(PushActivationEventGotPushDeviceDetails) @interface ARTPushActivationEventGotPushDeviceDetails : ARTPushActivationEvent @end +NS_SWIFT_NAME(PushActivationEventGettingPushDeviceDetailsFailed) @interface ARTPushActivationEventGettingPushDeviceDetailsFailed : ARTPushActivationErrorEvent @end +NS_SWIFT_NAME(PushActivationEventGotDeviceRegistration) @interface ARTPushActivationEventGotDeviceRegistration : ARTPushActivationDeviceIdentityEvent @end +NS_SWIFT_NAME(PushActivationEventGettingDeviceRegistrationFailed) @interface ARTPushActivationEventGettingDeviceRegistrationFailed : ARTPushActivationErrorEvent @end +NS_SWIFT_NAME(PushActivationEventRegistrationSynced) @interface ARTPushActivationEventRegistrationSynced : ARTPushActivationDeviceIdentityEvent @end +NS_SWIFT_NAME(PushActivationEventSyncRegistrationFailed) @interface ARTPushActivationEventSyncRegistrationFailed : ARTPushActivationErrorEvent @end +NS_SWIFT_NAME(PushActivationEventDeregistered) @interface ARTPushActivationEventDeregistered : ARTPushActivationEvent @end +NS_SWIFT_NAME(PushActivationEventDeregistrationFailed) @interface ARTPushActivationEventDeregistrationFailed : ARTPushActivationErrorEvent @end diff --git a/Source/PrivateHeaders/Ably/ARTPushActivationState.h b/Source/PrivateHeaders/Ably/ARTPushActivationState.h index 463d731e1..33b050100 100644 --- a/Source/PrivateHeaders/Ably/ARTPushActivationState.h +++ b/Source/PrivateHeaders/Ably/ARTPushActivationState.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(PushActivationState) @interface ARTPushActivationState : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -25,23 +26,29 @@ NS_ASSUME_NONNULL_BEGIN @end /// Persistent State +NS_SWIFT_NAME(PushActivationPersistantState) @interface ARTPushActivationPersistentState : ARTPushActivationState @end #pragma mark - States +NS_SWIFT_NAME(PushActivationStateNotActivated) @interface ARTPushActivationStateNotActivated : ARTPushActivationPersistentState @end +NS_SWIFT_NAME(PushActivationStateWaitingForDeviceRegistration) @interface ARTPushActivationStateWaitingForDeviceRegistration : ARTPushActivationState @end +NS_SWIFT_NAME(PushActivationStateWaitingForPushDeviceDetails) @interface ARTPushActivationStateWaitingForPushDeviceDetails : ARTPushActivationPersistentState @end +NS_SWIFT_NAME(PushActivationStateWaitingForNewPushDeviceDetails) @interface ARTPushActivationStateWaitingForNewPushDeviceDetails : ARTPushActivationPersistentState @end +NS_SWIFT_NAME(PushActivationStateWaitingForRegistrationSync) @interface ARTPushActivationStateWaitingForRegistrationSync : ARTPushActivationState - (instancetype)initWithMachine:(ARTPushActivationStateMachine *)machine logger:(ARTInternalLog *)logger NS_UNAVAILABLE; @@ -54,14 +61,17 @@ NS_ASSUME_NONNULL_BEGIN @end +NS_SWIFT_NAME(PushActivationStateAfterRegistrationSyncFailed) @interface ARTPushActivationStateAfterRegistrationSyncFailed : ARTPushActivationPersistentState @end +NS_SWIFT_NAME(PushActivationStateWaitingForDeregistration) @interface ARTPushActivationStateWaitingForDeregistration : ARTPushActivationState @end // Deprecated states; kept around for persistence backwards-compatibility +NS_SWIFT_NAME(PushActivationDeprecatedPersistentState) @interface ARTPushActivationDeprecatedPersistentState : ARTPushActivationPersistentState - (instancetype)initWithMachine:(ARTPushActivationStateMachine *)machine NS_UNAVAILABLE; @@ -70,6 +80,7 @@ NS_ASSUME_NONNULL_BEGIN @end +NS_SWIFT_NAME(PushActivationStateAfterRegistrationUpdateFailed) @interface ARTPushActivationStateAfterRegistrationUpdateFailed : ARTPushActivationDeprecatedPersistentState @end diff --git a/Source/PrivateHeaders/Ably/ARTPushActivationStateMachine.h b/Source/PrivateHeaders/Ably/ARTPushActivationStateMachine.h index 2e4d617fd..c61806f79 100644 --- a/Source/PrivateHeaders/Ably/ARTPushActivationStateMachine.h +++ b/Source/PrivateHeaders/Ably/ARTPushActivationStateMachine.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(PushActivationStateMachine) @interface ARTPushActivationStateMachine : NSObject @property (readonly, nonatomic) ARTPushActivationEvent *lastEvent; diff --git a/Source/PrivateHeaders/Ably/ARTPushAdmin+Private.h b/Source/PrivateHeaders/Ably/ARTPushAdmin+Private.h index 4ee52db63..6f93dd233 100644 --- a/Source/PrivateHeaders/Ably/ARTPushAdmin+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPushAdmin+Private.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(PushAdminInternal) @interface ARTPushAdminInternal : NSObject @property (nonatomic, readonly) ARTPushDeviceRegistrationsInternal *deviceRegistrations; diff --git a/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h b/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h index 48df667c2..8e6de63be 100644 --- a/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPushChannel+Private.h @@ -4,6 +4,7 @@ @class ARTRestInternal; @class ARTInternalLog; +NS_SWIFT_NAME(PushChannelInternal) @interface ARTPushChannelInternal : NSObject - (instancetype)init:(ARTRestInternal *)rest withChannel:(ARTChannel *)channel logger:(ARTInternalLog *)logger; diff --git a/Source/PrivateHeaders/Ably/ARTPushChannelSubscriptions+Private.h b/Source/PrivateHeaders/Ably/ARTPushChannelSubscriptions+Private.h index 87294beff..9c050275a 100644 --- a/Source/PrivateHeaders/Ably/ARTPushChannelSubscriptions+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPushChannelSubscriptions+Private.h @@ -4,6 +4,7 @@ @class ARTRestInternal; @class ARTInternalLog; +NS_SWIFT_NAME(PushChannelSubscriptionsInternal) @interface ARTPushChannelSubscriptionsInternal : NSObject - (instancetype)initWithRest:(ARTRestInternal *)rest logger:(ARTInternalLog *)logger; diff --git a/Source/PrivateHeaders/Ably/ARTPushDeviceRegistrations+Private.h b/Source/PrivateHeaders/Ably/ARTPushDeviceRegistrations+Private.h index a50d270e3..bc710023b 100644 --- a/Source/PrivateHeaders/Ably/ARTPushDeviceRegistrations+Private.h +++ b/Source/PrivateHeaders/Ably/ARTPushDeviceRegistrations+Private.h @@ -4,6 +4,7 @@ @class ARTRestInternal; @class ARTInternalLog; +NS_SWIFT_NAME(PushDeviceRegistrationsInternal) @interface ARTPushDeviceRegistrationsInternal : NSObject - (instancetype)initWithRest:(ARTRestInternal *)rest logger:(ARTInternalLog *)logger; diff --git a/Source/include/Ably/ARTAuth.h b/Source/include/Ably/ARTAuth.h index 3f1b8f35e..b7fa9e1a9 100644 --- a/Source/include/Ably/ARTAuth.h +++ b/Source/include/Ably/ARTAuth.h @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTAuth` is implemented. */ +NS_SWIFT_NAME(AuthProtocol) @protocol ARTAuthProtocol /** @@ -88,6 +89,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTAuthProtocol` for details. */ +NS_SWIFT_NAME(Auth) @interface ARTAuth : NSObject @end diff --git a/Source/include/Ably/ARTBaseMessage.h b/Source/include/Ably/ARTBaseMessage.h index fc48355d3..20a6323db 100644 --- a/Source/include/Ably/ARTBaseMessage.h +++ b/Source/include/Ably/ARTBaseMessage.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN /** A base interface for an `ARTMessage` and an `ARTPresenceMessage` objects. */ +NS_SWIFT_NAME(BaseMessage) @interface ARTBaseMessage : NSObject /** diff --git a/Source/include/Ably/ARTChannelOptions.h b/Source/include/Ably/ARTChannelOptions.h index f7028d517..1436ae2ce 100644 --- a/Source/include/Ably/ARTChannelOptions.h +++ b/Source/include/Ably/ARTChannelOptions.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRestChannel` object, such as encryption. */ +NS_SWIFT_NAME(ChannelOptions) @interface ARTChannelOptions : NSObject /** diff --git a/Source/include/Ably/ARTClientOptions.h b/Source/include/Ably/ARTClientOptions.h index 572983a6c..5e1169a74 100644 --- a/Source/include/Ably/ARTClientOptions.h +++ b/Source/include/Ably/ARTClientOptions.h @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Passes additional client-specific properties to the REST `-[ARTRestProtocol initWithOptions:]` or the Realtime `-[ARTRealtimeProtocol initWithOptions:]`. */ +NS_SWIFT_NAME(ClientOptions) @interface ARTClientOptions : ARTAuthOptions /** diff --git a/Source/include/Ably/ARTConnection.h b/Source/include/Ably/ARTConnection.h index aa25e2f56..3b8110cf6 100644 --- a/Source/include/Ably/ARTConnection.h +++ b/Source/include/Ably/ARTConnection.h @@ -80,6 +80,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTRealtimeConnectionEvent, ARTConnectionState * * @see See `ARTConnectionProtocol` for details. */ +NS_SWIFT_NAME(Connection) @interface ARTConnection: NSObject @end diff --git a/Source/include/Ably/ARTCrypto.h b/Source/include/Ably/ARTCrypto.h index fa3ab3691..80ba16004 100644 --- a/Source/include/Ably/ARTCrypto.h +++ b/Source/include/Ably/ARTCrypto.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(CipherKeyCompatible) @protocol ARTCipherKeyCompatible - (NSData *)toData; @end @@ -23,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN @class ARTCipherParams; /// :nodoc: +NS_SWIFT_NAME(CipherParamsCompatible) @protocol ARTCipherParamsCompatible - (ARTCipherParams *)toCipherParams; @end @@ -35,6 +37,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Sets the properties to configure encryption for an `ARTRestChannel` or `ARTRealtimeChannel` object. */ +NS_SWIFT_NAME(CipherParams) @interface ARTCipherParams : NSObject /** @@ -71,6 +74,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties required to configure the encryption of `ARTMessage` payloads. */ +NS_SWIFT_NAME(Crypto) @interface ARTCrypto : NSObject /** * Returns an `ARTCipherParams` object, using the default values for any fields not supplied by the `cipherParams` dictionary. diff --git a/Source/include/Ably/ARTDataQuery.h b/Source/include/Ably/ARTDataQuery.h index 6f9d8ccbd..7874b21a9 100755 --- a/Source/include/Ably/ARTDataQuery.h +++ b/Source/include/Ably/ARTDataQuery.h @@ -6,13 +6,14 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: typedef NS_ENUM(NSUInteger, ARTQueryDirection) { - ARTQueryDirectionForwards, - ARTQueryDirectionBackwards -}; + ARTQueryDirectionForwards NS_SWIFT_NAME(forwards), + ARTQueryDirectionBackwards NS_SWIFT_NAME(backwards) +} NS_SWIFT_NAME(QueryDirection); /** This object is used for providing parameters into methods with paginated results. */ +NS_SWIFT_NAME(DataQuery) @interface ARTDataQuery : NSObject /** @@ -40,6 +41,7 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) { /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ +NS_SWIFT_NAME(RealtimeHistoryQuery) @interface ARTRealtimeHistoryQuery : ARTDataQuery /** diff --git a/Source/include/Ably/ARTDefault.h b/Source/include/Ably/ARTDefault.h index 16b807c39..9e87b3fc9 100644 --- a/Source/include/Ably/ARTDefault.h +++ b/Source/include/Ably/ARTDefault.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** Represents default library settings. */ +NS_SWIFT_NAME(Default) @interface ARTDefault : NSObject + (NSString *)apiVersion; diff --git a/Source/include/Ably/ARTDeviceDetails.h b/Source/include/Ably/ARTDeviceDetails.h index b996fc99c..7cd1536a2 100644 --- a/Source/include/Ably/ARTDeviceDetails.h +++ b/Source/include/Ably/ARTDeviceDetails.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the properties of a device registered for push notifications. */ +NS_SWIFT_NAME(DeviceDetails) @interface ARTDeviceDetails : NSObject /** diff --git a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h index 5e2463dd3..e30a249ca 100644 --- a/Source/include/Ably/ARTDeviceIdentityTokenDetails.h +++ b/Source/include/Ably/ARTDeviceIdentityTokenDetails.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** * An object representing a unique device identity token used to communicate with APNS. */ +NS_SWIFT_NAME(DeviceIdentityTokenDetails) @interface ARTDeviceIdentityTokenDetails : NSObject /** diff --git a/Source/include/Ably/ARTDevicePushDetails.h b/Source/include/Ably/ARTDevicePushDetails.h index 3822cd595..175b843db 100644 --- a/Source/include/Ably/ARTDevicePushDetails.h +++ b/Source/include/Ably/ARTDevicePushDetails.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the details of the push registration of a device. */ +NS_SWIFT_NAME(DevicePushDetails) @interface ARTDevicePushDetails : NSObject /** diff --git a/Source/include/Ably/ARTDeviceStorage.h b/Source/include/Ably/ARTDeviceStorage.h index 1d965ed3d..d4694ebee 100644 --- a/Source/include/Ably/ARTDeviceStorage.h +++ b/Source/include/Ably/ARTDeviceStorage.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN // Instances of ARTDeviceStorage should expect to have their methods called // from any thread. /// :nodoc: +NS_SWIFT_NAME(DeviceStorage) @protocol ARTDeviceStorage - (nullable id)objectForKey:(NSString *)key; - (void)setObject:(nullable id)value forKey:(NSString *)key; diff --git a/Source/include/Ably/ARTEncoder.h b/Source/include/Ably/ARTEncoder.h index 9d740a78b..491d47b02 100644 --- a/Source/include/Ably/ARTEncoder.h +++ b/Source/include/Ably/ARTEncoder.h @@ -12,17 +12,19 @@ @class ARTPushChannelSubscription; @class ARTLocalDevice; +NS_SWIFT_NAME(PushRecipient) @protocol ARTPushRecipient; /// :nodoc: typedef NS_ENUM(NSUInteger, ARTEncoderFormat) { - ARTEncoderFormatJson, - ARTEncoderFormatMsgPack -}; + ARTEncoderFormatJson NS_SWIFT_NAME(json), + ARTEncoderFormatMsgPack NS_SWIFT_NAME(msgPack) +} NS_SWIFT_NAME(EncoderFormat); NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(Encoder) @protocol ARTEncoder - (NSString *)mimeType; diff --git a/Source/include/Ably/ARTEventEmitter.h b/Source/include/Ably/ARTEventEmitter.h index d6d20a293..bf1755d8c 100644 --- a/Source/include/Ably/ARTEventEmitter.h +++ b/Source/include/Ably/ARTEventEmitter.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(EventIdentification) @protocol ARTEventIdentification - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @@ -13,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_NAME(Event) @interface ARTEvent : NSObject - (instancetype)initWithString:(NSString *)value; @@ -23,12 +25,14 @@ NS_ASSUME_NONNULL_BEGIN /** An object representing a listener returned by `ARTEventEmitter` methods. */ +NS_SWIFT_NAME(EventListener) @interface ARTEventListener : NSObject @end /** * A generic interface for event registration and delivery used in a number of the types in the Realtime client library. For example, the `ARTConnection` and `ARTRealtimeChannel` objects emit events for their state using the `ARTEventEmitter` pattern. */ +NS_SWIFT_NAME(EventEmitter) @interface ARTEventEmitter, ItemType> : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTHTTPPaginatedResponse.h b/Source/include/Ably/ARTHTTPPaginatedResponse.h index 25ddbcae9..f482cf339 100644 --- a/Source/include/Ably/ARTHTTPPaginatedResponse.h +++ b/Source/include/Ably/ARTHTTPPaginatedResponse.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A superset of `ARTPaginatedResult` which represents a page of results plus metadata indicating the relative queries available to it. `ARTHttpPaginatedResponse` additionally carries information about the response to an HTTP request. */ +NS_SWIFT_NAME(HTTPPaginatedResponse) @interface ARTHTTPPaginatedResponse : ARTPaginatedResult /** diff --git a/Source/include/Ably/ARTLocalDevice.h b/Source/include/Ably/ARTLocalDevice.h index 25ef79639..4f0582642 100644 --- a/Source/include/Ably/ARTLocalDevice.h +++ b/Source/include/Ably/ARTLocalDevice.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the device identity token and secret of a device. `ARTLocalDevice` extends `ARTDeviceDetails`. */ +NS_SWIFT_NAME(LocalDevice) @interface ARTLocalDevice : ARTDeviceDetails /** diff --git a/Source/include/Ably/ARTLog.h b/Source/include/Ably/ARTLog.h index 4f344a80b..65adefa17 100644 --- a/Source/include/Ably/ARTLog.h +++ b/Source/include/Ably/ARTLog.h @@ -6,15 +6,16 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: typedef NS_ENUM(NSUInteger, ARTLogLevel) { - ARTLogLevelVerbose, - ARTLogLevelDebug, - ARTLogLevelInfo, - ARTLogLevelWarn, - ARTLogLevelError, - ARTLogLevelNone -}; + ARTLogLevelVerbose NS_SWIFT_NAME(verbose), + ARTLogLevelDebug NS_SWIFT_NAME(debug), + ARTLogLevelInfo NS_SWIFT_NAME(info), + ARTLogLevelWarn NS_SWIFT_NAME(warn), + ARTLogLevelError NS_SWIFT_NAME(error), + ARTLogLevelNone NS_SWIFT_NAME(none) +} NS_SWIFT_NAME(LogLevel); /// :nodoc: +NS_SWIFT_NAME(Log) @interface ARTLog : NSObject @property (nonatomic) ARTLogLevel logLevel; diff --git a/Source/include/Ably/ARTMessage.h b/Source/include/Ably/ARTMessage.h index 88d145170..8ba60e8c5 100644 --- a/Source/include/Ably/ARTMessage.h +++ b/Source/include/Ably/ARTMessage.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains an individual message that is sent to, or received from, Ably. */ +NS_SWIFT_NAME(Message) @interface ARTMessage : ARTBaseMessage /// The event name, if available diff --git a/Source/include/Ably/ARTPaginatedResult.h b/Source/include/Ably/ARTPaginatedResult.h index f215f6c6f..e346c720f 100644 --- a/Source/include/Ably/ARTPaginatedResult.h +++ b/Source/include/Ably/ARTPaginatedResult.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains a page of results for message or presence history, stats, or REST presence requests. An `ARTPaginatedResult` response from a REST API paginated query is also accompanied by metadata that indicates the relative queries available to the `ARTPaginatedResult` object. */ +NS_SWIFT_NAME(PaginatedResult) @interface ARTPaginatedResult : NSObject /** diff --git a/Source/include/Ably/ARTPresence.h b/Source/include/Ably/ARTPresence.h index e3589105d..726cbc352 100644 --- a/Source/include/Ably/ARTPresence.h +++ b/Source/include/Ably/ARTPresence.h @@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(Presence) @interface ARTPresence : NSObject - (void)history:(ARTPaginatedPresenceCallback)callback; diff --git a/Source/include/Ably/ARTPresenceMessage.h b/Source/include/Ably/ARTPresenceMessage.h index a97411136..8fc0e82e1 100644 --- a/Source/include/Ably/ARTPresenceMessage.h +++ b/Source/include/Ably/ARTPresenceMessage.h @@ -8,33 +8,34 @@ typedef NS_ENUM(NSUInteger, ARTPresenceAction) { /** * A member is not present in the channel. */ - ARTPresenceAbsent, + ARTPresenceAbsent NS_SWIFT_NAME(absent), /** * When subscribing to presence events on a channel that already has members present, this event is emitted for every member already present on the channel before the subscribe listener was registered. */ - ARTPresencePresent, + ARTPresencePresent NS_SWIFT_NAME(present), /** * A new member has entered the channel. */ - ARTPresenceEnter, + ARTPresenceEnter NS_SWIFT_NAME(enter), /** * A member who was present has now left the channel. This may be a result of an explicit request to leave or implicitly when detaching from the channel. Alternatively, if a member's connection is abruptly disconnected and they do not resume their connection within a minute, Ably treats this as a leave event as the client is no longer present. */ - ARTPresenceLeave, + ARTPresenceLeave NS_SWIFT_NAME(leave), /** * An already present member has updated their member data. Being notified of member data updates can be very useful, for example, it can be used to update the status of a user when they are typing a message. */ - ARTPresenceUpdate -}; + ARTPresenceUpdate NS_SWIFT_NAME(update) +} NS_SWIFT_NAME(PresenceAction); /// :nodoc: -NSString *_Nonnull ARTPresenceActionToStr(ARTPresenceAction action); +NSString * _Nonnull ARTPresenceActionToStr(ARTPresenceAction action) NS_SWIFT_NAME(PresenceActionToStr(_:)); NS_ASSUME_NONNULL_BEGIN /** * Contains an individual presence update sent to, or received from, Ably. */ +NS_SWIFT_NAME(PresenceMessage) @interface ARTPresenceMessage : ARTBaseMessage /** diff --git a/Source/include/Ably/ARTProtocolMessage.h b/Source/include/Ably/ARTProtocolMessage.h index 99d9186ee..b171e1c71 100644 --- a/Source/include/Ably/ARTProtocolMessage.h +++ b/Source/include/Ably/ARTProtocolMessage.h @@ -11,28 +11,29 @@ /// :nodoc: typedef NS_ENUM(NSUInteger, ARTProtocolMessageAction) { - ARTProtocolMessageHeartbeat = 0, - ARTProtocolMessageAck = 1, - ARTProtocolMessageNack = 2, - ARTProtocolMessageConnect = 3, - ARTProtocolMessageConnected = 4, - ARTProtocolMessageDisconnect = 5, - ARTProtocolMessageDisconnected = 6, - ARTProtocolMessageClose = 7, - ARTProtocolMessageClosed = 8, - ARTProtocolMessageError = 9, - ARTProtocolMessageAttach = 10, - ARTProtocolMessageAttached = 11, - ARTProtocolMessageDetach = 12, - ARTProtocolMessageDetached = 13, - ARTProtocolMessagePresence = 14, - ARTProtocolMessageMessage = 15, - ARTProtocolMessageSync = 16, - ARTProtocolMessageAuth = 17, -}; + ARTProtocolMessageHeartbeat NS_SWIFT_NAME(heartbeat) = 0, + ARTProtocolMessageAck NS_SWIFT_NAME(ack) = 1, + ARTProtocolMessageNack NS_SWIFT_NAME(nack) = 2, + ARTProtocolMessageConnect NS_SWIFT_NAME(connect) = 3, + ARTProtocolMessageConnected NS_SWIFT_NAME(connected) = 4, + ARTProtocolMessageDisconnect NS_SWIFT_NAME(disconnect) = 5, + ARTProtocolMessageDisconnected NS_SWIFT_NAME(disconnected) = 6, + ARTProtocolMessageClose NS_SWIFT_NAME(close) = 7, + ARTProtocolMessageClosed NS_SWIFT_NAME(closed) = 8, + ARTProtocolMessageError NS_SWIFT_NAME(error) = 9, + ARTProtocolMessageAttach NS_SWIFT_NAME(attach) = 10, + ARTProtocolMessageAttached NS_SWIFT_NAME(attached) = 11, + ARTProtocolMessageDetach NS_SWIFT_NAME(detach) = 12, + ARTProtocolMessageDetached NS_SWIFT_NAME(detached) = 13, + ARTProtocolMessagePresence NS_SWIFT_NAME(presence) = 14, + ARTProtocolMessageMessage NS_SWIFT_NAME(message) = 15, + ARTProtocolMessageSync NS_SWIFT_NAME(sync) = 16, + ARTProtocolMessageAuth NS_SWIFT_NAME(auth) = 17, +} NS_SWIFT_NAME(ProtocolMessageAction); /// :nodoc: -NSString *_Nonnull ARTProtocolMessageActionToStr(ARTProtocolMessageAction action); + +NSString *_Nonnull ARTProtocolMessageActionToStr(ARTProtocolMessageAction action) NS_SWIFT_NAME(ProtocolMessageActionToStr(_:)); NS_ASSUME_NONNULL_BEGIN @@ -42,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN * ARTProtocolMessage always relates to a single channel only, but can contain multiple individual messages or presence messages. * ARTProtocolMessage are serially numbered on a connection. */ +NS_SWIFT_NAME(ProtocolMessage) @interface ARTProtocolMessage : NSObject @property (readwrite, nonatomic) ARTProtocolMessageAction action; diff --git a/Source/include/Ably/ARTPush.h b/Source/include/Ably/ARTPush.h index 81b414995..b45c1a505 100644 --- a/Source/include/Ably/ARTPush.h +++ b/Source/include/Ably/ARTPush.h @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN /** The interface for handling Push activation/deactivation-related actions. */ +NS_SWIFT_NAME(PushRegistererDelegate) @protocol ARTPushRegistererDelegate /** @@ -57,6 +58,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTPush` is implemented. */ +NS_SWIFT_NAME(PushProtocol) @protocol ARTPushProtocol /// :nodoc: @@ -111,6 +113,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables a device to be registered and deregistered from receiving push notifications. */ +NS_SWIFT_NAME(Push) @interface ARTPush : NSObject /** diff --git a/Source/include/Ably/ARTPushAdmin.h b/Source/include/Ably/ARTPushAdmin.h index 6da31f872..f52c36239 100644 --- a/Source/include/Ably/ARTPushAdmin.h +++ b/Source/include/Ably/ARTPushAdmin.h @@ -4,15 +4,11 @@ #import NS_ASSUME_NONNULL_BEGIN -//@import Push; -// -//@interface test : RandomSwiftClass; -// -//@end /** The protocol upon which the `ARTPushAdmin` is implemented. */ +NS_SWIFT_NAME(PushAdminProtocol) @protocol ARTPushAdminProtocol /// :nodoc: @@ -32,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables the management of device registrations and push notification subscriptions. Also enables the publishing of push notifications to devices. */ +NS_SWIFT_NAME(PushAdmin) @interface ARTPushAdmin : NSObject /** diff --git a/Source/include/Ably/ARTPushChannel.h b/Source/include/Ably/ARTPushChannel.h index ce2551ea0..4f11742f6 100644 --- a/Source/include/Ably/ARTPushChannel.h +++ b/Source/include/Ably/ARTPushChannel.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTPushChannel` is implemented. */ +NS_SWIFT_NAME(PushChannelProtocol) @protocol ARTPushChannelProtocol /// :nodoc: @@ -83,6 +84,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelProtocol` for details. */ +NS_SWIFT_NAME(PushChannel) @interface ARTPushChannel : NSObject @end diff --git a/Source/include/Ably/ARTPushChannelSubscription.h b/Source/include/Ably/ARTPushChannelSubscription.h index eb89e72a2..f680d557b 100644 --- a/Source/include/Ably/ARTPushChannelSubscription.h +++ b/Source/include/Ably/ARTPushChannelSubscription.h @@ -5,6 +5,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Contains the subscriptions of a device, or a group of devices sharing the same `clientId`, has to a channel in order to receive push notifications. */ + +NS_SWIFT_NAME(PushChannelSubscription) @interface ARTPushChannelSubscription : NSObject /** diff --git a/Source/include/Ably/ARTPushChannelSubscriptions.h b/Source/include/Ably/ARTPushChannelSubscriptions.h index af06f0f08..d56a0aed0 100644 --- a/Source/include/Ably/ARTPushChannelSubscriptions.h +++ b/Source/include/Ably/ARTPushChannelSubscriptions.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTPushChannelSubscriptions` is implemented. */ +NS_SWIFT_NAME(PushChannelSubscriptionsProtocol) @protocol ARTPushChannelSubscriptionsProtocol /// :nodoc: @@ -62,6 +63,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushChannelSubscriptionsProtocol` for details. */ +NS_SWIFT_NAME(PushChannelSubscriptions) @interface ARTPushChannelSubscriptions : NSObject @end diff --git a/Source/include/Ably/ARTPushDeviceRegistrations.h b/Source/include/Ably/ARTPushDeviceRegistrations.h index 1738b9863..e81d888ae 100644 --- a/Source/include/Ably/ARTPushDeviceRegistrations.h +++ b/Source/include/Ably/ARTPushDeviceRegistrations.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTPushDeviceRegistrations` is implemented. */ +NS_SWIFT_NAME(PushDeviceRegistrationsProtocol) @protocol ARTPushDeviceRegistrationsProtocol /// :nodoc: @@ -61,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTPushDeviceRegistrationsProtocol` for details. */ +NS_SWIFT_NAME(PushDeviceRegistrations) @interface ARTPushDeviceRegistrations : NSObject @end diff --git a/Source/include/Ably/ARTRealtime.h b/Source/include/Ably/ARTRealtime.h index fbf87b8b8..21ae654e2 100644 --- a/Source/include/Ably/ARTRealtime.h +++ b/Source/include/Ably/ARTRealtime.h @@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the top level object `ARTRealtime` is implemented. */ +NS_SWIFT_NAME(RealtimeProtocol) @protocol ARTRealtimeProtocol #if TARGET_OS_IOS @@ -104,6 +105,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that extends the functionality of the `ARTRest` and provides additional realtime-specific features. */ +NS_SWIFT_NAME(Realtime) @interface ARTRealtime : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannel.h b/Source/include/Ably/ARTRealtimeChannel.h index 6a153d8aa..9b34e6bd2 100644 --- a/Source/include/Ably/ARTRealtimeChannel.h +++ b/Source/include/Ably/ARTRealtimeChannel.h @@ -149,6 +149,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTChannelEvent, ARTChannelStateChange *) * Enables messages to be published and subscribed to. Also enables historic messages to be retrieved and provides access to the `ARTRealtimePresence` object of a channel. * Also implements `ARTEventEmitter` interface and emits `ARTChannelEvent` events, where a `ARTChannelEvent` is either a `ARTRealtimeChannelState` or an `ARTChannelEvent.ARTChannelEventUpdate`. */ +NS_SWIFT_NAME(RealtimeChannel) @interface ARTRealtimeChannel : NSObject /** diff --git a/Source/include/Ably/ARTRealtimeChannelOptions.h b/Source/include/Ably/ARTRealtimeChannelOptions.h index 2e5618d12..36f0d9197 100644 --- a/Source/include/Ably/ARTRealtimeChannelOptions.h +++ b/Source/include/Ably/ARTRealtimeChannelOptions.h @@ -9,26 +9,27 @@ typedef NS_OPTIONS(NSUInteger, ARTChannelMode) { /** * The client can enter the presence set. */ - ARTChannelModePresence = 1 << 16, + ARTChannelModePresence NS_SWIFT_NAME(presence) = 1 << 16, /** * The client can publish messages. */ - ARTChannelModePublish = 1 << 17, + ARTChannelModePublish NS_SWIFT_NAME(publish) = 1 << 17, /** * The client can subscribe to messages. */ - ARTChannelModeSubscribe = 1 << 18, + ARTChannelModeSubscribe NS_SWIFT_NAME(subscribe) = 1 << 18, /** * The client can receive presence messages. */ - ARTChannelModePresenceSubscribe = 1 << 19 -}; + ARTChannelModePresenceSubscribe NS_SWIFT_NAME(presenceSubscribe) = 1 << 19 +} NS_SWIFT_NAME(ChannelMode); NS_ASSUME_NONNULL_BEGIN /** * Passes additional properties to an `ARTRealtimeChannel` object, such as encryption, an `ARTChannelMode` and channel parameters. */ +NS_SWIFT_NAME(RealtimeChannelOptions) @interface ARTRealtimeChannelOptions : ARTChannelOptions /** diff --git a/Source/include/Ably/ARTRealtimeChannels.h b/Source/include/Ably/ARTRealtimeChannels.h index e927c3595..74a03c748 100644 --- a/Source/include/Ably/ARTRealtimeChannels.h +++ b/Source/include/Ably/ARTRealtimeChannels.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(RealtimeChannelsProtocol) @protocol ARTRealtimeChannelsProtocol // We copy this from the parent class and replace ChannelType by ARTRealtimeChannel * because @@ -17,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_NAME(RealtimeChannels) @interface ARTRealtimeChannels : NSObject - (ARTRealtimeChannel *)get:(NSString *)name; diff --git a/Source/include/Ably/ARTRealtimePresence.h b/Source/include/Ably/ARTRealtimePresence.h index 6e22ef459..718476ed0 100644 --- a/Source/include/Ably/ARTRealtimePresence.h +++ b/Source/include/Ably/ARTRealtimePresence.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results. */ +NS_SWIFT_NAME(RealtimePresenceQuery) @interface ARTRealtimePresenceQuery : ARTPresenceQuery /** @@ -22,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTRealtimePresence` is implemented. */ +NS_SWIFT_NAME(RealtimePresenceProtocol) @protocol ARTRealtimePresenceProtocol /** @@ -217,6 +219,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRealtimePresenceProtocol` for details. */ +NS_SWIFT_NAME(RealtimePresence) @interface ARTRealtimePresence : ARTPresence @end diff --git a/Source/include/Ably/ARTRest.h b/Source/include/Ably/ARTRest.h index ca9dbd0de..e8187442a 100644 --- a/Source/include/Ably/ARTRest.h +++ b/Source/include/Ably/ARTRest.h @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the top level object `ARTRest` is implemented. */ +NS_SWIFT_NAME(RestProtocol) @protocol ARTRestProtocol /// :nodoc: @@ -99,6 +100,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A client that offers a simple stateless API to interact directly with Ably's REST API. */ +NS_SWIFT_NAME(Rest) @interface ARTRest : NSObject /** diff --git a/Source/include/Ably/ARTRestChannel.h b/Source/include/Ably/ARTRestChannel.h index 2c25a3a2e..2b86cd990 100644 --- a/Source/include/Ably/ARTRestChannel.h +++ b/Source/include/Ably/ARTRestChannel.h @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTRestChannel` is implemented. */ +NS_SWIFT_NAME(RestChannelProtocol) @protocol ARTRestChannelProtocol /// :nodoc: TODO: docstring @@ -46,6 +47,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Enables messages to be published and historic messages to be retrieved for a channel. */ +NS_SWIFT_NAME(RestChannel) @interface ARTRestChannel : NSObject /** diff --git a/Source/include/Ably/ARTRestChannels.h b/Source/include/Ably/ARTRestChannels.h index 3a9bcc13e..b266df882 100644 --- a/Source/include/Ably/ARTRestChannels.h +++ b/Source/include/Ably/ARTRestChannels.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(RestChannelsProtocol) @protocol ARTRestChannelsProtocol // We copy this from the parent class and replace ChannelType by ARTRestChannel * because @@ -16,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @end /// :nodoc: +NS_SWIFT_NAME(RestChannels) @interface ARTRestChannels : NSObject - (ARTRestChannel *)get:(NSString *)name; diff --git a/Source/include/Ably/ARTRestPresence.h b/Source/include/Ably/ARTRestPresence.h index 0d24c00dc..5219d594a 100644 --- a/Source/include/Ably/ARTRestPresence.h +++ b/Source/include/Ably/ARTRestPresence.h @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN /** This object is used for providing parameters into `ARTRestPresence`'s methods with paginated results. */ +NS_SWIFT_NAME(PresenceQuery) @interface ARTPresenceQuery : NSObject /** @@ -41,6 +42,7 @@ NS_ASSUME_NONNULL_BEGIN /** The protocol upon which the `ARTRestPresence` is implemented. */ +NS_SWIFT_NAME(RestPresenceProtocol) @protocol ARTRestPresenceProtocol /// :nodoc: TODO: docstring @@ -78,6 +80,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see See `ARTRestPresenceProtocol` for details. */ +NS_SWIFT_NAME(RestPresence) @interface ARTRestPresence : ARTPresence @end diff --git a/Source/include/Ably/ARTStats.h b/Source/include/Ably/ARTStats.h index e05a5b342..29d74e267 100644 --- a/Source/include/Ably/ARTStats.h +++ b/Source/include/Ably/ARTStats.h @@ -11,24 +11,25 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Interval unit over which statistics are gathered as minutes. */ - ARTStatsGranularityMinute, + ARTStatsGranularityMinute NS_SWIFT_NAME(minute), /** * Interval unit over which statistics are gathered as hours. */ - ARTStatsGranularityHour, + ARTStatsGranularityHour NS_SWIFT_NAME(hour), /** * Interval unit over which statistics are gathered as days. */ - ARTStatsGranularityDay, + ARTStatsGranularityDay NS_SWIFT_NAME(day), /** * Interval unit over which statistics are gathered as months. */ - ARTStatsGranularityMonth -}; + ARTStatsGranularityMonth NS_SWIFT_NAME(month) +} NS_SWIFT_NAME(StatsGranularity); /** This object is used for providing parameters into `ARTStats`'s methods with paginated results. */ +NS_SWIFT_NAME(StatsQuery) @interface ARTStatsQuery : ARTDataQuery /** @@ -41,6 +42,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate counts for messages and data transferred. */ +NS_SWIFT_NAME(StatsMessageCount) @interface ARTStatsMessageCount : NSObject /** @@ -68,6 +70,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for different (channel vs presence) message types. */ +NS_SWIFT_NAME(StatsMessageTypes) @interface ARTStatsMessageTypes : NSObject /** @@ -101,6 +104,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for traffic over various transport types. */ +NS_SWIFT_NAME(StatsMessageTraffic) @interface ARTStatsMessageTraffic : NSObject /** @@ -140,6 +144,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate data for usage of a resource in a specific scope. */ +NS_SWIFT_NAME(StatsResourceCount) @interface ARTStatsResourceCount : NSObject /** @@ -185,6 +190,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains a breakdown of summary stats data for different (`TLS` vs non-`TLS`) connection types. */ +NS_SWIFT_NAME(StatsConnectionTypes) @interface ARTStatsConnectionTypes : NSObject /** @@ -218,6 +224,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains the aggregate counts for requests made. */ +NS_SWIFT_NAME(StatsRequestCount) @interface ARTStatsRequestCount : NSObject /** @@ -251,6 +258,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Details the stats on push notifications. */ +NS_SWIFT_NAME(StatsPushCount) @interface ARTStatsPushCount : NSObject /** @@ -302,6 +310,7 @@ typedef NS_ENUM(NSUInteger, ARTStatsGranularity) { /** * Contains application statistics for a specified time interval and time period. */ +NS_SWIFT_NAME(Stats) @interface ARTStats : NSObject /// :nodoc: diff --git a/Source/include/Ably/ARTStatus.h b/Source/include/Ably/ARTStatus.h index c36e83c8c..483075deb 100644 --- a/Source/include/Ably/ARTStatus.h +++ b/Source/include/Ably/ARTStatus.h @@ -2,173 +2,174 @@ /// :nodoc: typedef NS_ENUM(NSUInteger, ARTState) { - ARTStateOk = 0, - ARTStateConnectionClosedByClient, - ARTStateConnectionDisconnected, - ARTStateConnectionSuspended, - ARTStateConnectionFailed, - ARTStateAccessRefused, - ARTStateNeverConnected, - ARTStateConnectionTimedOut, - ARTStateAttachTimedOut, - ARTStateDetachTimedOut, - ARTStateNotAttached, - ARTStateInvalidArgs, - ARTStateCryptoBadPadding, - ARTStateNoClientId, - ARTStateMismatchedClientId, - ARTStateRequestTokenFailed, - ARTStateAuthorizationFailed, - ARTStateAuthUrlIncompatibleContent, - ARTStateBadConnectionState, - ARTStateError = 99999 -}; + ARTStateOk NS_SWIFT_NAME(ok) = 0, + ARTStateConnectionClosedByClient NS_SWIFT_NAME(connetionClosedByClient), + ARTStateConnectionDisconnected NS_SWIFT_NAME(connectionDisconnected), + ARTStateConnectionSuspended NS_SWIFT_NAME(connectionSuspended), + ARTStateConnectionFailed NS_SWIFT_NAME(connectionFailed), + ARTStateAccessRefused NS_SWIFT_NAME(accessRefused), + ARTStateNeverConnected NS_SWIFT_NAME(neverConnected), + ARTStateConnectionTimedOut NS_SWIFT_NAME(connectiontimedOut), + ARTStateAttachTimedOut NS_SWIFT_NAME(attachTimedOut), + ARTStateDetachTimedOut NS_SWIFT_NAME(detachTimedOut), + ARTStateNotAttached NS_SWIFT_NAME(notAttached), + ARTStateInvalidArgs NS_SWIFT_NAME(invalidArgs), + ARTStateCryptoBadPadding NS_SWIFT_NAME(cryptoBadPadding), + ARTStateNoClientId NS_SWIFT_NAME(noClientId), + ARTStateMismatchedClientId NS_SWIFT_NAME(mismatchedClientId), + ARTStateRequestTokenFailed NS_SWIFT_NAME(requestTokenFailed), + ARTStateAuthorizationFailed NS_SWIFT_NAME(authorizationFailed), + ARTStateAuthUrlIncompatibleContent NS_SWIFT_NAME(authUrlIncompatibleContent), + ARTStateBadConnectionState NS_SWIFT_NAME(badConnectionState), + ARTStateError NS_SWIFT_NAME(error) = 99999 +} NS_SWIFT_NAME(State); /** The list of all public error codes returned under the error domain ARTAblyErrorDomain */ typedef CF_ENUM(NSUInteger, ARTErrorCode) { - ARTErrorNoError = 10000, - ARTErrorBadRequest = 40000, - ARTErrorInvalidRequestBody = 40001, - ARTErrorInvalidParameterName = 40002, - ARTErrorInvalidParameterValue = 40003, - ARTErrorInvalidHeader = 40004, - ARTErrorInvalidCredential = 40005, - ARTErrorInvalidConnectionId = 40006, - ARTErrorInvalidMessageId = 40007, - ARTErrorInvalidContentLength = 40008, - ARTErrorMaxMessageLengthExceeded = 40009, - ARTErrorInvalidChannelName = 40010, - ARTErrorStaleRingState = 40011, - ARTErrorInvalidClientId = 40012, - ARTErrorInvalidMessageDataOrEncoding = 40013, - ARTErrorResourceDisposed = 40014, - ARTErrorInvalidDeviceId = 40015, - ARTErrorInvalidMessageName = 40016, - ARTErrorUnsupportedProtocolVersion = 40017, - ARTErrorUnableToDecodeMessage = 40018, - ARTErrorBatchError = 40020, - ARTErrorInvalidPublishRequest = 40030, - ARTErrorInvalidClient = 40031, - ARTErrorReservedForTesting = 40099, - ARTErrorUnauthorized = 40100, - ARTErrorInvalidCredentials = 40101, - ARTErrorIncompatibleCredentials = 40102, - ARTErrorInvalidUseOfBasicAuthOverNonTlsTransport = 40103, - ARTErrorTimestampNotCurrent = 40104, - ARTErrorNonceValueReplayed = 40105, - ARTErrorUnableToObtainCredentials = 40106, - ARTErrorAccountDisabled = 40110, - ARTErrorAccountConnectionLimitsExceeded = 40111, - ARTErrorAccountMessageLimitsExceeded = 40112, - ARTErrorAccountBlocked = 40113, - ARTErrorAccountChannelLimitsExceeded = 40114, - ARTErrorApplicationDisabled = 40120, - ARTErrorKeyErrorUnspecified = 40130, - ARTErrorKeyRevoked = 40131, - ARTErrorKeyExpired = 40132, - ARTErrorKeyDisabled = 40133, - ARTErrorTokenErrorUnspecified = 40140, - ARTErrorTokenRevoked = 40141, - ARTErrorTokenExpired = 40142, - ARTErrorTokenUnrecognised = 40143, - ARTErrorInvalidJwtFormat = 40144, - ARTErrorInvalidTokenFormat = 40145, - ARTErrorConnectionLimitsExceeded = 40150, - ARTErrorOperationNotPermittedWithProvidedCapability = 40160, - ARTErrorOperationNotPermittedAsItRequiresAnIdentifiedClient = 40161, - ARTErrorErrorFromClientTokenCallback = 40170, - ARTErrorNoMeansProvidedToRenewAuthToken = 40171, - ARTErrorForbidden = 40300, - ARTErrorAccountDoesNotPermitTlsConnection = 40310, - ARTErrorOperationRequiresTlsConnection = 40311, - ARTErrorApplicationRequiresAuthentication = 40320, - ARTErrorUnableToActivateAccountUnspecified = 40330, - ARTErrorUnableToActivateAccountIncompatibleEnvironment = 40331, - ARTErrorUnableToActivateAccountIncompatibleSite = 40332, - ARTErrorNotFound = 40400, - ARTErrorMethodNotAllowed = 40500, - ARTErrorRateLimitExceededUnspecified = 42910, - ARTErrorMaxPerConnectionPublishRateLimitExceeded = 42911, - ARTErrorRateLimitExceededFatal = 42920, - ARTErrorMaxPerConnectionPublishRateLimitExceededFatal = 42921, - ARTErrorInternalError = 50000, - ARTErrorInternalChannelError = 50001, - ARTErrorInternalConnectionError = 50002, - ARTErrorTimeoutError = 50003, - ARTErrorRequestFailedDueToOverloadedInstance = 50004, - ARTErrorEdgeProxyServiceInternalError = 50010, - ARTErrorEdgeProxyServiceBadGateway = 50210, - ARTErrorEdgeProxyServiceUnavailableAblyPlatform = 50310, - ARTErrorTrafficTemporarilyRedirectedToBackupService = 50320, - ARTErrorEdgeProxyServiceTimedOutWaitingAblyPlatform = 50410, - ARTErrorReactorOperationFailed = 70000, - ARTErrorReactorPostOperationFailed = 70001, - ARTErrorReactorPostOperationReturnedUnexpectedCode = 70002, - ARTErrorReactorMaxNumberOfConcurrentRequestsExceeded = 70003, - ARTErrorReactorInvalidOrUnacceptedMessageContents = 70004, - ARTErrorExchangeErrorUnspecified = 71000, - ARTErrorForcedReAttachmentDueToPermissionsChange = 71001, - ARTErrorExchangePublisherErrorUnspecified = 71100, - ARTErrorNoSuchPublisher = 71101, - ARTErrorPublisherNotEnabledAsAnExchangePublisher = 71102, - ARTErrorExchangeProductErrorUnspecified = 71200, - ARTErrorNoSuchProduct = 71201, - ARTErrorProductDisabled = 71202, - ARTErrorNoSuchChannelInThisProduct = 71203, - ARTErrorForcedReAttachmentDueToRemapped = 71204, - ARTErrorExchangeSubscriptionErrorUnspecified = 71300, - ARTErrorSubscriptionDisabled = 71301, - ARTErrorRequesterHasNoSubscriptionToThisProduct = 71302, - ARTErrorChannelDoesNotMatchTheChannelFilter = 71303, - ARTErrorConnectionFailed = 80000, - ARTErrorConnectionFailedNoCompatibleTransport = 80001, - ARTErrorConnectionSuspended = 80002, - ARTErrorDisconnected = 80003, - ARTErrorAlreadyConnected = 80004, - ARTErrorInvalidConnectionIdRemoteNotFound = 80005, - ARTErrorUnableToRecoverConnectionMessagesExpired = 80006, - ARTErrorUnableToRecoverConnectionMessageLimitExceeded = 80007, - ARTErrorUnableToRecoverConnectionExpired = 80008, - ARTErrorConnectionNotEstablishedNoTransportHandle = 80009, - ARTErrorInvalidTransportHandle = 80010, - ARTErrorUnableToRecoverConnectionIncompatibleAuthParams = 80011, - ARTErrorUnableToRecoverConnectionInvalidConnectionSerial = 80012, - ARTErrorProtocolError = 80013, - ARTErrorConnectionTimedOut = 80014, - ARTErrorIncompatibleConnectionParameters = 80015, - ARTErrorOperationOnSupersededConnection = 80016, - ARTErrorConnectionClosed = 80017, - ARTErrorInvalidConnectionIdInvalidFormat = 80018, - ARTErrorAuthConfiguredProviderFailure = 80019, - ARTErrorContinuityLossDueToMaxSubscribeMessageRateExceeded = 80020, - ARTErrorClientRestrictionNotSatisfied = 80030, - ARTErrorChannelOperationFailed = 90000, - ARTErrorChannelOperationFailedInvalidState = 90001, - ARTErrorChannelOperationFailedEpochExpired = 90002, - ARTErrorUnableToRecoverChannelMessagesExpired = 90003, - ARTErrorUnableToRecoverChannelMessageLimitExceeded = 90004, - ARTErrorUnableToRecoverChannelNoMatchingEpoch = 90005, - ARTErrorUnableToRecoverChannelUnboundedRequest = 90006, - ARTErrorChannelOperationFailedNoResponseFromServer = 90007, - ARTErrorMaxNumberOfChannelsPerConnectionExceeded = 90010, - ARTErrorUnableToEnterPresenceChannelNoClientid = 91000, - ARTErrorUnableToEnterPresenceChannelInvalidState = 91001, - ARTErrorUnableToLeavePresenceChannelThatIsNotEntered = 91002, - ARTErrorUnableToEnterPresenceChannelMaxMemberLimitExceeded = 91003, - ARTErrorUnableToAutomaticallyReEnterPresenceChannel = 91004, - ARTErrorPresenceStateIsOutOfSync = 91005, - ARTErrorMemberImplicitlyLeftPresenceChannel = 91100 + ARTErrorNoError NS_SWIFT_NAME(noError) = 10000, + ARTErrorBadRequest NS_SWIFT_NAME(badRequest) = 40000, + ARTErrorInvalidRequestBody NS_SWIFT_NAME(invalidRequestBody) = 40001, + ARTErrorInvalidParameterName NS_SWIFT_NAME(invalidParameterName) = 40002, + ARTErrorInvalidParameterValue NS_SWIFT_NAME(invalidParameterValue) = 40003, + ARTErrorInvalidHeader NS_SWIFT_NAME(invalidHeader) = 40004, + ARTErrorInvalidCredential NS_SWIFT_NAME(invalidCredential) = 40005, + ARTErrorInvalidConnectionId NS_SWIFT_NAME(invalidConnectionId) = 40006, + ARTErrorInvalidMessageId NS_SWIFT_NAME(invalidMessageId) = 40007, + ARTErrorInvalidContentLength NS_SWIFT_NAME(invalidContentLength) = 40008, + ARTErrorMaxMessageLengthExceeded NS_SWIFT_NAME(maxMessageLengthExceeded) = 40009, + ARTErrorInvalidChannelName NS_SWIFT_NAME(invalidChannelName) = 40010, + ARTErrorStaleRingState NS_SWIFT_NAME(staleRingState) = 40011, + ARTErrorInvalidClientId NS_SWIFT_NAME(invalidClientId) = 40012, + ARTErrorInvalidMessageDataOrEncoding NS_SWIFT_NAME(invalidMessageDataOrEncoding) = 40013, + ARTErrorResourceDisposed NS_SWIFT_NAME(resourceDisposed) = 40014, + ARTErrorInvalidDeviceId NS_SWIFT_NAME(invalidDeviceId) = 40015, + ARTErrorInvalidMessageName NS_SWIFT_NAME(invalidMessageName) = 40016, + ARTErrorUnsupportedProtocolVersion NS_SWIFT_NAME(unsupportedProtocolVersion) = 40017, + ARTErrorUnableToDecodeMessage NS_SWIFT_NAME(unableToDecodeMessage) = 40018, + ARTErrorBatchError NS_SWIFT_NAME(batchError) = 40020, + ARTErrorInvalidPublishRequest NS_SWIFT_NAME(invalidPublishRequest) = 40030, + ARTErrorInvalidClient NS_SWIFT_NAME(invalidClient) = 40031, + ARTErrorReservedForTesting NS_SWIFT_NAME(reservedForTesting) = 40099, + ARTErrorUnauthorized NS_SWIFT_NAME(unauthorized) = 40100, + ARTErrorInvalidCredentials NS_SWIFT_NAME(invalidCredentials) = 40101, + ARTErrorIncompatibleCredentials NS_SWIFT_NAME(incompatibleCredentials) = 40102, + ARTErrorInvalidUseOfBasicAuthOverNonTlsTransport NS_SWIFT_NAME(invalidUseOfBasicAuthOverNonTlsTransport) = 40103, + ARTErrorTimestampNotCurrent NS_SWIFT_NAME(timestampNotCurrent) = 40104, + ARTErrorNonceValueReplayed NS_SWIFT_NAME(nonceValueReplayed) = 40105, + ARTErrorUnableToObtainCredentials NS_SWIFT_NAME(unableToObtainCredentials) = 40106, + ARTErrorAccountDisabled NS_SWIFT_NAME(accountDisabled) = 40110, + ARTErrorAccountConnectionLimitsExceeded NS_SWIFT_NAME(accountConnectionLimitsExceeded) = 40111, + ARTErrorAccountMessageLimitsExceeded NS_SWIFT_NAME(accountMessageLimitsExceeded) = 40112, + ARTErrorAccountBlocked NS_SWIFT_NAME(accountBlocked) = 40113, + ARTErrorAccountChannelLimitsExceeded NS_SWIFT_NAME(accountChannelLimitsExceeded) = 40114, + ARTErrorApplicationDisabled NS_SWIFT_NAME(applicationDisabled) = 40120, + ARTErrorKeyErrorUnspecified NS_SWIFT_NAME(keyErrorUnspecified) = 40130, + ARTErrorKeyRevoked NS_SWIFT_NAME(keyRevoked) = 40131, + ARTErrorKeyExpired NS_SWIFT_NAME(keyExpired) = 40132, + ARTErrorKeyDisabled NS_SWIFT_NAME(keyDisabled) = 40133, + ARTErrorTokenErrorUnspecified NS_SWIFT_NAME(tokenErrorUnspecified) = 40140, + ARTErrorTokenRevoked NS_SWIFT_NAME(tokenRevoked) = 40141, + ARTErrorTokenExpired NS_SWIFT_NAME(tokenExpired) = 40142, + ARTErrorTokenUnrecognised NS_SWIFT_NAME(tokenUnrecognised) = 40143, + ARTErrorInvalidJwtFormat NS_SWIFT_NAME(invalidJwtFormat) = 40144, + ARTErrorInvalidTokenFormat NS_SWIFT_NAME(invalidTokenFormat) = 40145, + ARTErrorConnectionLimitsExceeded NS_SWIFT_NAME(connectionLimitsExceeded) = 40150, + ARTErrorOperationNotPermittedWithProvidedCapability NS_SWIFT_NAME(operationNotPermittedWithProvidedCapability) = 40160, + ARTErrorOperationNotPermittedAsItRequiresAnIdentifiedClient NS_SWIFT_NAME(operationNotPermittedAsItRequiresAnIdentifiedClient) = 40161, + ARTErrorErrorFromClientTokenCallback NS_SWIFT_NAME(errorFromClientTokenCallback) = 40170, + ARTErrorNoMeansProvidedToRenewAuthToken NS_SWIFT_NAME(noMeansProvidedToRenewAuthToken) = 40171, + ARTErrorForbidden NS_SWIFT_NAME(forbidden) = 40300, + ARTErrorAccountDoesNotPermitTlsConnection NS_SWIFT_NAME(accountDoesNotPermitTlsConnection) = 40310, + ARTErrorOperationRequiresTlsConnection NS_SWIFT_NAME(operationRequiresTlsConnection) = 40311, + ARTErrorApplicationRequiresAuthentication NS_SWIFT_NAME(applicationRequiresAuthentication) = 40320, + ARTErrorUnableToActivateAccountUnspecified NS_SWIFT_NAME(unableToActivateAccountUnspecified) = 40330, + ARTErrorUnableToActivateAccountIncompatibleEnvironment NS_SWIFT_NAME(unableToActivateAccountIncompatibleEnvironment) = 40331, + ARTErrorUnableToActivateAccountIncompatibleSite NS_SWIFT_NAME(unableToActivateAccountIncompatibleSite) = 40332, + ARTErrorNotFound NS_SWIFT_NAME(notFound) = 40400, + ARTErrorMethodNotAllowed NS_SWIFT_NAME(methodNotAllowed) = 40500, + ARTErrorRateLimitExceededUnspecified NS_SWIFT_NAME(rateLimitExceededUnspecified) = 42910, + ARTErrorMaxPerConnectionPublishRateLimitExceeded NS_SWIFT_NAME(maxPerConnectionPublishRateLimitExceeded) = 42911, + ARTErrorRateLimitExceededFatal NS_SWIFT_NAME(rateLimitExceededFatal) = 42920, + ARTErrorMaxPerConnectionPublishRateLimitExceededFatal NS_SWIFT_NAME(maxPerConnectionPublishRateLimitExceededFatal) = 42921, + ARTErrorInternalError NS_SWIFT_NAME(internalError) = 50000, + ARTErrorInternalChannelError NS_SWIFT_NAME(internalChannelError) = 50001, + ARTErrorInternalConnectionError NS_SWIFT_NAME(internalConnectionError) = 50002, + ARTErrorTimeoutError NS_SWIFT_NAME(timeoutError) = 50003, + ARTErrorRequestFailedDueToOverloadedInstance NS_SWIFT_NAME(requestFailedDueToOverloadedInstance) = 50004, + ARTErrorEdgeProxyServiceInternalError NS_SWIFT_NAME(edgeProxyServiceInternalError) = 50010, + ARTErrorEdgeProxyServiceBadGateway NS_SWIFT_NAME(edgeProxyServiceBadGateway) = 50210, + ARTErrorEdgeProxyServiceUnavailableAblyPlatform NS_SWIFT_NAME(edgeProxyServiceUnavailableAblyPlatform) = 50310, + ARTErrorTrafficTemporarilyRedirectedToBackupService NS_SWIFT_NAME(trafficTemporarilyRedirectedToBackupService) = 50320, + ARTErrorEdgeProxyServiceTimedOutWaitingAblyPlatform NS_SWIFT_NAME(edgeProxyServiceTimedOutWaitingAblyPlatform) = 50410, + ARTErrorReactorOperationFailed NS_SWIFT_NAME(reactorOperationFailed) = 70000, + ARTErrorReactorPostOperationFailed NS_SWIFT_NAME(reactorPostOperationFailed) = 70001, + ARTErrorReactorPostOperationReturnedUnexpectedCode NS_SWIFT_NAME(reactorPostOperationReturnedUnexpectedCode) = 70002, + ARTErrorReactorMaxNumberOfConcurrentRequestsExceeded NS_SWIFT_NAME(reactorMaxNumberOfConcurrentRequestsExceeded) = 70003, + ARTErrorReactorInvalidOrUnacceptedMessageContents NS_SWIFT_NAME(reactorInvalidOrUnacceptedMessageContents) = 70004, + ARTErrorExchangeErrorUnspecified NS_SWIFT_NAME(exchangeErrorUnspecified) = 71000, + ARTErrorForcedReAttachmentDueToPermissionsChange NS_SWIFT_NAME(forcedReAttachmentDueToPermissionsChange) = 71001, + ARTErrorExchangePublisherErrorUnspecified NS_SWIFT_NAME(exchangePublisherErrorUnspecified) = 71100, + ARTErrorNoSuchPublisher NS_SWIFT_NAME(noSuchPublisher) = 71101, + ARTErrorPublisherNotEnabledAsAnExchangePublisher NS_SWIFT_NAME(publisherNotEnabledAsAnExchangePublisher) = 71102, + ARTErrorExchangeProductErrorUnspecified NS_SWIFT_NAME(exchangeProductErrorUnspecified) = 71200, + ARTErrorNoSuchProduct NS_SWIFT_NAME(noSuchProduct) = 71201, + ARTErrorProductDisabled NS_SWIFT_NAME(productDisabled) = 71202, + ARTErrorNoSuchChannelInThisProduct NS_SWIFT_NAME(noSuchChannelInThisProduct) = 71203, + ARTErrorForcedReAttachmentDueToRemapped NS_SWIFT_NAME(forcedReAttachmentDueToRemapped) = 71204, + ARTErrorExchangeSubscriptionErrorUnspecified NS_SWIFT_NAME(exchangeSubscriptionErrorUnspecified) = 71300, + ARTErrorSubscriptionDisabled NS_SWIFT_NAME(subscriptionDisabled) = 71301, + ARTErrorRequesterHasNoSubscriptionToThisProduct NS_SWIFT_NAME(requesterHasNoSubscriptionToThisProduct) = 71302, + ARTErrorChannelDoesNotMatchTheChannelFilter NS_SWIFT_NAME(channelDoesNotMatchTheChannelFilter) = 71303, + ARTErrorConnectionFailed NS_SWIFT_NAME(connectionFailed) = 80000, + ARTErrorConnectionFailedNoCompatibleTransport NS_SWIFT_NAME(connectionFailedNoCompatibleTransport) = 80001, + ARTErrorConnectionSuspended NS_SWIFT_NAME(connectionSuspended) = 80002, + ARTErrorDisconnected NS_SWIFT_NAME(disconnected) = 80003, + ARTErrorAlreadyConnected NS_SWIFT_NAME(alreadyConnected) = 80004, + ARTErrorInvalidConnectionIdRemoteNotFound NS_SWIFT_NAME(invalidConnectionIdRemoteNotFound) = 80005, + ARTErrorUnableToRecoverConnectionMessagesExpired NS_SWIFT_NAME(unableToRecoverConnectionMessagesExpired) = 80006, + ARTErrorUnableToRecoverConnectionMessageLimitExceeded NS_SWIFT_NAME(unableToRecoverConnectionMessageLimitExceeded) = 80007, + ARTErrorUnableToRecoverConnectionExpired NS_SWIFT_NAME(unableToRecoverConnectionExpired) = 80008, + ARTErrorConnectionNotEstablishedNoTransportHandle NS_SWIFT_NAME(connectionNotEstablishedNoTransportHandle) = 80009, + ARTErrorInvalidTransportHandle NS_SWIFT_NAME(invalidTransportHandle) = 80010, + ARTErrorUnableToRecoverConnectionIncompatibleAuthParams NS_SWIFT_NAME(unableToRecoverConnectionIncompatibleAuthParams) = 80011, + ARTErrorUnableToRecoverConnectionInvalidConnectionSerial NS_SWIFT_NAME(unableToRecoverConnectionInvalidConnectionSerial) = 80012, + ARTErrorProtocolError NS_SWIFT_NAME(protocolError) = 80013, + ARTErrorConnectionTimedOut NS_SWIFT_NAME(connectionTimedOut) = 80014, + ARTErrorIncompatibleConnectionParameters NS_SWIFT_NAME(incompatibleConnectionParameters) = 80015, + ARTErrorOperationOnSupersededConnection NS_SWIFT_NAME(operationOnSupersededConnection) = 80016, + ARTErrorConnectionClosed NS_SWIFT_NAME(connectionClosed) = 80017, + ARTErrorInvalidConnectionIdInvalidFormat NS_SWIFT_NAME(invalidConnectionIdInvalidFormat) = 80018, + ARTErrorAuthConfiguredProviderFailure NS_SWIFT_NAME(authConfiguredProviderFailure) = 80019, + ARTErrorContinuityLossDueToMaxSubscribeMessageRateExceeded NS_SWIFT_NAME(continuityLossDueToMaxSubscribeMessageRateExceeded) = 80020, + ARTErrorClientRestrictionNotSatisfied NS_SWIFT_NAME(clientRestrictionNotSatisfied) = 80030, + ARTErrorChannelOperationFailed NS_SWIFT_NAME(channelOperationFailed) = 90000, + ARTErrorChannelOperationFailedInvalidState NS_SWIFT_NAME(channelOperationFailedInvalidState) = 90001, + ARTErrorChannelOperationFailedEpochExpired NS_SWIFT_NAME(channelOperationFailedEpochExpired) = 90002, + ARTErrorUnableToRecoverChannelMessagesExpired NS_SWIFT_NAME(unableToRecoverChannelMessagesExpired) = 90003, + ARTErrorUnableToRecoverChannelMessageLimitExceeded NS_SWIFT_NAME(unableToRecoverChannelMessageLimitExceeded) = 90004, + ARTErrorUnableToRecoverChannelNoMatchingEpoch NS_SWIFT_NAME(unableToRecoverChannelNoMatchingEpoch) = 90005, + ARTErrorUnableToRecoverChannelUnboundedRequest NS_SWIFT_NAME(unableToRecoverChannelUnboundedRequest) = 90006, + ARTErrorChannelOperationFailedNoResponseFromServer NS_SWIFT_NAME(channelOperationFailedNoResponseFromServer) = 90007, + ARTErrorMaxNumberOfChannelsPerConnectionExceeded NS_SWIFT_NAME(maxNumberOfChannelsPerConnectionExceeded) = 90010, + ARTErrorUnableToEnterPresenceChannelNoClientid NS_SWIFT_NAME(unableToEnterPresenceChannelNoClientid) = 91000, + ARTErrorUnableToEnterPresenceChannelInvalidState NS_SWIFT_NAME(unableToEnterPresenceChannelInvalidState) = 91001, + ARTErrorUnableToLeavePresenceChannelThatIsNotEntered NS_SWIFT_NAME(unableToLeavePresenceChannelThatIsNotEntered) = 91002, + ARTErrorUnableToEnterPresenceChannelMaxMemberLimitExceeded NS_SWIFT_NAME(unableToEnterPresenceChannelMaxMemberLimitExceeded) = 91003, + ARTErrorUnableToAutomaticallyReEnterPresenceChannel NS_SWIFT_NAME(unableToAutomaticallyReEnterPresenceChannel) = 91004, + ARTErrorPresenceStateIsOutOfSync NS_SWIFT_NAME(presenceStateIsOutOfSync) = 91005, + ARTErrorMemberImplicitlyLeftPresenceChannel NS_SWIFT_NAME(memberImplicitlyLeftPresenceChannel) = 91100, }; + /** The list of all client error codes returned under the error domain ARTAblyErrorDomain */ typedef CF_ENUM(NSUInteger, ARTClientCodeError) { - ARTClientCodeErrorInvalidType, - ARTClientCodeErrorTransport, -}; + ARTClientCodeErrorInvalidType NS_SWIFT_NAME(invalidType), + ARTClientCodeErrorTransport NS_SWIFT_NAME(transport), +} NS_SWIFT_NAME(ClientCodeError); NS_ASSUME_NONNULL_BEGIN @@ -189,6 +190,7 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; * * @see For possible `NSError.code` see Ably [error codes](https://github.com/ably/ably-common/blob/main/protocol/errors.json). */ +NS_SWIFT_NAME(ErrorInfo) @interface ARTErrorInfo : NSError /** @@ -257,6 +259,7 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; * :nodoc: TODO: docstring * An object representing a status of an operation. */ +NS_SWIFT_NAME(Status) @interface ARTStatus : NSObject @property (nullable, readonly, nonatomic) ARTErrorInfo *errorInfo; diff --git a/Source/include/Ably/ARTStringifiable.h b/Source/include/Ably/ARTStringifiable.h index 8f598fd6d..c13ad546b 100644 --- a/Source/include/Ably/ARTStringifiable.h +++ b/Source/include/Ably/ARTStringifiable.h @@ -4,6 +4,7 @@ NS_ASSUME_NONNULL_BEGIN /// :nodoc: +NS_SWIFT_NAME(Stringifiable) @interface ARTStringifiable : NSObject - (instancetype)init UNAVAILABLE_ATTRIBUTE; diff --git a/Source/include/Ably/ARTTypes.h b/Source/include/Ably/ARTTypes.h index afdcda17a..86b4af14c 100644 --- a/Source/include/Ably/ARTTypes.h +++ b/Source/include/Ably/ARTTypes.h @@ -19,34 +19,34 @@ @protocol ARTTokenDetailsCompatible; /// :nodoc: -typedef NSDictionary ARTJsonObject; +typedef NSDictionary ARTJsonObject NS_SWIFT_NAME(JsonObject); /// :nodoc: -typedef NSString ARTDeviceId; +typedef NSString ARTDeviceId NS_SWIFT_NAME(DeviceId); /// :nodoc: -typedef NSString ARTDeviceSecret; +typedef NSString ARTDeviceSecret NS_SWIFT_NAME(DeviceSecret); /// :nodoc: -typedef NSData ARTDeviceToken; +typedef NSData ARTDeviceToken NS_SWIFT_NAME(DeviceToken); /// :nodoc: -typedef ARTJsonObject ARTPushRecipient; +typedef ARTJsonObject ARTPushRecipient NS_SWIFT_NAME(PushRecipient); /// :nodoc: typedef NS_ENUM(NSUInteger, ARTAuthentication) { - ARTAuthenticationOff, - ARTAuthenticationOn, - ARTAuthenticationUseBasic, - ARTAuthenticationNewToken, - ARTAuthenticationTokenRetry -}; + ARTAuthenticationOff NS_SWIFT_NAME(off), + ARTAuthenticationOn NS_SWIFT_NAME(on), + ARTAuthenticationUseBasic NS_SWIFT_NAME(useBasic), + ARTAuthenticationNewToken NS_SWIFT_NAME(newToken), + ARTAuthenticationTokenRetry NS_SWIFT_NAME(tokenRetry) +} NS_SWIFT_NAME(Authentication); /// :nodoc: typedef NS_ENUM(NSUInteger, ARTAuthMethod) { - ARTAuthMethodBasic, - ARTAuthMethodToken -}; + ARTAuthMethodBasic NS_SWIFT_NAME(basic), + ARTAuthMethodToken NS_SWIFT_NAME(token) +} NS_SWIFT_NAME(AuthMethod); /** * Describes the realtime `ARTConnection` object states. @@ -55,60 +55,60 @@ typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionState) { /** * A connection with this state has been initialized but no connection has yet been attempted. */ - ARTRealtimeInitialized, + ARTRealtimeInitialized NS_SWIFT_NAME(initialized), /** * A connection attempt has been initiated. The connecting state is entered as soon as the library has completed initialization, and is reentered each time connection is re-attempted following disconnection. */ - ARTRealtimeConnecting, + ARTRealtimeConnecting NS_SWIFT_NAME(connecting), /** * A connection exists and is active. */ - ARTRealtimeConnected, + ARTRealtimeConnected NS_SWIFT_NAME(connected), /** * A temporary failure condition. No current connection exists because there is no network connectivity or no host is available. The disconnected state is entered if an established connection is dropped, or if a connection attempt was unsuccessful. In the disconnected state the library will periodically attempt to open a new connection (approximately every 15 seconds), anticipating that the connection will be re-established soon and thus connection and channel continuity will be possible. In this state, developers can continue to publish messages as they are automatically placed in a local queue, to be sent as soon as a connection is reestablished. Messages published by other clients while this client is disconnected will be delivered to it upon reconnection, so long as the connection was resumed within 2 minutes. After 2 minutes have elapsed, recovery is no longer possible and the connection will move to the `ARTRealtimeSuspended` state. */ - ARTRealtimeDisconnected, + ARTRealtimeDisconnected NS_SWIFT_NAME(disconnected), /** * A long term failure condition. No current connection exists because there is no network connectivity or no host is available. The suspended state is entered after a failed connection attempt if there has then been no connection for a period of two minutes. In the suspended state, the library will periodically attempt to open a new connection every 30 seconds. Developers are unable to publish messages in this state. A new connection attempt can also be triggered by an explicit call to `-[ARTConnectionProtocol connect]`. Once the connection has been re-established, channels will be automatically re-attached. The client has been disconnected for too long for them to resume from where they left off, so if it wants to catch up on messages published by other clients while it was disconnected, it needs to use the [History API](https://ably.com/docs/realtime/history). */ - ARTRealtimeSuspended, + ARTRealtimeSuspended NS_SWIFT_NAME(suspended), /** * An explicit request by the developer to close the connection has been sent to the Ably service. If a reply is not received from Ably within a short period of time, the connection is forcibly terminated and the connection state becomes `ARTRealtimeClosed`. */ - ARTRealtimeClosing, + ARTRealtimeClosing NS_SWIFT_NAME(closing), /** * The connection has been explicitly closed by the client. In the closed state, no reconnection attempts are made automatically by the library, and clients may not publish messages. No connection state is preserved by the service or by the library. A new connection attempt can be triggered by an explicit call to `-[ARTConnectionProtocol connect]`, which results in a new connection. */ - ARTRealtimeClosed, + ARTRealtimeClosed NS_SWIFT_NAME(closed), /** * This state is entered if the client library encounters a failure condition that it cannot recover from. This may be a fatal connection error received from the Ably service, for example an attempt to connect with an incorrect API key, or a local terminal error, for example the token in use has expired and the library does not have any way to renew it. In the failed state, no reconnection attempts are made automatically by the library, and clients may not publish messages. A new connection attempt can be triggered by an explicit call to `-[ARTConnectionProtocol connect]`. */ - ARTRealtimeFailed -}; + ARTRealtimeFailed NS_SWIFT_NAME(failed) +} NS_SWIFT_NAME(RealtimeConnectionState); /// :nodoc: -NSString *_Nonnull ARTRealtimeConnectionStateToStr(ARTRealtimeConnectionState state); +NSString * _Nonnull ARTRealtimeConnectionStateToStr(ARTRealtimeConnectionState state) NS_SWIFT_NAME(RealtimeConnectionStateToStr(_:)); /** * Describes the events emitted by a `ARTConnection` object. An event is either an `ARTRealtimeConnectionEventUpdate` or an `ARTRealtimeConnectionState`. */ typedef NS_ENUM(NSUInteger, ARTRealtimeConnectionEvent) { - ARTRealtimeConnectionEventInitialized, - ARTRealtimeConnectionEventConnecting, - ARTRealtimeConnectionEventConnected, - ARTRealtimeConnectionEventDisconnected, - ARTRealtimeConnectionEventSuspended, - ARTRealtimeConnectionEventClosing, - ARTRealtimeConnectionEventClosed, - ARTRealtimeConnectionEventFailed, + ARTRealtimeConnectionEventInitialized NS_SWIFT_NAME(initialized), + ARTRealtimeConnectionEventConnecting NS_SWIFT_NAME(connecting), + ARTRealtimeConnectionEventConnected NS_SWIFT_NAME(connected), + ARTRealtimeConnectionEventDisconnected NS_SWIFT_NAME(disconnected), + ARTRealtimeConnectionEventSuspended NS_SWIFT_NAME(suspended), + ARTRealtimeConnectionEventClosing NS_SWIFT_NAME(closing), + ARTRealtimeConnectionEventClosed NS_SWIFT_NAME(closed), + ARTRealtimeConnectionEventFailed NS_SWIFT_NAME(failed), /** * An event for changes to connection conditions for which the `ARTRealtimeConnectionState` does not change. */ - ARTRealtimeConnectionEventUpdate -}; + ARTRealtimeConnectionEventUpdate NS_SWIFT_NAME(update) +} NS_SWIFT_NAME(RealtimeConnectionEvent); /// :nodoc: -NSString *_Nonnull ARTRealtimeConnectionEventToStr(ARTRealtimeConnectionEvent event); +NSString *_Nonnull ARTRealtimeConnectionEventToStr(ARTRealtimeConnectionEvent event) NS_SWIFT_NAME(RealtimeConnectionEventToStr(_:)); /** * Describes the possible states of an `ARTRealtimeChannel` object. @@ -117,77 +117,76 @@ typedef NS_ENUM(NSUInteger, ARTRealtimeChannelState) { /** * The channel has been initialized but no attach has yet been attempted. */ - ARTRealtimeChannelInitialized, + ARTRealtimeChannelInitialized NS_SWIFT_NAME(initialized), /** * An attach has been initiated by sending a request to Ably. This is a transient state, followed either by a transition to `ARTRealtimeChannelAttached`, `ARTRealtimeChannelSuspended`, or `ARTRealtimeChannelFailed`. */ - ARTRealtimeChannelAttaching, + ARTRealtimeChannelAttaching NS_SWIFT_NAME(attaching), /** * The attach has succeeded. In the attached state a client may publish and subscribe to messages, or be present on the channel. */ - ARTRealtimeChannelAttached, + ARTRealtimeChannelAttached NS_SWIFT_NAME(attached), /** * A detach has been initiated on an `ARTRealtimeChannelAttached` channel by sending a request to Ably. This is a transient state, followed either by a transition to `ARTRealtimeChannelDetached` or `ARTRealtimeChannelFailed`. */ - ARTRealtimeChannelDetaching, + ARTRealtimeChannelDetaching NS_SWIFT_NAME(detaching), /** * The channel, having previously been `ARTRealtimeChannelAttached`, has been detached by the user. */ - ARTRealtimeChannelDetached, + ARTRealtimeChannelDetached NS_SWIFT_NAME(detached), /** * The channel, having previously been `ARTRealtimeChannelAttached`, has lost continuity, usually due to the client being disconnected from Ably for longer than two minutes. It will automatically attempt to reattach as soon as connectivity is restored. */ - ARTRealtimeChannelSuspended, + ARTRealtimeChannelSuspended NS_SWIFT_NAME(suspended), /** * An indefinite failure condition. This state is entered if a channel error has been received from the Ably service, such as an attempt to attach without the necessary access rights. */ - ARTRealtimeChannelFailed -}; + ARTRealtimeChannelFailed NS_SWIFT_NAME(failed) +} NS_SWIFT_NAME(RealtimeChannelState); /// :nodoc: -NSString *_Nonnull ARTRealtimeChannelStateToStr(ARTRealtimeChannelState state); +NSString *_Nonnull ARTRealtimeChannelStateToStr(ARTRealtimeChannelState state) NS_SWIFT_NAME(RealtimeChannelStateToStr(_:)); /** * Describes the events emitted by an `ARTRealtimeChannel` object. An event is either an `ARTChannelEventUpdate` or a `ARTRealtimeChannelState`. */ typedef NS_ENUM(NSUInteger, ARTChannelEvent) { - ARTChannelEventInitialized, - ARTChannelEventAttaching, - ARTChannelEventAttached, - ARTChannelEventDetaching, - ARTChannelEventDetached, - ARTChannelEventSuspended, - ARTChannelEventFailed, + ARTChannelEventInitialized NS_SWIFT_NAME(initialized), + ARTChannelEventAttaching NS_SWIFT_NAME(attaching), + ARTChannelEventAttached NS_SWIFT_NAME(attached), + ARTChannelEventDetaching NS_SWIFT_NAME(detaching), + ARTChannelEventDetached NS_SWIFT_NAME(detached), + ARTChannelEventSuspended NS_SWIFT_NAME(suspended), + ARTChannelEventFailed NS_SWIFT_NAME(failed), /** * An event for changes to channel conditions that do not result in a change in `ARTRealtimeChannelState`. */ - ARTChannelEventUpdate -}; + ARTChannelEventUpdate NS_SWIFT_NAME(update) +} NS_SWIFT_NAME(ChannelEvent); /// :nodoc: -NSString *_Nonnull ARTChannelEventToStr(ARTChannelEvent event); - +NSString *_Nonnull ARTChannelEventToStr(ARTChannelEvent event) NS_SWIFT_NAME(ChannelEventToStr(_:)); /// :nodoc: typedef NS_ENUM(NSInteger, ARTDataQueryError) { - ARTDataQueryErrorLimit = 1, - ARTDataQueryErrorTimestampRange = 2, - ARTDataQueryErrorMissingRequiredFields = 3, - ARTDataQueryErrorInvalidParameters = 4, - ARTDataQueryErrorDeviceInactive = 5, -}; + ARTDataQueryErrorLimit NS_SWIFT_NAME(limit) = 1, + ARTDataQueryErrorTimestampRange NS_SWIFT_NAME(timestampRange) = 2, + ARTDataQueryErrorMissingRequiredFields NS_SWIFT_NAME(missingRequiredFields) = 3, + ARTDataQueryErrorInvalidParameters NS_SWIFT_NAME(invalidParameters) = 4, + ARTDataQueryErrorDeviceInactive NS_SWIFT_NAME(deviceInactive) = 5, +} NS_SWIFT_NAME(DataQueryError); /// :nodoc: typedef NS_ENUM(NSInteger, ARTRealtimeHistoryError) { - ARTRealtimeHistoryErrorNotAttached = ARTDataQueryErrorTimestampRange + 1 -}; + ARTRealtimeHistoryErrorNotAttached NS_SWIFT_NAME(notAttached) = ARTDataQueryErrorTimestampRange + 1 +} NS_SWIFT_NAME(RealtimeHistoryError); /// :nodoc: typedef NS_ENUM(NSInteger, ARTCustomRequestError) { - ARTCustomRequestErrorInvalidMethod = 1, - ARTCustomRequestErrorInvalidBody = 2, - ARTCustomRequestErrorInvalidPath = 3, -}; + ARTCustomRequestErrorInvalidMethod NS_SWIFT_NAME(invalidMethod) = 1, + ARTCustomRequestErrorInvalidBody NS_SWIFT_NAME(invalidBody) = 2, + ARTCustomRequestErrorInvalidPath NS_SWIFT_NAME(invalidPath) = 3, +} NS_SWIFT_NAME(CustomRequestError); NS_ASSUME_NONNULL_BEGIN @@ -214,6 +213,7 @@ NSTimeInterval millisecondsToTimeInterval(uint64_t msecs); NSString *generateNonce(void); /// :nodoc: +NS_SWIFT_NAME(Cancellable) @protocol ARTCancellable - (void)cancel; @end @@ -221,6 +221,7 @@ NSString *generateNonce(void); /** * Contains `ARTRealtimeConnectionState` change information emitted by the `ARTConnection` object. */ +NS_SWIFT_NAME(ConnectionStateChange) @interface ARTConnectionStateChange : NSObject /// :nodoc: @@ -264,6 +265,7 @@ NSString *generateNonce(void); /** * Contains state change information emitted by an `ARTRealtimeChannel` object. */ +NS_SWIFT_NAME(ChannelStateChange) @interface ARTChannelStateChange : NSObject /// :nodoc: @@ -309,6 +311,7 @@ NSString *generateNonce(void); /** * Contains the metrics associated with a `ARTRestChannel` or `ARTRealtimeChannel`, such as the number of publishers, subscribers and connections it has. */ +NS_SWIFT_NAME(ChannelMetrics) @interface ARTChannelMetrics : NSObject /** @@ -354,6 +357,7 @@ NSString *generateNonce(void); /** * Contains the metrics of a `ARTRestChannel` or `ARTRealtimeChannel` object. */ +NS_SWIFT_NAME(ChannelOccupancy) @interface ARTChannelOccupancy : NSObject /** @@ -369,6 +373,7 @@ NSString *generateNonce(void); /** * Contains the status of a `ARTRestChannel` or `ARTRealtimeChannel` object such as whether it is active and its `ARTChannelOccupancy`. */ +NS_SWIFT_NAME(ChannelStatus) @interface ARTChannelStatus : NSObject /** @@ -389,6 +394,7 @@ NSString *generateNonce(void); /** * Contains the details of a `ARTRestChannel` or `ARTRealtimeChannel` object such as its ID and `ARTChannelStatus`. */ +NS_SWIFT_NAME(ChannelDetails) @interface ARTChannelDetails : NSObject /** @@ -407,6 +413,7 @@ NSString *generateNonce(void); @end /// :nodoc: +NS_SWIFT_NAME(JsonCompatible) @protocol ARTJsonCompatible - (NSDictionary *_Nullable)toJSON:(NSError *_Nullable *_Nullable)error; - (NSString *_Nullable)toJSONString; @@ -441,14 +448,14 @@ NSString *generateNonce(void); /// :nodoc: @interface NSDictionary (ARTURLQueryItemAdditions) -@property (nonatomic, readonly) NSArray *art_asURLQueryItems; +@property (nonatomic, readonly) NSArray *art_asURLQueryItems NS_SWIFT_NAME(asURLQueryItems); @end /// :nodoc: @interface NSMutableArray (ARTQueueAdditions) -- (void)art_enqueue:(id)object; -- (nullable id)art_dequeue; -- (nullable id)art_peek; +- (void)art_enqueue:(id)object NS_SWIFT_NAME(enqueue(_:)); +- (nullable id)art_dequeue NS_SWIFT_NAME(dequeue()); +- (nullable id)art_peek NS_SWIFT_NAME(peek()); @end /// :nodoc: @@ -462,70 +469,70 @@ typedef NSDictionary NSStringDictionary; // Either result/response or error can be nil but not both. /// :nodoc: -typedef void (^ARTCallback)(ARTErrorInfo *_Nullable error); +typedef void (^ARTCallback)(ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(Callback); /// :nodoc: -typedef void (^ARTResultCallback)(id _Nullable result, NSError *_Nullable error); +typedef void (^ARTResultCallback)(id _Nullable result, NSError *_Nullable error) NS_SWIFT_NAME(ResultCallback); /// :nodoc: -typedef void (^ARTDateTimeCallback)(NSDate *_Nullable result, NSError *_Nullable error); +typedef void (^ARTDateTimeCallback)(NSDate *_Nullable result, NSError *_Nullable error) NS_SWIFT_NAME(DataTimeCallback); /// :nodoc: -typedef void (^ARTMessageCallback)(ARTMessage *message); +typedef void (^ARTMessageCallback)(ARTMessage *message) NS_SWIFT_NAME(MessageCallback); /// :nodoc: -typedef void (^ARTChannelStateCallback)(ARTChannelStateChange *stateChange); +typedef void (^ARTChannelStateCallback)(ARTChannelStateChange *stateChange) NS_SWIFT_NAME(ChannelStateCallback); /// :nodoc: -typedef void (^ARTConnectionStateCallback)(ARTConnectionStateChange *stateChange); +typedef void (^ARTConnectionStateCallback)(ARTConnectionStateChange *stateChange) NS_SWIFT_NAME(ConnectionStateCallback); /// :nodoc: -typedef void (^ARTPresenceMessageCallback)(ARTPresenceMessage *message); +typedef void (^ARTPresenceMessageCallback)(ARTPresenceMessage *message) NS_SWIFT_NAME(PresenceMessageCallback); /// :nodoc: -typedef void (^ARTPresenceMessageErrorCallback)(ARTPresenceMessage *message, ARTErrorInfo *_Nullable error); +typedef void (^ARTPresenceMessageErrorCallback)(ARTPresenceMessage *message, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PresenceMessageErrorCallback); /// :nodoc: -typedef void (^ARTPresenceMessagesCallback)(NSArray *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPresenceMessagesCallback)(NSArray *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PresenceMessagesCallback); /// :nodoc: -typedef void (^ARTChannelDetailsCallback)(ARTChannelDetails *_Nullable details, ARTErrorInfo *_Nullable error); +typedef void (^ARTChannelDetailsCallback)(ARTChannelDetails *_Nullable details, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(ChannelDetailsCallback); /// :nodoc: -typedef void (^ARTStatusCallback)(ARTStatus *status); +typedef void (^ARTStatusCallback)(ARTStatus *status) NS_SWIFT_NAME(StatusCallback); /// :nodoc: -typedef void (^ARTURLRequestCallback)(NSHTTPURLResponse *_Nullable result, NSData *_Nullable data, NSError *_Nullable error); +typedef void (^ARTURLRequestCallback)(NSHTTPURLResponse *_Nullable result, NSData *_Nullable data, NSError *_Nullable error) NS_SWIFT_NAME(URLRequestCallback); /// :nodoc: -typedef void (^ARTTokenDetailsCallback)(ARTTokenDetails *_Nullable result, NSError *_Nullable error); +typedef void (^ARTTokenDetailsCallback)(ARTTokenDetails *_Nullable result, NSError *_Nullable error) NS_SWIFT_NAME(TokenDetailsCallback); /// :nodoc: -typedef void (^ARTTokenDetailsCompatibleCallback)(id _Nullable result, NSError *_Nullable error); +typedef void (^ARTTokenDetailsCompatibleCallback)(id _Nullable result, NSError *_Nullable error) NS_SWIFT_NAME(TokenDetailsCompatibleCallback); /// :nodoc: -typedef void (^ARTAuthCallback)(ARTTokenParams *params, ARTTokenDetailsCompatibleCallback callback); +typedef void (^ARTAuthCallback)(ARTTokenParams *params, ARTTokenDetailsCompatibleCallback callback) NS_SWIFT_NAME(AuthCallback); /// :nodoc: -typedef void (^ARTHTTPPaginatedCallback)(ARTHTTPPaginatedResponse *_Nullable response, ARTErrorInfo *_Nullable error); +typedef void (^ARTHTTPPaginatedCallback)(ARTHTTPPaginatedResponse *_Nullable response, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(HTTPPaginatedCallback); /// :nodoc: -typedef void (^ARTPaginatedStatsCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedStatsCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedStatsCallback); /// :nodoc: -typedef void (^ARTPaginatedPresenceCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedPresenceCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedPresenceCallback); /// :nodoc: -typedef void (^ARTPaginatedPushChannelCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedPushChannelCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedPushChannelCallback); /// :nodoc: -typedef void (^ARTPaginatedMessagesCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedMessagesCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedMessagesCallback); /// :nodoc: -typedef void (^ARTPaginatedDeviceDetailsCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedDeviceDetailsCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedDeviceDetailsCallback); /// :nodoc: -typedef void (^ARTPaginatedTextCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error); +typedef void (^ARTPaginatedTextCallback)(ARTPaginatedResult *_Nullable result, ARTErrorInfo *_Nullable error) NS_SWIFT_NAME(PaginatedTextCallback); /** * :nodoc: @@ -537,6 +544,7 @@ typedef void (^ARTPaginatedTextCallback)(ARTPaginatedResult *_Nullab * * To make use of these benefits the caller needs to use the returned wrapper to invoke the callback. The wrapper will only work for as long as the returned instance remains allocated (i.e. has a strong reference to it somewhere). */ -NSObject * artCancellableFromCallback(ARTResultCallback callback, _Nonnull ARTResultCallback *_Nonnull wrapper); +NSObject * artCancellableFromCallback(ARTResultCallback callback, _Nonnull ARTResultCallback *_Nonnull wrapper) NS_SWIFT_NAME(cancellable(from:wrapper:)); + NS_ASSUME_NONNULL_END diff --git a/Test/Test Utilities/MockDeviceStorage.swift b/Test/Test Utilities/MockDeviceStorage.swift index 1bbb4a751..3203c928f 100644 --- a/Test/Test Utilities/MockDeviceStorage.swift +++ b/Test/Test Utilities/MockDeviceStorage.swift @@ -1,6 +1,6 @@ import Ably -class MockDeviceStorage: NSObject, ARTDeviceStorage { +class MockDeviceStorage: NSObject, DeviceStorage { private let accessQueue = DispatchQueue(label: "io.ably.MockDeviceStorage") @@ -10,7 +10,7 @@ class MockDeviceStorage: NSObject, ARTDeviceStorage { private var simulateData: [String: Data] = [:] private var simulateString: [String: String] = [:] - init(startWith state: ARTPushActivationState? = nil) { + init(startWith state: PushActivationState? = nil) { super.init() if let state = state { simulateOnNextRead(data: state.archive(), for: ARTPushActivationCurrentStateKey) diff --git a/Test/Test Utilities/MockErrorChecker.swift b/Test/Test Utilities/MockErrorChecker.swift index efb666207..7417bc093 100644 --- a/Test/Test Utilities/MockErrorChecker.swift +++ b/Test/Test Utilities/MockErrorChecker.swift @@ -3,7 +3,7 @@ import Ably.Private class MockErrorChecker: ErrorChecker { var isTokenError: Bool! - func isTokenError(_ errorInfo: ARTErrorInfo) -> Bool { + func isTokenError(_ errorInfo: ErrorInfo) -> Bool { return isTokenError } } diff --git a/Test/Test Utilities/MockInternalLogCore.swift b/Test/Test Utilities/MockInternalLogCore.swift index 20a87ed94..046c2cce5 100644 --- a/Test/Test Utilities/MockInternalLogCore.swift +++ b/Test/Test Utilities/MockInternalLogCore.swift @@ -2,15 +2,15 @@ import Ably.Private @objc(ARTMockInternalLogCore) class MockInternalLogCore: NSObject, InternalLogCore { - var logLevel: ARTLogLevel = .none + var logLevel: LogLevel = .none - var lastReceivedLogMessageArguments: (message: String, level: ARTLogLevel, fileName: UnsafePointer, line: Int)? + var lastReceivedLogMessageArguments: (message: String, level: LogLevel, fileName: UnsafePointer, line: Int)? @objc var lastReceivedLogMessageArgumentMessage: String? - @objc var lastReceivedLogMessageArgumentLevel: ARTLogLevel = .none + @objc var lastReceivedLogMessageArgumentLevel: LogLevel = .none @objc var lastReceivedLogMessageArgumentFileName: UnsafePointer? @objc var lastReceivedLogMessageArgumentLine: Int = -1 - func log(_ message: String, with level: ARTLogLevel, file fileName: UnsafePointer, line: Int) { + func log(_ message: String, with level: LogLevel, file fileName: UnsafePointer, line: Int) { lastReceivedLogMessageArguments = (message: message, level: level, fileName: fileName, line: line) lastReceivedLogMessageArgumentMessage = message lastReceivedLogMessageArgumentLevel = level diff --git a/Test/Test Utilities/MockVersion2Log.swift b/Test/Test Utilities/MockVersion2Log.swift index d7328b2f0..0691edb96 100644 --- a/Test/Test Utilities/MockVersion2Log.swift +++ b/Test/Test Utilities/MockVersion2Log.swift @@ -1,11 +1,11 @@ import Ably.Private class MockVersion2Log: NSObject, Version2Log { - var logLevel: ARTLogLevel = .none + var logLevel: LogLevel = .none - var lastReceivedLogMessageArguments: (message: String, level: ARTLogLevel, fileName: String, line: Int)? + var lastReceivedLogMessageArguments: (message: String, level: LogLevel, fileName: String, line: Int)? - func log(_ message: String, with level: ARTLogLevel, file fileName: String, line: Int) { + func log(_ message: String, with level: LogLevel, file fileName: String, line: Int) { lastReceivedLogMessageArguments = (message: message, level: level, fileName: fileName, line: line) } } diff --git a/Test/Test Utilities/TestProxyTransportFactory.swift b/Test/Test Utilities/TestProxyTransportFactory.swift index d115ec6ef..2fc282cd3 100644 --- a/Test/Test Utilities/TestProxyTransportFactory.swift +++ b/Test/Test Utilities/TestProxyTransportFactory.swift @@ -9,7 +9,7 @@ class TestProxyTransportFactory: RealtimeTransportFactory { var transportCreatedEvent: ((ARTRealtimeTransport) -> Void)? - func transport(withRest rest: ARTRestInternal, options: ARTClientOptions, resumeKey: String?, logger: InternalLog) -> ARTRealtimeTransport { + func transport(withRest rest: ARTRestInternal, options: ClientOptions, resumeKey: String?, logger: InternalLog) -> ARTRealtimeTransport { let webSocketFactory = WebSocketFactory() let testProxyTransport = TestProxyTransport( diff --git a/Test/Test Utilities/TestUtilities.swift b/Test/Test Utilities/TestUtilities.swift index 09bb0ddac..21de8e333 100644 --- a/Test/Test Utilities/TestUtilities.swift +++ b/Test/Test Utilities/TestUtilities.swift @@ -67,7 +67,7 @@ class AblyTests { return encoded } - class func checkError(_ errorInfo: ARTErrorInfo?, withAlternative message: String) { + class func checkError(_ errorInfo: ErrorInfo?, withAlternative message: String) { if let error = errorInfo { XCTFail("\((error ).code): \(error.message)") } @@ -76,7 +76,7 @@ class AblyTests { } } - class func checkError(_ errorInfo: ARTErrorInfo?) { + class func checkError(_ errorInfo: ErrorInfo?) { checkError(errorInfo, withAlternative: "") } @@ -104,7 +104,7 @@ class AblyTests { return DispatchQueue.getSpecific(key: queueIdentityKey)?.label } - class func commonAppSetup(for test: Test, debug: Bool = false, forceNewApp: Bool = false) throws -> ARTClientOptions { + class func commonAppSetup(for test: Test, debug: Bool = false, forceNewApp: Bool = false) throws -> ClientOptions { let options = try AblyTests.clientOptions(for: test, debug: debug) options.testOptions.channelNamePrefix = "test-\(test.id)-\(UUID().uuidString)" @@ -141,8 +141,8 @@ class AblyTests { return options } - class func clientOptions(for test: Test, debug: Bool = false, key: String? = nil, requestToken: Bool = false) throws -> ARTClientOptions { - let options = ARTClientOptions() + class func clientOptions(for test: Test, debug: Bool = false, key: String? = nil, requestToken: Bool = false) throws -> ClientOptions { + let options = ClientOptions() options.environment = getEnvironment() if debug { options.logLevel = .verbose @@ -158,38 +158,38 @@ class AblyTests { return options } - class func newErrorProtocolMessage(message: String = "Fail test") -> ARTProtocolMessage { - let protocolMessage = ARTProtocolMessage() + class func newErrorProtocolMessage(message: String = "Fail test") -> ProtocolMessage { + let protocolMessage = ProtocolMessage() protocolMessage.action = .error - protocolMessage.error = ARTErrorInfo.create(withCode: 0, message: message) + protocolMessage.error = ErrorInfo.create(withCode: 0, message: message) return protocolMessage } - class func newPresenceProtocolMessage(id: String, channel: String, action: ARTPresenceAction, clientId: String, connectionId: String) -> ARTProtocolMessage { - let protocolMessage = ARTProtocolMessage() + class func newPresenceProtocolMessage(id: String, channel: String, action: PresenceAction, clientId: String, connectionId: String) -> ProtocolMessage { + let protocolMessage = ProtocolMessage() protocolMessage.action = .presence protocolMessage.channel = channel protocolMessage.timestamp = Date() protocolMessage.presence = [ - ARTPresenceMessage(clientId: clientId, action: action, connectionId: connectionId, id: id, timestamp: Date()) + PresenceMessage(clientId: clientId, action: action, connectionId: connectionId, id: id, timestamp: Date()) ] return protocolMessage } struct RealtimeTestEnvironment { - let client: ARTRealtime + let client: Realtime let transportFactory: TestProxyTransportFactory } - class func newRealtime(_ options: ARTClientOptions, onTransportCreated event: ((ARTRealtimeTransport) -> Void)? = nil) -> RealtimeTestEnvironment { - let modifiedOptions = options.copy() as! ARTClientOptions + class func newRealtime(_ options: ClientOptions, onTransportCreated event: ((ARTRealtimeTransport) -> Void)? = nil) -> RealtimeTestEnvironment { + let modifiedOptions = options.copy() as! ClientOptions let autoConnect = modifiedOptions.autoConnect modifiedOptions.autoConnect = false let transportFactory = TestProxyTransportFactory() transportFactory.transportCreatedEvent = event modifiedOptions.testOptions.transportFactory = transportFactory - let realtime = ARTRealtime(options: modifiedOptions) + let realtime = Realtime(options: modifiedOptions) realtime.internal.setReachabilityClass(TestReachability.self) if autoConnect { realtime.connect() @@ -201,8 +201,8 @@ class AblyTests { return ProcessInfo.processInfo.globallyUniqueString } - class func addMembersSequentiallyToChannel(_ channelName: String, members: Int = 1, startFrom: Int = 1, data: AnyObject? = nil, options: ARTClientOptions) -> ARTRealtime { - let client = ARTRealtime(options: options) + class func addMembersSequentiallyToChannel(_ channelName: String, members: Int = 1, startFrom: Int = 1, data: AnyObject? = nil, options: ClientOptions) -> Realtime { + let client = Realtime(options: options) let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -222,8 +222,8 @@ class AblyTests { return client } - class func addMembersSequentiallyToChannel(_ channelName: String, members: Int = 1, startFrom: Int = 1, data: AnyObject? = nil, options: ARTClientOptions, done: @escaping ()->()) -> ARTRealtime { - let client = ARTRealtime(options: options) + class func addMembersSequentiallyToChannel(_ channelName: String, members: Int = 1, startFrom: Int = 1, data: AnyObject? = nil, options: ClientOptions, done: @escaping ()->()) -> Realtime { + let client = Realtime(options: options) let channel = client.channels.get(channelName) class Total { @@ -411,7 +411,7 @@ func ==(lhs: ARTAuthOptions, rhs: ARTAuthOptions) -> Bool { lhs.key == rhs.key } -func ==(lhs: ARTJsonCompatible?, rhs: ARTJsonCompatible?) -> Bool { +func ==(lhs: JsonCompatible?, rhs: JsonCompatible?) -> Bool { guard let lhs = lhs else { return rhs == nil } @@ -429,10 +429,10 @@ func ==(lhs: ARTJsonCompatible?, rhs: ARTJsonCompatible?) -> Bool { class PublishTestMessage { - var completion: ((ARTErrorInfo?) -> Void)? = nil - var error: ARTErrorInfo? = nil + var completion: ((ErrorInfo?) -> Void)? = nil + var error: ErrorInfo? = nil - init(client: ARTRest, channelName: String, failOnError: Bool = true, completion: ((ARTErrorInfo?) -> Void)? = nil) { + init(client: Rest, channelName: String, failOnError: Bool = true, completion: ((ErrorInfo?) -> Void)? = nil) { client.channels.get(channelName).publish(nil, data: "message") { error in self.error = error if let callback = completion { @@ -444,9 +444,9 @@ class PublishTestMessage { } } - init(client: ARTRealtime, channelName: String, failOnError: Bool = true, completion: ((ARTErrorInfo?) -> Void)? = nil) { - let complete: (ARTErrorInfo?) -> Void = { errorInfo in - // ARTErrorInfo to NSError + init(client: Realtime, channelName: String, failOnError: Bool = true, completion: ((ErrorInfo?) -> Void)? = nil) { + let complete: (ErrorInfo?) -> Void = { errorInfo in + // ErrorInfo to NSError self.error = errorInfo if let callback = completion { @@ -481,23 +481,23 @@ class PublishTestMessage { } /// Rest - Publish message -@discardableResult func publishTestMessage(_ rest: ARTRest, channelName: String, completion: Optional<(ARTErrorInfo?)->()>) -> PublishTestMessage { +@discardableResult func publishTestMessage(_ rest: Rest, channelName: String, completion: Optional<(ErrorInfo?)->()>) -> PublishTestMessage { return PublishTestMessage(client: rest, channelName: channelName, failOnError: false, completion: completion) } -@discardableResult func publishTestMessage(_ rest: ARTRest, channelName: String, failOnError: Bool = true) -> PublishTestMessage { +@discardableResult func publishTestMessage(_ rest: Rest, channelName: String, failOnError: Bool = true) -> PublishTestMessage { return PublishTestMessage(client: rest, channelName: channelName, failOnError: failOnError) } /// Realtime - Publish message with callback /// (publishes if connection state changes to CONNECTED and channel state changes to ATTACHED) -@discardableResult func publishFirstTestMessage(_ realtime: ARTRealtime, channelName: String, completion: Optional<(ARTErrorInfo?)->()>) -> PublishTestMessage { +@discardableResult func publishFirstTestMessage(_ realtime: Realtime, channelName: String, completion: Optional<(ErrorInfo?)->()>) -> PublishTestMessage { return PublishTestMessage(client: realtime, channelName: channelName, failOnError: false, completion: completion) } /// Realtime - Publish message /// (publishes if connection state changes to CONNECTED and channel state changes to ATTACHED) -@discardableResult func publishFirstTestMessage(_ realtime: ARTRealtime, channelName: String, failOnError: Bool = true) -> PublishTestMessage { +@discardableResult func publishFirstTestMessage(_ realtime: Realtime, channelName: String, failOnError: Bool = true) -> PublishTestMessage { return PublishTestMessage(client: realtime, channelName: channelName, failOnError: failOnError) } @@ -514,7 +514,7 @@ func getTestToken(for test: Test, key: String? = nil, clientId: String? = nil, c /// Access TokenDetails func getTestTokenDetails(for test: Test, key: String? = nil, clientId: String? = nil, capability: String? = nil, ttl: TimeInterval? = nil, queryTime: Bool? = nil, completion: @escaping (Swift.Result) -> Void) { - let options: ARTClientOptions + let options: ClientOptions if let key = key { do { options = try AblyTests.clientOptions(for: test) @@ -536,7 +536,7 @@ func getTestTokenDetails(for test: Test, key: String? = nil, clientId: String? = options.queryTime = queryTime } - let client = ARTRest(options: options) + let client = Rest(options: options) var tokenParams: ARTTokenParams? = nil if let capability = capability { @@ -632,10 +632,10 @@ public func getEnvironment() -> String { return env } -public func buildMessagesThatExceedMaxMessageSize() -> [ARTMessage] { - var messages = [ARTMessage]() +public func buildMessagesThatExceedMaxMessageSize() -> [Message] { + var messages = [Message]() for index in 0...5000 { - let m = ARTMessage(name: "name-\(index)", data: "data-\(index)") + let m = Message(name: "name-\(index)", data: "data-\(index)") messages.append(m) } return messages @@ -829,7 +829,7 @@ class MockHTTP: ARTHttp { } } - override public func execute(_ request: URLRequest, completion callback: ((HTTPURLResponse?, Data?, Error?) -> Void)? = nil) -> (ARTCancellable & NSObjectProtocol)? { + override public func execute(_ request: URLRequest, completion callback: ((HTTPURLResponse?, Data?, Error?) -> Void)? = nil) -> (Cancellable & NSObjectProtocol)? { queue.async { switch self.rule { case .none: @@ -915,19 +915,19 @@ class MockHTTPExecutor: NSObject, ARTHTTPAuthenticatedExecutor { fileprivate var errorSimulator: NSError? private(set) var logger = InternalLog(logger: MockVersion2Log()) - var clientOptions = ARTClientOptions() + var clientOptions = ClientOptions() var encoder = ARTJsonLikeEncoder() var requests: [URLRequest] = [] - func options() -> ARTClientOptions { + func options() -> ClientOptions { return self.clientOptions } - func defaultEncoder() -> ARTEncoder { + func defaultEncoder() -> Encoder { return self.encoder } - func execute(_ request: NSMutableURLRequest, withAuthOption authOption: ARTAuthentication, completion callback: @escaping (HTTPURLResponse?, Data?, Error?) -> Void) -> (ARTCancellable & NSObjectProtocol)? { + func execute(_ request: NSMutableURLRequest, withAuthOption authOption: Authentication, completion callback: @escaping (HTTPURLResponse?, Data?, Error?) -> Void) -> (Cancellable & NSObjectProtocol)? { self.requests.append(request as URLRequest) if let simulatedError = errorSimulator, var _ = request.url { @@ -940,7 +940,7 @@ class MockHTTPExecutor: NSObject, ARTHTTPAuthenticatedExecutor { return nil } - func execute(_ request: URLRequest, completion callback: ((HTTPURLResponse?, Data?, Error?) -> Void)? = nil) -> (ARTCancellable & NSObjectProtocol)? { + func execute(_ request: URLRequest, completion callback: ((HTTPURLResponse?, Data?, Error?) -> Void)? = nil) -> (Cancellable & NSObjectProtocol)? { self.requests.append(request) if let simulatedError = errorSimulator, var _ = request.url { @@ -1029,7 +1029,7 @@ class TestProxyHTTPExecutor: NSObject, ARTHTTPExecutor { } } - public func execute(_ request: URLRequest, completion callback: HTTPExecutorCallback? = nil) -> (ARTCancellable & NSObjectProtocol)? { + public func execute(_ request: URLRequest, completion callback: HTTPExecutorCallback? = nil) -> (Cancellable & NSObjectProtocol)? { self._requests.append(request) if let performEvent = callbackBeforeRequest { @@ -1112,34 +1112,34 @@ class TestProxyTransport: ARTWebSocketTransport { return _factory } - init(factory: TestProxyTransportFactory, rest: ARTRestInternal, options: ARTClientOptions, resumeKey: String?, logger: InternalLog, webSocketFactory: WebSocketFactory) { + init(factory: TestProxyTransportFactory, rest: ARTRestInternal, options: ClientOptions, resumeKey: String?, logger: InternalLog, webSocketFactory: WebSocketFactory) { self._factory = factory super.init(rest: rest, options: options, resumeKey: resumeKey, logger: logger, webSocketFactory: webSocketFactory) } fileprivate(set) var lastUrl: URL? - private var _protocolMessagesReceived: [ARTProtocolMessage] = [] - var protocolMessagesReceived: [ARTProtocolMessage] { - var result: [ARTProtocolMessage] = [] + private var _protocolMessagesReceived: [ProtocolMessage] = [] + var protocolMessagesReceived: [ProtocolMessage] { + var result: [ProtocolMessage] = [] queue.sync { result = self._protocolMessagesReceived } return result } - private var _protocolMessagesSent: [ARTProtocolMessage] = [] - var protocolMessagesSent: [ARTProtocolMessage] { - var result: [ARTProtocolMessage] = [] + private var _protocolMessagesSent: [ProtocolMessage] = [] + var protocolMessagesSent: [ProtocolMessage] { + var result: [ProtocolMessage] = [] queue.sync { result = self._protocolMessagesSent } return result } - private var _protocolMessagesSentIgnored: [ARTProtocolMessage] = [] - var protocolMessagesSentIgnored: [ARTProtocolMessage] { - var result: [ARTProtocolMessage] = [] + private var _protocolMessagesSentIgnored: [ProtocolMessage] = [] + var protocolMessagesSentIgnored: [ProtocolMessage] { + var result: [ProtocolMessage] = [] queue.sync { result = self._protocolMessagesSentIgnored } @@ -1149,21 +1149,21 @@ class TestProxyTransport: ARTWebSocketTransport { fileprivate(set) var rawDataSent = [Data]() fileprivate(set) var rawDataReceived = [Data]() - private var replacingAcksWithNacks: ARTErrorInfo? + private var replacingAcksWithNacks: ErrorInfo? var ignoreWebSocket = false var ignoreSends = false - var actionsIgnored = [ARTProtocolMessageAction]() + var actionsIgnored = [ProtocolMessageAction]() var queue: DispatchQueue { return websocket?.delegateDispatchQueue ?? AblyTests.queue } - private var callbackBeforeProcessingIncomingMessage: ((ARTProtocolMessage) -> Void)? - private var callbackAfterProcessingIncomingMessage: ((ARTProtocolMessage) -> Void)? - private var callbackBeforeProcessingOutgoingMessage: ((ARTProtocolMessage) -> Void)? - private var callbackBeforeIncomingMessageModifier: ((ARTProtocolMessage) -> ARTProtocolMessage?)? - private var callbackAfterIncomingMessageModifier: ((ARTProtocolMessage) -> ARTProtocolMessage?)? + private var callbackBeforeProcessingIncomingMessage: ((ProtocolMessage) -> Void)? + private var callbackAfterProcessingIncomingMessage: ((ProtocolMessage) -> Void)? + private var callbackBeforeProcessingOutgoingMessage: ((ProtocolMessage) -> Void)? + private var callbackBeforeIncomingMessageModifier: ((ProtocolMessage) -> ProtocolMessage?)? + private var callbackAfterIncomingMessageModifier: ((ProtocolMessage) -> ProtocolMessage?)? // Represents a request to replace the implementation of a method. private class Hook { @@ -1183,19 +1183,19 @@ class TestProxyTransport: ARTWebSocketTransport { /// Used for synchronising access to webSocketOpenHook. private let webSocketOpenHookSempahore = DispatchSemaphore(value: 1) - func setListenerBeforeProcessingIncomingMessage(_ callback: ((ARTProtocolMessage) -> Void)?) { + func setListenerBeforeProcessingIncomingMessage(_ callback: ((ProtocolMessage) -> Void)?) { queue.sync { self.callbackBeforeProcessingIncomingMessage = callback } } - func setListenerAfterProcessingIncomingMessage(_ callback: ((ARTProtocolMessage) -> Void)?) { + func setListenerAfterProcessingIncomingMessage(_ callback: ((ProtocolMessage) -> Void)?) { queue.sync { self.callbackAfterProcessingIncomingMessage = callback } } - func setListenerBeforeProcessingOutgoingMessage(_ callback: ((ARTProtocolMessage) -> Void)?) { + func setListenerBeforeProcessingOutgoingMessage(_ callback: ((ProtocolMessage) -> Void)?) { queue.sync { self.callbackBeforeProcessingOutgoingMessage = callback } @@ -1204,18 +1204,18 @@ class TestProxyTransport: ARTWebSocketTransport { /// The modifier will be called on the internal queue. /// /// If `callback` returns nil, the message will be ignored. - func setBeforeIncomingMessageModifier(_ callback: ((ARTProtocolMessage) -> ARTProtocolMessage?)?) { + func setBeforeIncomingMessageModifier(_ callback: ((ProtocolMessage) -> ProtocolMessage?)?) { self.callbackBeforeIncomingMessageModifier = callback } /// The modifier will be called on the internal queue. /// /// If `callback` returns nil, the message will be ignored. - func setAfterIncomingMessageModifier(_ callback: ((ARTProtocolMessage) -> ARTProtocolMessage?)?) { + func setAfterIncomingMessageModifier(_ callback: ((ProtocolMessage) -> ProtocolMessage?)?) { self.callbackAfterIncomingMessageModifier = callback } - func enableReplaceAcksWithNacks(with errorInfo: ARTErrorInfo) { + func enableReplaceAcksWithNacks(with errorInfo: ErrorInfo) { queue.sync { self.replacingAcksWithNacks = errorInfo } @@ -1334,13 +1334,13 @@ class TestProxyTransport: ARTWebSocketTransport { } } - override func setupWebSocket(_ params: [String: URLQueryItem], with options: ARTClientOptions, resumeKey: String?) -> URL { + override func setupWebSocket(_ params: [String: URLQueryItem], with options: ClientOptions, resumeKey: String?) -> URL { let url = super.setupWebSocket(params, with: options, resumeKey: resumeKey) lastUrl = url return url } - func send(_ message: ARTProtocolMessage) { + func send(_ message: ProtocolMessage) { let data = try! encoder.encode(message) send(data, withSource: message) } @@ -1353,7 +1353,7 @@ class TestProxyTransport: ARTWebSocketTransport { return false } - if let msg = decodedObject as? ARTProtocolMessage { + if let msg = decodedObject as? ProtocolMessage { if ignoreSends { _protocolMessagesSentIgnored.append(msg) return false @@ -1369,7 +1369,7 @@ class TestProxyTransport: ARTWebSocketTransport { return super.send(data, withSource: decodedObject) } - override func receive(_ original: ARTProtocolMessage) { + override func receive(_ original: ProtocolMessage) { if original.action == .ack || original.action == .presence { if let error = replacingAcksWithNacks { original.action = .nack @@ -1406,7 +1406,7 @@ class TestProxyTransport: ARTWebSocketTransport { } } - override func receive(with data: Data) -> ARTProtocolMessage? { + override func receive(with data: Data) -> ProtocolMessage? { rawDataReceived.append(data) return super.receive(with: data) } @@ -1445,7 +1445,7 @@ class TestProxyTransport: ARTWebSocketTransport { func simulateTransportSuccess(clientId: String? = nil) { self.ignoreWebSocket = true - let msg = ARTProtocolMessage() + let msg = ProtocolMessage() msg.action = .connected msg.connectionId = "x-xxxxxxxx" msg.connectionKey = "xxxxxxx-xxxxxxxxxxxxxx-xxxxxxxx" @@ -1504,10 +1504,10 @@ extension Dictionary { } -extension ARTMessage { +extension Message { open override func isEqual(_ object: Any?) -> Bool { - if let other = object as? ARTMessage { + if let other = object as? Message { return self.name == other.name && self.encoding == other.encoding && self.data as! NSObject == other.data as! NSObject @@ -1604,7 +1604,7 @@ extension String { } -extension ARTRealtime { +extension Realtime { var transportFactory: TestProxyTransportFactory? { self.internal.options.testOptions.transportFactory as? TestProxyTransportFactory @@ -1695,15 +1695,15 @@ extension ARTRealtime { } func dispose() { - let names = self.channels.map({ ($0 as! ARTRealtimeChannel).name }) + let names = self.channels.map({ ($0 as! RealtimeChannel).name }) for name in names { self.channels.release(name) } self.connection.off() } - func requestPresenceSyncForChannel(_ channel: ARTRealtimeChannel) { - let syncMessage = ARTProtocolMessage() + func requestPresenceSyncForChannel(_ channel: RealtimeChannel) { + let syncMessage = ProtocolMessage() syncMessage.action = .sync syncMessage.channel = channel.name guard let transport = self.internal.transport as? TestProxyTransport else { @@ -1730,9 +1730,9 @@ extension ARTWebSocketTransport { func simulateIncomingError() { // Simulate receiving an ERROR ProtocolMessage, which should put a client into the FAILED state (per RTN15i) - let protocolMessage = ARTProtocolMessage() + let protocolMessage = ProtocolMessage() protocolMessage.action = .error - protocolMessage.error = ARTErrorInfo.create(withCode: 50000 /* arbitrarily chosen */, message: "Fail test") + protocolMessage.error = ErrorInfo.create(withCode: 50000 /* arbitrarily chosen */, message: "Fail test") receive(protocolMessage) } } @@ -1756,9 +1756,9 @@ extension ARTAuthInternal { } -extension ARTPresenceMessage { +extension PresenceMessage { - convenience init(clientId: String, action: ARTPresenceAction, connectionId: String, id: String, timestamp: Date = Date()) { + convenience init(clientId: String, action: PresenceAction, connectionId: String, id: String, timestamp: Date = Date()) { self.init() self.action = action self.clientId = clientId @@ -1769,7 +1769,7 @@ extension ARTPresenceMessage { } -extension ARTMessage { +extension Message { convenience init(id: String, name: String? = nil, data: Any) { self.init(name: name, data: data) @@ -1778,39 +1778,39 @@ extension ARTMessage { } -extension ARTRealtimeConnectionState : CustomStringConvertible { +extension RealtimeConnectionState : CustomStringConvertible { public var description : String { - return ARTRealtimeConnectionStateToStr(self) + return RealtimeConnectionStateToStr(self) } } -extension ARTRealtimeConnectionEvent : CustomStringConvertible { +extension RealtimeConnectionEvent : CustomStringConvertible { public var description : String { - return ARTRealtimeConnectionEventToStr(self) + return RealtimeConnectionEventToStr(self) } } -extension ARTProtocolMessageAction : CustomStringConvertible { +extension ProtocolMessageAction : CustomStringConvertible { public var description : String { - return ARTProtocolMessageActionToStr(self) + return ProtocolMessageActionToStr(self) } } -extension ARTRealtimeChannelState : CustomStringConvertible { +extension RealtimeChannelState : CustomStringConvertible { public var description : String { - return ARTRealtimeChannelStateToStr(self) + return RealtimeChannelStateToStr(self) } } -extension ARTChannelEvent : CustomStringConvertible { +extension ChannelEvent : CustomStringConvertible { public var description : String { - return ARTChannelEventToStr(self) + return ChannelEventToStr(self) } } -extension ARTPresenceAction : CustomStringConvertible { +extension PresenceAction : CustomStringConvertible { public var description : String { - return ARTPresenceActionToStr(self) + return PresenceActionToStr(self) } } @@ -1943,7 +1943,7 @@ extension HTTPURLResponse { } -extension ARTHTTPPaginatedResponse { +extension HTTPPaginatedResponse { var headers: NSDictionary { return response.objc_allHeaderFields @@ -1955,7 +1955,7 @@ protocol ARTHasInternal { func unwrapAsync(_: @escaping (Internal) -> ()) } -extension ARTRealtime: ARTHasInternal { +extension Realtime: ARTHasInternal { typealias Internal = ARTRealtimeInternal func unwrapAsync(_ use: @escaping (Internal) -> ()) { self.internalAsync(use) diff --git a/Test/Tests/ARTDefaultTests.swift b/Test/Tests/ARTDefaultTests.swift index 7c0053f38..4ef2037b9 100644 --- a/Test/Tests/ARTDefaultTests.swift +++ b/Test/Tests/ARTDefaultTests.swift @@ -5,7 +5,7 @@ import Ably.ARTDefault // System under Test class ARTDefaultTests: XCTestCase { func testVersions() { - XCTAssertEqual(ARTDefault.apiVersion(), "2") - XCTAssertEqual(ARTDefault.libraryVersion(), "1.2.31") + XCTAssertEqual(Default.apiVersion(), "2") + XCTAssertEqual(Default.libraryVersion(), "1.2.31") } } diff --git a/Test/Tests/AuthTests.swift b/Test/Tests/AuthTests.swift index 149f79c48..9c4dded11 100644 --- a/Test/Tests/AuthTests.swift +++ b/Test/Tests/AuthTests.swift @@ -4,22 +4,22 @@ import Nimble import XCTest private func testOptionsGiveDefaultAuthMethod(_ caseSetter: (ARTAuthOptions) -> Void) { - let options = ARTClientOptions() + let options = ClientOptions() caseSetter(options) - let client = ARTRest(options: options) + let client = Rest(options: options) - XCTAssertEqual(client.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(client.auth.internal.method, AuthMethod.token) } // Cases: // - useTokenAuth is specified and thus a key is not provided // - authCallback and authUrl are both specified -private func testStopsClientWithOptions(caseSetter: (ARTClientOptions) -> Void) { - let options = ARTClientOptions() +private func testStopsClientWithOptions(caseSetter: (ClientOptions) -> Void) { + let options = ClientOptions() caseSetter(options) - expect { ARTRest(options: options) }.to(raiseException()) + expect { Rest(options: options) }.to(raiseException()) } private let currentClientId = "client_string" @@ -42,7 +42,7 @@ private func check(_ details: ARTTokenDetails) { private let channelName = "test_JWT" private let messageName = "message_JWT" -private func createAuthUrlTestsOptions(for test: Test) throws -> ARTClientOptions { +private func createAuthUrlTestsOptions(for test: Test) throws -> ClientOptions { let options = try AblyTests.clientOptions(for: test) options.authUrl = URL(string: echoServerAddress)! return options @@ -54,7 +54,7 @@ private func createJsonEncoder() -> ARTJsonLikeEncoder { return encoder } -private func jwtContentTypeTestsSetupDependencies(for test: Test) throws -> ARTRest { +private func jwtContentTypeTestsSetupDependencies(for test: Test) throws -> Rest { let options = try AblyTests.clientOptions(for: test) let keys = try getKeys(for: test) options.authUrl = URL(string: echoServerAddress)! @@ -62,7 +62,7 @@ private func jwtContentTypeTestsSetupDependencies(for test: Test) throws -> ARTR options.authParams?.append(URLQueryItem(name: "keyName", value: keys["keyName"])) options.authParams?.append(URLQueryItem(name: "keySecret", value: keys["keySecret"])) options.authParams?.append(URLQueryItem(name: "returnType", value: "jwt")) - return ARTRest(options: options) + return Rest(options: options) } class AuthTests: XCTestCase { @@ -78,14 +78,14 @@ class AuthTests: XCTestCase { let clientOptions = try AblyTests.commonAppSetup(for: test) clientOptions.tls = false - expect { ARTRest(options: clientOptions) }.to(raiseException()) + expect { Rest(options: clientOptions) }.to(raiseException()) } // RSA11 func test__004__Basic__should_send_the_API_key_in_the_Authorization_header() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -110,9 +110,9 @@ class AuthTests: XCTestCase { // RSA2 func test__005__Basic__should_be_default_when_an_API_key_is_set() { - let client = ARTRest(options: ARTClientOptions(key: "fake:key")) + let client = Rest(options: ClientOptions(key: "fake:key")) - XCTAssertEqual(client.auth.internal.method, ARTAuthMethod.basic) + XCTAssertEqual(client.auth.internal.method, AuthMethod.basic) } // RSA3 @@ -122,7 +122,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) options.tls = false - let clientHTTP = ARTRest(options: options) + let clientHTTP = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) clientHTTP.internal.httpExecutor = testHTTPExecutor @@ -141,7 +141,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) options.tls = true - let clientHTTPS = ARTRest(options: options) + let clientHTTPS = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) clientHTTPS.internal.httpExecutor = testHTTPExecutor @@ -163,7 +163,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -193,7 +193,7 @@ class AuthTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.connect() @@ -236,7 +236,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) // No means to renew the token is provided XCTAssertNil(rest.internal.options.key) XCTAssertNil(rest.internal.options.authCallback) @@ -252,7 +252,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(UInt(error.code), ARTState.requestTokenFailed.rawValue) + XCTAssertEqual(UInt(error.code), State.requestTokenFailed.rawValue) done() } } @@ -272,7 +272,7 @@ class AuthTests: XCTestCase { delay(tokenTtl + AblyTests.tokenExpiryTolerance) { done() } } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } // No means to renew the token is provided XCTAssertNil(realtime.internal.options.key) @@ -288,7 +288,7 @@ class AuthTests: XCTestCase { fail("Error is nil"); done(); return } XCTAssertEqual(error.code, ARTErrorCode.tokenExpired.intValue) - XCTAssertEqual(realtime.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(realtime.connection.state, RealtimeConnectionState.failed) done() } } @@ -307,7 +307,7 @@ class AuthTests: XCTestCase { } } - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -335,7 +335,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.useTokenAuth = true - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -369,7 +369,7 @@ class AuthTests: XCTestCase { } options.autoConnect = false - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -404,7 +404,7 @@ class AuthTests: XCTestCase { } options.autoConnect = false - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -435,7 +435,7 @@ class AuthTests: XCTestCase { options.tokenDetails = tokenDetails options.key = nil - let rest = ARTRest(options: options) + let rest = Rest(options: options) let proxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) // Sync server time offset @@ -464,7 +464,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(error.code, Int(ARTState.requestTokenFailed.rawValue)) + XCTAssertEqual(error.code, Int(State.requestTokenFailed.rawValue)) expect(error.message).to(contain("no means to renew the token is provided")) XCTAssertEqual(proxyHTTPExecutor.requests.count, 0) @@ -486,7 +486,7 @@ class AuthTests: XCTestCase { options.tokenDetails = tokenDetails options.key = nil - let rest = ARTRest(options: options) + let rest = Rest(options: options) let proxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = proxyHTTPExecutor @@ -505,7 +505,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(error.code, Int(ARTState.requestTokenFailed.rawValue)) + XCTAssertEqual(error.code, Int(State.requestTokenFailed.rawValue)) expect(error.message).to(contain("no means to renew the token is provided")) XCTAssertEqual(proxyHTTPExecutor.requests.count, 1) XCTAssertEqual(proxyHTTPExecutor.responses.count, 1) @@ -524,7 +524,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.autoConnect = false options.authUrl = URL(string: "https://echo.ably.io/respondwith?status=403")! - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -545,9 +545,9 @@ class AuthTests: XCTestCase { var authCallbackHasBeenInvoked = false options.authCallback = { _, completion in authCallbackHasBeenInvoked = true - completion(nil, ARTErrorInfo(domain: "io.ably.cocoa", code: ARTErrorCode.forbidden.intValue, userInfo: ["ARTErrorInfoStatusCode": 403])) + completion(nil, ErrorInfo(domain: "io.ably.cocoa", code: ARTErrorCode.forbidden.intValue, userInfo: ["ErrorInfoStatusCode": 403])) } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -579,12 +579,12 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.autoConnect = false options.authUrl = URL(string: "http://echo.ably.io")! - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) guard let errorInfo = stateChange.reason else { fail("ErrorInfo is nil"); done(); return } @@ -610,7 +610,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "type", value: "text")) options.authParams?.append(URLQueryItem(name: "body", value: token)) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -624,8 +624,8 @@ class AuthTests: XCTestCase { realtime.internal.options.authParams = [URLQueryItem]() // Inject AUTH - let authMessage = ARTProtocolMessage() - authMessage.action = ARTProtocolMessageAction.auth + let authMessage = ProtocolMessage() + authMessage.action = ProtocolMessageAction.auth realtime.internal.transport?.receive(authMessage) expect(realtime.connection.errorReason).toEventuallyNot(beNil(), timeout: testTimeout) @@ -635,7 +635,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("body param is required")) - XCTAssertEqual(realtime.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(realtime.connection.state, RealtimeConnectionState.connected) } // RSA4c1 & RSA4c2 @@ -646,12 +646,12 @@ class AuthTests: XCTestCase { options.authCallback = { _, completion in completion(nil, NSError(domain: NSURLErrorDomain, code: -1003, userInfo: [NSLocalizedDescriptionKey: "A server with the specified hostname could not be found."])) } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) guard let errorInfo = stateChange.reason else { fail("ErrorInfo is nil"); done(); return } @@ -661,7 +661,7 @@ class AuthTests: XCTestCase { realtime.connect() } - expect(realtime.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) + expect(realtime.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) let errorInfo = try XCTUnwrap(realtime.connection.errorReason, "ErrorInfo is empty") @@ -676,7 +676,7 @@ class AuthTests: XCTestCase { options.authCallback = { _, completion in getTestTokenDetails(for: test, completion: completion) } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -692,8 +692,8 @@ class AuthTests: XCTestCase { } // Inject AUTH - let authMessage = ARTProtocolMessage() - authMessage.action = ARTProtocolMessageAction.auth + let authMessage = ProtocolMessage() + authMessage.action = ProtocolMessageAction.auth realtime.internal.transport?.receive(authMessage) expect(realtime.connection.errorReason).toEventuallyNot(beNil(), timeout: testTimeout) @@ -703,7 +703,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("hostname could not be found")) - XCTAssertEqual(realtime.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(realtime.connection.state, RealtimeConnectionState.connected) } // RSA4c1 & RSA4c2 @@ -717,12 +717,12 @@ class AuthTests: XCTestCase { let invalidTokenFormat = "{secret_token:xxx}" options.authParams?.append(URLQueryItem(name: "body", value: invalidTokenFormat)) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) guard let errorInfo = stateChange.reason else { fail("ErrorInfo is nil"); done(); return } @@ -737,7 +737,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("content response cannot be used for token request")) - expect(realtime.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) + expect(realtime.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) } // RSA4c3 @@ -751,7 +751,7 @@ class AuthTests: XCTestCase { let token = try getTestToken(for: test) options.authParams?.append(URLQueryItem(name: "body", value: token)) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -779,8 +779,8 @@ class AuthTests: XCTestCase { } // Inject AUTH - let authMessage = ARTProtocolMessage() - authMessage.action = ARTProtocolMessageAction.auth + let authMessage = ProtocolMessage() + authMessage.action = ProtocolMessageAction.auth realtime.internal.transport?.receive(authMessage) expect(realtime.connection.errorReason).toEventuallyNot(beNil(), timeout: testTimeout) @@ -790,7 +790,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("content response cannot be used for token request")) - XCTAssertEqual(realtime.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(realtime.connection.state, RealtimeConnectionState.connected) } // RSA4c1 & RSA4c2 @@ -803,7 +803,7 @@ class AuthTests: XCTestCase { } options.testOptions.realtimeRequestTimeout = 0.5 - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -822,7 +822,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("timed out")) - expect(realtime.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) + expect(realtime.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) } // RSA4c3 @@ -837,7 +837,7 @@ class AuthTests: XCTestCase { // This needs to be sufficiently long such that we can expect to receive a CONNECTED ProtocolMessage within this duration after starting a connection attempt (there's no "correct" value since it depends on network conditions, but 1.5s seemed to work locally and in CI at time of writing). But we also don't want it to be longer than necessary since that would impact test execution time. options.testOptions.realtimeRequestTimeout = 1.5 - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -854,8 +854,8 @@ class AuthTests: XCTestCase { } // Inject AUTH - let authMessage = ARTProtocolMessage() - authMessage.action = ARTProtocolMessageAction.auth + let authMessage = ProtocolMessage() + authMessage.action = ProtocolMessageAction.auth waitUntil(timeout: testTimeout) { done in realtime.unwrapAsync { realtime in realtime.transport?.receive(authMessage) @@ -870,7 +870,7 @@ class AuthTests: XCTestCase { XCTAssertEqual(errorInfo.code, ARTErrorCode.authConfiguredProviderFailure.intValue) expect(errorInfo.message).to(contain("timed out")) - XCTAssertEqual(realtime.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(realtime.connection.state, RealtimeConnectionState.connected) } // RSA15 @@ -884,7 +884,7 @@ class AuthTests: XCTestCase { options.useTokenAuth = true options.clientId = expectedClientId - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -892,7 +892,7 @@ class AuthTests: XCTestCase { // Token client.auth.authorize(nil, options: nil) { tokenDetails, error in XCTAssertNil(error) - XCTAssertEqual(client.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(client.auth.internal.method, AuthMethod.token) guard let tokenDetails = tokenDetails else { fail("TokenDetails is nil"); done(); return } @@ -920,7 +920,7 @@ class AuthTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.connect() @@ -949,8 +949,8 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "*" - expect { ARTRest(options: options) }.to(raiseException()) - expect { ARTRealtime(options: options) }.to(raiseException()) + expect { Rest(options: options) }.to(raiseException()) + expect { Realtime(options: options) }.to(raiseException()) } // RSA15b @@ -959,7 +959,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = nil - let clientBasic = ARTRest(options: options) + let clientBasic = Rest(options: options) waitUntil(timeout: testTimeout) { done in // Basic @@ -971,7 +971,7 @@ class AuthTests: XCTestCase { } } - let clientToken = ARTRest(options: options) + let clientToken = Rest(options: options) waitUntil(timeout: testTimeout) { done in // Last TokenDetails @@ -995,7 +995,7 @@ class AuthTests: XCTestCase { options.authCallback = { _, completion in completion(wrongTokenDetails, nil) } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -1011,11 +1011,11 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(ARTTokenParams(clientId: "wrong"), with: nil) { tokenDetails, error in - let error = error as! ARTErrorInfo + let error = error as! ErrorInfo XCTAssertEqual(error.code, ARTErrorCode.incompatibleCredentials.intValue) XCTAssertNil(tokenDetails) done() @@ -1042,9 +1042,9 @@ class AuthTests: XCTestCase { tokenParams.timestamp = dateFormatter.date(from: "2016/10/08 22:31 GMT") } - let options = ARTClientOptions() + let options = ClientOptions() options.authUrl = URL(string: "https://ably-test-suite.io") - let rest = ARTRest(options: options) + let rest = Rest(options: options) let request = rest.auth.internal.buildRequest(options, with: tokenParams) let query = try XCTUnwrap(request.url?.query, "URL is empty") @@ -1060,7 +1060,7 @@ class AuthTests: XCTestCase { XCTAssertNil(tokenParams.capability) let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -1093,7 +1093,7 @@ class AuthTests: XCTestCase { tokenParams.capability = "{\"*\":[\"*\"]}" let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -1125,7 +1125,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "mary" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor let channel = rest.channels.get(test.uniqueChannelName()) @@ -1151,7 +1151,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client_string" - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -1175,7 +1175,7 @@ class AuthTests: XCTestCase { let clientOptions = try AblyTests.commonAppSetup(for: test) clientOptions.clientId = "String" - XCTAssertEqual(ARTRest(options: clientOptions).internal.options.clientId, "String") + XCTAssertEqual(Rest(options: clientOptions).internal.options.clientId, "String") } // RSA7a4 @@ -1195,7 +1195,7 @@ class AuthTests: XCTestCase { } } options.defaultTokenParams = ARTTokenParams(clientId: "tester") - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(client.auth.clientId, "john") @@ -1253,7 +1253,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.token = try getTestToken(for: test, clientId: "tester") - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } XCTAssertNil(realtime.auth.clientId) @@ -1279,7 +1279,7 @@ class AuthTests: XCTestCase { let clientOptions = try AblyTests.commonAppSetup(for: test) clientOptions.clientId = "Exist" - XCTAssertEqual(ARTRest(options: clientOptions).auth.clientId, "Exist") + XCTAssertEqual(Rest(options: clientOptions).auth.clientId, "Exist") } // RSA7b2 @@ -1289,7 +1289,7 @@ class AuthTests: XCTestCase { options.clientId = "client_string" options.useTokenAuth = true - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -1298,7 +1298,7 @@ class AuthTests: XCTestCase { // Token client.auth.authorize(nil, options: nil) { _, error in XCTAssertNil(error) - XCTAssertEqual(client.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(client.auth.internal.method, AuthMethod.token) XCTAssertEqual(client.auth.clientId, options.clientId) done() } @@ -1343,7 +1343,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, clientId: "*") - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.connection.on(.connected) { _ in @@ -1359,7 +1359,7 @@ class AuthTests: XCTestCase { let clientOptions = try AblyTests.commonAppSetup(for: test) clientOptions.clientId = "*" - expect { ARTRest(options: clientOptions) }.to(raiseException()) + expect { Rest(options: clientOptions) }.to(raiseException()) } // RSA8 @@ -1369,7 +1369,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "сlientId" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams() tokenParams.ttl = 2000 @@ -1390,7 +1390,7 @@ class AuthTests: XCTestCase { let options2 = try AblyTests.commonAppSetup(for: test) options2.clientId = nil - let rest2 = ARTRest(options: options2) + let rest2 = Rest(options: options2) let precedenceOptions2 = try AblyTests.commonAppSetup(for: test) precedenceOptions2.clientId = nil @@ -1412,7 +1412,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "tester" - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(nil, with: nil) { tokenDetails, error in @@ -1451,7 +1451,7 @@ class AuthTests: XCTestCase { XCTAssertNotNil(tokenDetails) XCTAssertEqual(tokenDetails!.capability, "{\"*\":[\"*\"]}") XCTAssertEqual(tokenDetails!.clientId, "tester") - XCTAssertEqual(tokenDetails!.expires!.timeIntervalSince1970 - tokenDetails!.issued!.timeIntervalSince1970, ARTDefault.ttl()) + XCTAssertEqual(tokenDetails!.expires!.timeIntervalSince1970 - tokenDetails!.issued!.timeIntervalSince1970, Default.ttl()) done() } } @@ -1482,7 +1482,7 @@ class AuthTests: XCTestCase { options.authParams!.append(URLQueryItem(name: "type", value: "text")) options.authParams!.append(URLQueryItem(name: "body", value: testToken)) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -1502,7 +1502,7 @@ class AuthTests: XCTestCase { let testTokenDetails = try XCTUnwrap(getTestTokenDetails(for: test, clientId: "tester"), "TokenDetails is empty") let jsonTokenDetails = try XCTUnwrap(createJsonEncoder().encode(testTokenDetails), "Invalid TokenDetails") - let options = ARTClientOptions() + let options = ClientOptions() options.authUrl = URL(string: "http://echo.ably.io") XCTAssertNotNil(options.authUrl) // JSON with TokenDetails @@ -1510,7 +1510,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "type", value: "json")) options.authParams?.append(URLQueryItem(name: "body", value: jsonTokenDetails.toUTF8String)) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -1543,7 +1543,7 @@ class AuthTests: XCTestCase { options.authUrl = URL(string: "http://echo.ably.io") XCTAssertNotNil(options.authUrl) - var rest = ARTRest(options: options) + var rest = Rest(options: options) var tokenRequest: ARTTokenRequest? waitUntil(timeout: testTimeout) { done in @@ -1563,7 +1563,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "type", value: "json")) options.authParams?.append(URLQueryItem(name: "body", value: jsonTokenRequest.toUTF8String)) - rest = ARTRest(options: options) + rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -1585,7 +1585,7 @@ class AuthTests: XCTestCase { // RSA8c1a func test__069__requestToken__authUrl__parameters__should_be_added_to_the_URL_when_auth_method_is_GET() throws { - let clientOptions = ARTClientOptions() + let clientOptions = ClientOptions() clientOptions.authUrl = URL(string: "http://auth.ably.io") var authParams = [ "param1": "value", @@ -1599,7 +1599,7 @@ class AuthTests: XCTestCase { let tokenParams = ARTTokenParams() tokenParams.clientId = "test" - let rest = ARTRest(options: clientOptions) + let rest = Rest(options: clientOptions) let request = rest.auth.internal.buildRequest(clientOptions, with: tokenParams) for (header, expectedValue) in clientOptions.authHeaders! { @@ -1633,7 +1633,7 @@ class AuthTests: XCTestCase { // RSA8c1b func test__070__requestToken__authUrl__parameters__should_added_on_the_body_request_when_auth_method_is_POST() { - let clientOptions = ARTClientOptions() + let clientOptions = ClientOptions() clientOptions.authUrl = URL(string: "http://auth.ably.io") clientOptions.authParams = [ URLQueryItem(name: "identifier", value: "123"), @@ -1644,7 +1644,7 @@ class AuthTests: XCTestCase { tokenParams.ttl = 2000 tokenParams.capability = "{\"cansubscribe:*\":[\"subscribe\"]}" - let rest = ARTRest(options: clientOptions) + let rest = Rest(options: clientOptions) let request = rest.auth.internal.buildRequest(clientOptions, with: tokenParams) @@ -1674,7 +1674,7 @@ class AuthTests: XCTestCase { // RSA8c2 func test__067__requestToken__authUrl__TokenParams_should_take_precedence_over_any_configured_authParams_when_a_name_conflict_occurs() { - let options = ARTClientOptions() + let options = ClientOptions() options.clientId = "john" options.authUrl = URL(string: "http://auth.ably.io") options.authMethod = "GET" @@ -1688,7 +1688,7 @@ class AuthTests: XCTestCase { let tokenParams = ARTTokenParams() tokenParams.clientId = "tester" - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -1703,9 +1703,9 @@ class AuthTests: XCTestCase { // RSA8c3 func test__068__requestToken__authUrl__should_override_previously_configured_parameters() { - let clientOptions = ARTClientOptions() + let clientOptions = ClientOptions() clientOptions.authUrl = URL(string: "http://auth.ably.io") - let rest = ARTRest(options: clientOptions) + let rest = Rest(options: clientOptions) let authOptions = ARTAuthOptions() authOptions.authUrl = URL(string: "http://auth.ably.io") @@ -1718,7 +1718,7 @@ class AuthTests: XCTestCase { // RSA8a func test__057__requestToken__implicitly_creates_a_TokenRequest_and_requests_a_token() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) var createTokenRequestMethodWasCalled = false @@ -1745,11 +1745,11 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = currentClientId - let rest = ARTRest(options: options) + let rest = Rest(options: options) // Default values let defaultTokenParams = ARTTokenParams(clientId: currentClientId) - defaultTokenParams.ttl = ARTDefault.ttl() as NSNumber // Set by the server. + defaultTokenParams.ttl = Default.ttl() as NSNumber // Set by the server. waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(nil, with: nil, callback: { tokenDetails, _ in @@ -1770,7 +1770,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = currentClientId - let rest = ARTRest(options: options) + let rest = Rest(options: options) // Custom values let expectedTtl = 4800.0 @@ -1806,7 +1806,7 @@ class AuthTests: XCTestCase { XCTAssertNil(tokenParams.clientId) completion("token_string" as ARTTokenDetailsCompatible?, nil) } - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(expectedTokenParams, with: nil) { tokenDetails, error in @@ -1826,7 +1826,7 @@ class AuthTests: XCTestCase { XCTAssertNil(tokenParams.clientId) completion(ARTTokenDetails(token: "token_from_details"), nil) } - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(expectedTokenParams, with: nil) { tokenDetails, error in @@ -1842,7 +1842,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let expectedTokenParams = ARTTokenParams() expectedTokenParams.clientId = "foo" - var rest: ARTRest! + var rest: Rest! options.authCallback = { tokenParams, completion in XCTAssertTrue(tokenParams.clientId == expectedTokenParams.clientId) @@ -1851,7 +1851,7 @@ class AuthTests: XCTestCase { } } - rest = ARTRest(options: options) + rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.requestToken(expectedTokenParams, with: nil) { tokenDetails, error in @@ -1870,13 +1870,13 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, clientId: nil) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - let message = ARTMessage(name: nil, data: "message without an explicit clientId") + let message = Message(name: nil, data: "message without an explicit clientId") XCTAssertNil(message.clientId) channel.publish([message]) { error in XCTAssertNil(error) @@ -1905,11 +1905,11 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, clientId: nil) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - let message = ARTMessage(name: nil, data: "message with an explicit clientId", clientId: "john") + let message = Message(name: nil, data: "message with an explicit clientId", clientId: "john") channel.publish([message]) { error in guard let error = error else { fail("Error is nil"); done(); return @@ -1925,7 +1925,7 @@ class AuthTests: XCTestCase { func test__060__requestToken__ensure_the_message_published_with_a_wildcard_____does_not_have_a_clientId() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(ARTTokenParams(clientId: "*"), options: nil) { _, error in @@ -1939,7 +1939,7 @@ class AuthTests: XCTestCase { let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - let message = ARTMessage(name: nil, data: "no client") + let message = Message(name: nil, data: "no client") XCTAssertNil(message.clientId) channel.publish([message]) { error in XCTAssertNil(error) @@ -1969,11 +1969,11 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) // Request a token with a wildcard '*' value clientId options.token = try getTestToken(for: test, clientId: "*") - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - let message = ARTMessage(name: nil, data: "message with an explicit clientId", clientId: "john") + let message = Message(name: nil, data: "message with an explicit clientId", clientId: "john") channel.publish([message]) { error in XCTAssertNil(error) channel.history { page, error in @@ -1999,7 +1999,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client_string" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams() let defaultCapability = tokenParams.capability @@ -2089,7 +2089,7 @@ class AuthTests: XCTestCase { } var testTokenRequest: ARTTokenRequest? - let rest = ARTRest(options: defaultOptions) + let rest = Rest(options: defaultOptions) rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, _ in testTokenRequest = tokenRequest }) @@ -2125,7 +2125,7 @@ class AuthTests: XCTestCase { completion(tokenRequest, nil) } - let rest = ARTRest(options: defaultOptions) + let rest = Rest(options: defaultOptions) rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, _ in currentTokenRequest = tokenRequest }) @@ -2143,7 +2143,7 @@ class AuthTests: XCTestCase { func test__079__createTokenRequest__should_replace_defaults_if__nil__option_s_field_passed() throws { let test = Test() let defaultOptions = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: defaultOptions) + let rest = Rest(options: defaultOptions) let customOptions = ARTAuthOptions() @@ -2162,7 +2162,7 @@ class AuthTests: XCTestCase { func test__080__createTokenRequest__should_use_configured_defaults_if_the_object_arguments_are_omitted() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams() tokenParams.clientId = "tester" @@ -2211,7 +2211,7 @@ class AuthTests: XCTestCase { // RSA9a func test__081__createTokenRequest__should_create_and_sign_a_TokenRequest() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let expectedClientId = "client_string" let tokenParams = ARTTokenParams(clientId: expectedClientId) @@ -2233,8 +2233,8 @@ class AuthTests: XCTestCase { // RSA9b func test__082__createTokenRequest__should_support_AuthOptions() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) - let auth: ARTAuth = rest.auth + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) + let auth: Auth = rest.auth let authOptions = ARTAuthOptions(key: "key:secret") @@ -2253,7 +2253,7 @@ class AuthTests: XCTestCase { // RSA9c func test__083__createTokenRequest__should_generate_a_unique_16_plus_character_nonce_if_none_is_provided() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) waitUntil(timeout: testTimeout) { done in // First @@ -2284,7 +2284,7 @@ class AuthTests: XCTestCase { func test__087__createTokenRequest__should_generate_a_timestamp__from_current_time_if_not_provided() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) waitUntil(timeout: testTimeout) { done in rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, error in @@ -2300,7 +2300,7 @@ class AuthTests: XCTestCase { func test__088__createTokenRequest__should_generate_a_timestamp__will_retrieve_the_server_time_if_queryTime_is_true() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) var serverTimeRequestWasMade = false let block: @convention(block) (AspectInfo) -> Void = { _ in @@ -2332,7 +2332,7 @@ class AuthTests: XCTestCase { func test__089__createTokenRequest__TTL__should_be_optional() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) waitUntil(timeout: testTimeout) { done in rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, error in @@ -2366,7 +2366,7 @@ class AuthTests: XCTestCase { func test__090__createTokenRequest__TTL__should_be_specified_in_milliseconds() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let params = ARTTokenParams() params.ttl = NSNumber(value: 42) @@ -2395,7 +2395,7 @@ class AuthTests: XCTestCase { func test__091__createTokenRequest__TTL__should_be_valid_to_request_a_token_for_24_hours() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let tokenParams = ARTTokenParams() let dayInSeconds = TimeInterval(24 * 60 * 60) tokenParams.ttl = dayInSeconds as NSNumber @@ -2415,7 +2415,7 @@ class AuthTests: XCTestCase { // RSA9f func test__084__createTokenRequest__should_provide_capability_has_json_text() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let tokenParams = ARTTokenParams() tokenParams.capability = "{ - }" @@ -2446,7 +2446,7 @@ class AuthTests: XCTestCase { // RSA9g func test__085__createTokenRequest__should_generate_a_valid_HMAC() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let tokenParams = ARTTokenParams(clientId: "client_string") @@ -2475,7 +2475,7 @@ class AuthTests: XCTestCase { // RSA9i func test__086__createTokenRequest__should_respect_all_requirements() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let expectedClientId = "client_string" let tokenParams = ARTTokenParams(clientId: expectedClientId) let expectedTtl = 6.0 @@ -2520,7 +2520,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.useTokenAuth = true - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -2531,7 +2531,7 @@ class AuthTests: XCTestCase { } // Check that token exists - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) let firstTokenDetails = try XCTUnwrap(rest.auth.tokenDetails, "TokenDetails is nil") XCTAssertNotNil(firstTokenDetails.token) @@ -2544,7 +2544,7 @@ class AuthTests: XCTestCase { } // Check that token has not changed - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) let secondTokenDetails = try XCTUnwrap(rest.auth.tokenDetails, "TokenDetails is nil") XCTAssertTrue(firstTokenDetails === secondTokenDetails) @@ -2576,7 +2576,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let testToken = try getTestToken(for: test) options.token = testToken - let rest = ARTRest(options: options) + let rest = Rest(options: options) XCTAssertNotNil(rest.auth.tokenDetails?.token) waitUntil(timeout: testTimeout) { done in @@ -2585,11 +2585,11 @@ class AuthTests: XCTestCase { XCTFail("TokenDetails is nil"); done(); return } XCTAssertNotEqual(tokenDetails.token, testToken) - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) publishTestMessage(rest, channelName: test.uniqueChannelName(), completion: { error in XCTAssertNil(error) - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) XCTAssertEqual(rest.auth.tokenDetails?.token, tokenDetails.token) done() }) @@ -2601,7 +2601,7 @@ class AuthTests: XCTestCase { func test__094__authorize__should_create_a_token_immediately_and_ensures_Token_Auth_is_used_for_all_future_requests() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) XCTAssertNil(rest.auth.tokenDetails?.token) waitUntil(timeout: testTimeout) { done in @@ -2610,11 +2610,11 @@ class AuthTests: XCTestCase { XCTFail("TokenDetails is nil"); done(); return } XCTAssertNotNil(tokenDetails.token) - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) publishTestMessage(rest, channelName: test.uniqueChannelName(), completion: { error in XCTAssertNil(error) - XCTAssertEqual(rest.auth.internal.method, ARTAuthMethod.token) + XCTAssertEqual(rest.auth.internal.method, AuthMethod.token) XCTAssertEqual(rest.auth.tokenDetails?.token, tokenDetails.token) done() }) @@ -2625,11 +2625,11 @@ class AuthTests: XCTestCase { // RSA10b func test__095__authorize__should_supports_all_TokenParams_and_AuthOptions() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(ARTTokenParams(), options: ARTAuthOptions(), callback: { _, error in - guard let error = error as? ARTErrorInfo else { + guard let error = error as? ErrorInfo else { fail("Error is nil"); done(); return } expect(error.localizedDescription).to(contain("no means to renew the token is provided")) @@ -2641,7 +2641,7 @@ class AuthTests: XCTestCase { // RSA10e func test__096__authorize__should_use_the_requestToken_implementation() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) var requestMethodWasCalled = false let block: @convention(block) (AspectInfo) -> Void = { _ in @@ -2673,7 +2673,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client_string" - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { tokenDetails, error in @@ -2695,7 +2695,7 @@ class AuthTests: XCTestCase { func test__099__authorize__on_subsequent_authorisations__should_store_the_AuthOptions_with_authUrl() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor let auth = rest.auth @@ -2738,7 +2738,7 @@ class AuthTests: XCTestCase { func test__100__authorize__on_subsequent_authorisations__should_store_the_AuthOptions_with_authCallback() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let auth = rest.auth var authCallbackHasBeenInvoked = false @@ -2773,7 +2773,7 @@ class AuthTests: XCTestCase { func test__101__authorize__on_subsequent_authorisations__should_not_store_queryTime() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let authOptions = ARTAuthOptions() authOptions.key = options.key authOptions.queryTime = true @@ -2807,7 +2807,7 @@ class AuthTests: XCTestCase { func test__102__authorize__on_subsequent_authorisations__should_store_the_TokenParams() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let tokenParams = ARTTokenParams() tokenParams.clientId = ExpectedTokenParams.clientId @@ -2841,7 +2841,7 @@ class AuthTests: XCTestCase { func test__103__authorize__on_subsequent_authorisations__should_use_configured_defaults_if_the_object_arguments_are_omitted() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams() tokenParams.clientId = ExpectedTokenParams.clientId @@ -2881,7 +2881,7 @@ class AuthTests: XCTestCase { func test__098__authorize__should_use_the_configured_Auth_clientId__if_not_null__by_default() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var rest = ARTRest(options: options) + var rest = Rest(options: options) // ClientId null waitUntil(timeout: testTimeout) { done in @@ -2896,7 +2896,7 @@ class AuthTests: XCTestCase { } options.clientId = "client_string" - rest = ARTRest(options: options) + rest = Rest(options: options) // ClientId not null waitUntil(timeout: testTimeout) { done in @@ -2917,7 +2917,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client_string" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams() tokenParams.clientId = ExpectedTokenParams.clientId @@ -2944,7 +2944,7 @@ class AuthTests: XCTestCase { let test = Test() var currentTokenRequest: ARTTokenRequest? - var rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + var rest = Rest(options: try AblyTests.commonAppSetup(for: test)) rest.auth.createTokenRequest(nil, options: nil, callback: { tokenRequest, _ in currentTokenRequest = tokenRequest }) @@ -2957,7 +2957,7 @@ class AuthTests: XCTestCase { completion(currentTokenRequest!, nil) } - rest = ARTRest(options: options) + rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { tokenDetails, error in XCTAssertNil(error) @@ -2973,13 +2973,13 @@ class AuthTests: XCTestCase { } func test__106__authorize__should_adhere_to_all_requirements_relating_to__authUrl() { - let options = ARTClientOptions() + let options = ClientOptions() options.authUrl = URL(string: "http://echo.ably.io")! - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { tokenDetails, error in - guard let error = error as? ARTErrorInfo else { + guard let error = error as? ErrorInfo else { fail("Error is nil"); done(); return } XCTAssertEqual(error.statusCode, 400) // Bad request @@ -2996,13 +2996,13 @@ class AuthTests: XCTestCase { let tokenDetailsData = try XCTUnwrap(createJsonEncoder().encode(tokenDetails), "Couldn't encode token details") let tokenDetailsJSON = try XCTUnwrap(String(data: tokenDetailsData, encoding: .utf8), "JSON TokenDetails is empty") - let options = ARTClientOptions() + let options = ClientOptions() // Use authUrl for authentication with JSON TokenDetails response options.authUrl = URL(string: "http://echo.ably.io")! options.authParams = [URLQueryItem]() options.authParams?.append(URLQueryItem(name: "type", value: "json")) options.authParams?.append(URLQueryItem(name: "body", value: "[]")) - var rest = ARTRest(options: options) + var rest = Rest(options: options) // Invalid TokenDetails waitUntil(timeout: testTimeout) { done in @@ -3010,7 +3010,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual((error as! ARTErrorInfo).code, Int(ARTState.authUrlIncompatibleContent.rawValue)) + XCTAssertEqual((error as! ErrorInfo).code, Int(State.authUrlIncompatibleContent.rawValue)) XCTAssertNil(tokenDetails) done() } @@ -3018,7 +3018,7 @@ class AuthTests: XCTestCase { options.authParams?.removeLast() options.authParams?.append(URLQueryItem(name: "body", value: tokenDetailsJSON)) - rest = ARTRest(options: options) + rest = Rest(options: options) // Valid token waitUntil(timeout: testTimeout) { done in @@ -3035,7 +3035,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var rest = ARTRest(options: options) + var rest = Rest(options: options) var tokenRequest: ARTTokenRequest! waitUntil(timeout: testTimeout) { done in let params = ARTTokenParams(clientId: "myClientId", nonce: "12345") @@ -3055,7 +3055,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "type", value: "json")) options.authParams?.append(URLQueryItem(name: "body", value: tokenRequestJSON)) options.key = nil - rest = ARTRest(options: options) + rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { tokenDetails, error in @@ -3070,13 +3070,13 @@ class AuthTests: XCTestCase { func test__109__authorize__should_adhere_to_all_requirements_relating_to__authUrl_with_plain_text() throws { let test = Test() let token = try getTestToken(for: test) - let options = ARTClientOptions() + let options = ClientOptions() // Use authUrl for authentication with plain text token response options.authUrl = URL(string: "http://echo.ably.io")! options.authParams = [URLQueryItem]() options.authParams?.append(URLQueryItem(name: "type", value: "text")) options.authParams?.append(URLQueryItem(name: "body", value: "")) - var rest = ARTRest(options: options) + var rest = Rest(options: options) // Invalid token waitUntil(timeout: testTimeout) { done in @@ -3089,7 +3089,7 @@ class AuthTests: XCTestCase { options.authParams?.removeLast() options.authParams?.append(URLQueryItem(name: "body", value: token)) - rest = ARTRest(options: options) + rest = Rest(options: options) // Valid token waitUntil(timeout: testTimeout) { done in @@ -3107,7 +3107,7 @@ class AuthTests: XCTestCase { let test = Test() let defaultOptions = try AblyTests.clientOptions(for: test) // sandbox defaultOptions.key = "xxxx:xxxx" - let rest = ARTRest(options: defaultOptions) + let rest = Rest(options: defaultOptions) let authOptions = ARTAuthOptions() authOptions.key = try AblyTests.commonAppSetup(for: test).key // valid key @@ -3156,7 +3156,7 @@ class AuthTests: XCTestCase { func test__111__authorize__when_TokenParams_and_AuthOptions_are_provided__should_supersede_configured_AuthOptions__using_authUrl__even_if_arguments_objects_are_empty() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let testTokenDetails = try XCTUnwrap(getTestTokenDetails(for: test, ttl: 0.1)) let tokenRequestData = try XCTUnwrap(createJsonEncoder().encode(testTokenDetails), "Encode failure") @@ -3188,7 +3188,7 @@ class AuthTests: XCTestCase { authOptions.authHeaders = nil waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: authOptions) { tokenDetails, error in - guard let error = error as? ARTErrorInfo else { + guard let error = error as? ErrorInfo else { fail("Error is nil"); done(); return } XCTAssertEqual(error.statusCode, 400) @@ -3202,7 +3202,7 @@ class AuthTests: XCTestCase { // Repeat waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { tokenDetails, error in - guard let error = error as? ARTErrorInfo else { + guard let error = error as? ErrorInfo else { fail("Error is nil"); done(); return } XCTAssertEqual(error.statusCode, 400) @@ -3219,7 +3219,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(UInt((error as! ARTErrorInfo).code), ARTState.requestTokenFailed.rawValue) + XCTAssertEqual(UInt((error as! ErrorInfo).code), State.requestTokenFailed.rawValue) XCTAssertNil(tokenDetails) XCTAssertNil(rest.auth.internal.options.authUrl) XCTAssertNil(rest.auth.internal.options.authParams) @@ -3234,7 +3234,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(UInt((error as! ARTErrorInfo).code), ARTState.requestTokenFailed.rawValue) + XCTAssertEqual(UInt((error as! ErrorInfo).code), State.requestTokenFailed.rawValue) XCTAssertNil(tokenDetails) XCTAssertNil(rest.auth.internal.options.authUrl) XCTAssertNil(rest.auth.internal.options.authParams) @@ -3246,7 +3246,7 @@ class AuthTests: XCTestCase { func test__112__authorize__when_TokenParams_and_AuthOptions_are_provided__should_supersede_configured_AuthOptions__using_authCallback__even_if_arguments_objects_are_empty() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let testTokenDetails = ARTTokenDetails(token: "token", expires: Date(), issued: Date(), capability: nil, clientId: nil) var authCallbackHasBeenInvoked = false @@ -3284,7 +3284,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(UInt((error as! ARTErrorInfo).code), ARTState.requestTokenFailed.rawValue) + XCTAssertEqual(UInt((error as! ErrorInfo).code), State.requestTokenFailed.rawValue) XCTAssertNil(tokenDetails) XCTAssertFalse(authCallbackHasBeenInvoked) XCTAssertNil(rest.auth.internal.options.authCallback) @@ -3297,7 +3297,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual(UInt((error as! ARTErrorInfo).code), ARTState.requestTokenFailed.rawValue) + XCTAssertEqual(UInt((error as! ErrorInfo).code), State.requestTokenFailed.rawValue) XCTAssertNil(tokenDetails) XCTAssertFalse(authCallbackHasBeenInvoked) XCTAssertNil(rest.auth.internal.options.authCallback) @@ -3311,7 +3311,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.key = "xxxx:xxxx" options.clientId = "client_string" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let tokenParams = ARTTokenParams(clientId: options.clientId) @@ -3321,7 +3321,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual((error as! ARTErrorInfo).code, ARTErrorCode.notFound.intValue) + XCTAssertEqual((error as! ErrorInfo).code, ARTErrorCode.notFound.intValue) XCTAssertNil(tokenDetails) done() } @@ -3383,7 +3383,7 @@ class AuthTests: XCTestCase { return $0 }(ARTTokenParams()) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testTokenParams = ARTTokenParams() testTokenParams.ttl = nil @@ -3403,7 +3403,7 @@ class AuthTests: XCTestCase { } XCTAssertNil(tokenDetails.clientId) // `ttl` when omitted, the default value is applied - XCTAssertEqual(issued.addingTimeInterval(ARTDefault.ttl()), expires) + XCTAssertEqual(issued.addingTimeInterval(Default.ttl()), expires) done() } } @@ -3422,7 +3422,7 @@ class AuthTests: XCTestCase { fail("TokenDetails.expires is nil"); done(); return } XCTAssertNil(tokenDetails.clientId) - XCTAssertEqual(issued.addingTimeInterval(ARTDefault.ttl()), expires) + XCTAssertEqual(issued.addingTimeInterval(Default.ttl()), expires) done() } } @@ -3433,7 +3433,7 @@ class AuthTests: XCTestCase { func skipped__test__115__authorize__server_time_offset__should_obtain_server_time_once_and_persist_the_offset_from_the_local_clock() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockServerDate = Date().addingTimeInterval(120) rest.auth.internal.testSuite_returnValue(for: NSSelectorFromString("handleServerTime:"), with: mockServerDate) @@ -3490,7 +3490,7 @@ class AuthTests: XCTestCase { func test__116__authorize__server_time_offset__should_be_consistent_the_timestamp_request_with_the_server_time() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockServerDate = Date().addingTimeInterval(120) rest.auth.internal.testSuite_returnValue(for: NSSelectorFromString("handleServerTime:"), with: mockServerDate) @@ -3527,7 +3527,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.queryTime = true - let rest = ARTRest(options: options) + let rest = Rest(options: options) var serverTimeRequestCount = 0 let hook = rest.internal.testSuite_injectIntoMethod(after: #selector(rest.internal._time(_:))) { @@ -3546,7 +3546,7 @@ class AuthTests: XCTestCase { } expect(timeOffset).toNot(beCloseTo(0)) let calculatedServerDate = Date().addingTimeInterval(timeOffset) - expect(tokenDetails.expires).to(beCloseTo(calculatedServerDate.addingTimeInterval(ARTDefault.ttl()), within: 1.0)) + expect(tokenDetails.expires).to(beCloseTo(calculatedServerDate.addingTimeInterval(Default.ttl()), within: 1.0)) XCTAssertEqual(serverTimeRequestCount, 1) done() } @@ -3576,7 +3576,7 @@ class AuthTests: XCTestCase { func test__118__authorize__server_time_offset__should_use_the_local_clock_offset_to_calculate_the_server_time() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let authOptions = ARTAuthOptions() authOptions.key = options.key @@ -3605,7 +3605,7 @@ class AuthTests: XCTestCase { func test__119__authorize__server_time_offset__should_request_server_time_when_queryTime_is_true_even_if_the_time_offset_is_assigned() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) var serverTimeRequestCount = 0 let hook = rest.internal.testSuite_injectIntoMethod(after: #selector(rest.internal._time)) { @@ -3636,7 +3636,7 @@ class AuthTests: XCTestCase { func test__120__authorize__server_time_offset__should_discard_the_time_offset_in_situations_in_which_it_may_have_been_invalidated() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) var discardTimeOffsetCallCount = 0 let hook = rest.auth.internal.testSuite_injectIntoMethod(after: #selector(rest.auth.internal.discardTimeOffset)) { @@ -3669,7 +3669,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.useTokenAuth = true - let rest = ARTRest(options: options) + let rest = Rest(options: options) var tokenDetailsFirst: ARTTokenDetails? var tokenDetailsLast: ARTTokenDetails? @@ -3758,7 +3758,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.useTokenAuth = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close(); realtime.dispose() } waitUntil(timeout: testTimeout) { done in @@ -3838,7 +3838,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let initialToken = try getTestToken(for: test, clientId: "tester", capability: "{\"restricted\":[\"*\"]}") options.token = initialToken - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let channel = realtime.channels.get(test.uniqueChannelName()) @@ -3881,7 +3881,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "tester" options.useTokenAuth = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in @@ -3900,7 +3900,7 @@ class AuthTests: XCTestCase { guard let error = error else { fail("Error is nil"); done(); return } - XCTAssertEqual((error as! ARTErrorInfo).code, ARTErrorCode.incompatibleCredentials.intValue) + XCTAssertEqual((error as! ErrorInfo).code, ARTErrorCode.incompatibleCredentials.intValue) XCTAssertNil(tokenDetails) done() } @@ -3908,7 +3908,7 @@ class AuthTests: XCTestCase { let initialToken = try XCTUnwrap(realtime.auth.tokenDetails?.token, "TokenDetails is nil") - expect(realtime.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(realtime.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) XCTAssertEqual(realtime.auth.tokenDetails?.token, initialToken) XCTAssertNotEqual(realtime.auth.tokenDetails?.capability, tokenParams.capability) } @@ -3916,7 +3916,7 @@ class AuthTests: XCTestCase { // TK2d func test__129__TokenParams__timestamp_should_not_be_a_member_of_any_default_token_params() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) waitUntil(timeout: testTimeout) { done in rest.auth.authorize(nil, options: nil) { _, error in XCTAssertNil(error) @@ -3953,7 +3953,7 @@ class AuthTests: XCTestCase { func test__accepts_a_string__which_should_be_interpreted_as_JSON() { contextBeforeEach?() - check(try! ARTTokenRequest.fromJson(json as ARTJsonCompatible)) + check(try! ARTTokenRequest.fromJson(json as JsonCompatible)) contextAfterEach?() } @@ -4031,17 +4031,17 @@ class AuthTests: XCTestCase { } func test__130__TokenRequest__fromJson__rejects_invalid_JSON() { - expect { try ARTTokenRequest.fromJson("not JSON" as ARTJsonCompatible) }.to(throwError()) + expect { try ARTTokenRequest.fromJson("not JSON" as JsonCompatible) }.to(throwError()) } func test__131__TokenRequest__fromJson__rejects_non_object_JSON() { - expect { try ARTTokenRequest.fromJson("[]" as ARTJsonCompatible) }.to(throwError()) + expect { try ARTTokenRequest.fromJson("[]" as JsonCompatible) }.to(throwError()) } // TD7 func test__136__TokenDetails__fromJson__accepts_a_string__which_should_be_interpreted_as_JSON() { - check(try! ARTTokenDetails.fromJson(json as ARTJsonCompatible)) + check(try! ARTTokenDetails.fromJson(json as JsonCompatible)) } func test__137__TokenDetails__fromJson__accepts_a_NSDictionary() { @@ -4051,11 +4051,11 @@ class AuthTests: XCTestCase { } func test__138__TokenDetails__fromJson__rejects_invalid_JSON() { - expect { try ARTTokenDetails.fromJson("not JSON" as ARTJsonCompatible) }.to(throwError()) + expect { try ARTTokenDetails.fromJson("not JSON" as JsonCompatible) }.to(throwError()) } func test__139__TokenDetails__fromJson__rejects_non_object_JSON() { - expect { try ARTTokenDetails.fromJson("[]" as ARTJsonCompatible) }.to(throwError()) + expect { try ARTTokenDetails.fromJson("[]" as JsonCompatible) }.to(throwError()) } func skipped__test__140__JWT_and_realtime__client_initialized_with_a_JWT_token_in_ClientOptions__with_valid_credentials__pulls_stats_successfully() throws { @@ -4104,7 +4104,7 @@ class AuthTests: XCTestCase { options.authParams = [URLQueryItem]() options.authParams?.append(URLQueryItem(name: "keyName", value: keys["keyName"])) options.authParams?.append(URLQueryItem(name: "keySecret", value: keys["keySecret"])) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } @@ -4129,7 +4129,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "keyName", value: keys["keyName"])) options.authParams?.append(URLQueryItem(name: "keySecret", value: "INVALID")) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4157,7 +4157,7 @@ class AuthTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "keySecret", value: keys["keySecret"])) options.authParams?.append(URLQueryItem(name: "expiresIn", value: String(UInt(tokenDuration)))) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4190,7 +4190,7 @@ class AuthTests: XCTestCase { options.autoConnect = false // Prevent auto connection so we can set the transport proxy options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4224,7 +4224,7 @@ class AuthTests: XCTestCase { } completion(token, nil) } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4249,7 +4249,7 @@ class AuthTests: XCTestCase { } completion(token, nil) } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4282,7 +4282,7 @@ class AuthTests: XCTestCase { } completion(token, nil) } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } var originalToken = "" var originalConnectionID = "" @@ -4310,7 +4310,7 @@ class AuthTests: XCTestCase { let clientId = "JWTClientId" let options = try AblyTests.clientOptions(for: test) options.tokenDetails = ARTTokenDetails(token: try getJWTToken(for: test, clientId: clientId)!) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4329,7 +4329,7 @@ class AuthTests: XCTestCase { options.tokenDetails = ARTTokenDetails(token: try getJWTToken(for: test, capability: capability)!) // Prevent channel name to be prefixed by test-* options.testOptions.channelNamePrefix = nil - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -4347,14 +4347,14 @@ class AuthTests: XCTestCase { func test__151__currentTokenDetails__should_hold_a__TokenDetails__instance_in_which_only_the__token__attribute_is_populated_with_that_token_string() throws { let test = Test() let token = try getTestToken(for: test) - let rest = ARTRest(token: token) + let rest = Rest(token: token) XCTAssertEqual(rest.auth.tokenDetails?.token, token) } // RSA11c func test__152__currentTokenDetails__should_be_set_with_the_current_token__if_applicable__on_instantiation_and_each_time_it_is_replaced() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) XCTAssertNil(rest.auth.tokenDetails) var authenticatedTokenDetails: ARTTokenDetails? waitUntil(timeout: testTimeout) { done in @@ -4370,7 +4370,7 @@ class AuthTests: XCTestCase { // RSA11d func test__153__currentTokenDetails__should_be_empty_if_there_is_no_current_token() throws { let test = Test() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) XCTAssertNil(rest.auth.tokenDetails) } @@ -4380,7 +4380,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.tokenDetails = ARTTokenDetails(token: try getJWTToken(for: test, jwtType: "embedded")!) - let client = ARTRest(options: options) + let client = Rest(options: options) waitUntil(timeout: testTimeout) { done in client.stats { _, error in XCTAssertNil(error) @@ -4393,7 +4393,7 @@ class AuthTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.tokenDetails = ARTTokenDetails(token: try getJWTToken(for: test, jwtType: "embedded", encrypted: 1)!) - let client = ARTRest(options: options) + let client = Rest(options: options) waitUntil(timeout: testTimeout) { done in client.stats { _, error in XCTAssertNil(error) @@ -4422,7 +4422,7 @@ class AuthTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.auth.requestToken(nil, with: nil, callback: { tokenDetails, error in - let newClientOptions: ARTClientOptions + let newClientOptions: ClientOptions do { newClientOptions = try AblyTests.clientOptions(for: test) } catch { @@ -4431,7 +4431,7 @@ class AuthTests: XCTestCase { return } newClientOptions.token = tokenDetails!.token - let newClient = ARTRest(options: newClientOptions) + let newClient = Rest(options: newClientOptions) newClient.stats { _, error in XCTAssertNil(error) done() @@ -4452,7 +4452,7 @@ class AuthTests: XCTestCase { func test__002__should_accept_authURL_response_with_timestamp_argument_as_string() throws { let test = Test() var originalTokenRequest: ARTTokenRequest! - let tmpRest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let tmpRest = Rest(options: try AblyTests.commonAppSetup(for: test)) let channelName = test.uniqueChannelName() waitUntil(timeout: testTimeout) { done in @@ -4476,7 +4476,7 @@ class AuthTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.authUrl = URL(string: "http://auth-test.ably.cocoa") - let rest = ARTRest(options: options) + let rest = Rest(options: options) XCTAssertNil(rest.auth.clientId) #if TARGET_OS_IOS XCTAssertNil(rest.device.clientId) diff --git a/Test/Tests/ClientInformationTests.swift b/Test/Tests/ClientInformationTests.swift index 400870ab8..b17c2ef61 100644 --- a/Test/Tests/ClientInformationTests.swift +++ b/Test/Tests/ClientInformationTests.swift @@ -28,7 +28,7 @@ final class ClientInformationTests: XCTestCase { func testAgentIdentifierWithAdditionalAgents_withNilAdditionalAgents() { let expectedIdentifier = [ "ably-cocoa/1.2.31", - ARTDefault.platformAgent() + Default.platformAgent() ].sorted().joined(separator: " ") XCTAssertEqual(ARTClientInformation.agentIdentifier(withAdditionalAgents: nil), expectedIdentifier) @@ -45,7 +45,7 @@ final class ClientInformationTests: XCTestCase { "ably-cocoa/1.2.31", "demolib/0.0.1", "morelib", - ARTDefault.platformAgent() + Default.platformAgent() ].sorted().joined(separator: " ") XCTAssertEqual(ARTClientInformation.agentIdentifier(withAdditionalAgents: additionalAgents), expectedIdentifier) diff --git a/Test/Tests/CryptoTests.swift b/Test/Tests/CryptoTests.swift index 706a5885b..d864b83e4 100644 --- a/Test/Tests/CryptoTests.swift +++ b/Test/Tests/CryptoTests.swift @@ -20,9 +20,9 @@ class CryptoTests: XCTestCase { // RSE1a, RSE1b func test__001__Crypto__getDefaultParams__returns_a_complete_CipherParams_instance__using_the_default_values_for_any_field_not_supplied() { - expect { ARTCrypto.getDefaultParams(["nokey": "nokey"]) }.to(raiseException()) + expect { Crypto.getDefaultParams(["nokey": "nokey"]) }.to(raiseException()) - var params: ARTCipherParams = ARTCrypto.getDefaultParams([ + var params: CipherParams = Crypto.getDefaultParams([ "key": key, ]) XCTAssertEqual(params.algorithm, "AES") @@ -30,7 +30,7 @@ class CryptoTests: XCTestCase { XCTAssertEqual(params.keyLength, 128) XCTAssertEqual(params.mode, "CBC") - params = ARTCrypto.getDefaultParams([ + params = Crypto.getDefaultParams([ "key": longKey, "algorithm": "DES", ]) @@ -43,33 +43,33 @@ class CryptoTests: XCTestCase { // RSE1c func test__004__Crypto__getDefaultParams__key_parameter__can_be_a_binary() { - let params = ARTCrypto.getDefaultParams(["key": binaryKey]) + let params = Crypto.getDefaultParams(["key": binaryKey]) XCTAssertEqual(params.key, binaryKey as Data) } func test__005__Crypto__getDefaultParams__key_parameter__can_be_a_base64_encoded_string_with_standard_encoding() { - let params = ARTCrypto.getDefaultParams(["key": key]) + let params = Crypto.getDefaultParams(["key": key]) XCTAssertEqual(params.key, binaryKey as Data) } func test__006__Crypto__getDefaultParams__key_parameter__can_be_a_base64_encoded_string_with_URL_encoding() { let key = "-_h4eHh4eHh4eHh4eHh4eA==" - let params = ARTCrypto.getDefaultParams(["key": key]) + let params = Crypto.getDefaultParams(["key": key]) XCTAssertEqual(params.key, binaryKey as Data) } // RSE1d func test__002__Crypto__getDefaultParams__calculates_a_keyLength_from_the_key__its_size_in_bits_() { - var params = ARTCrypto.getDefaultParams(["key": binaryKey]) + var params = Crypto.getDefaultParams(["key": binaryKey]) XCTAssertEqual(params.keyLength, 128) - params = ARTCrypto.getDefaultParams(["key": longKey]) + params = Crypto.getDefaultParams(["key": longKey]) XCTAssertEqual(params.keyLength, 256) } // RSE1e func test__003__Crypto__getDefaultParams__should_check_that_keyLength_is_valid_for_algorithm() { - expect { ARTCrypto.getDefaultParams([ + expect { Crypto.getDefaultParams([ "key": binaryKey.subdata(in: 0 ..< 10), ]) }.to(raiseException()) } @@ -78,16 +78,16 @@ class CryptoTests: XCTestCase { // RSE2a, RSE2b func test__007__Crypto__generateRandomKey__takes_a_single_length_argument_and_returns_a_binary() { - var key: NSData = ARTCrypto.generateRandomKey(128) as NSData + var key: NSData = Crypto.generateRandomKey(128) as NSData XCTAssertEqual(key.length, 128 / 8) - key = ARTCrypto.generateRandomKey(256) as NSData + key = Crypto.generateRandomKey(256) as NSData XCTAssertEqual(key.length, 256 / 8) } // RSE2a, RSE2b func test__008__Crypto__generateRandomKey__takes_no_arguments_and_returns_the_default_algorithm_s_default_length() { - let key: NSData = ARTCrypto.generateRandomKey() as NSData + let key: NSData = Crypto.generateRandomKey() as NSData XCTAssertEqual(key.length, 256 / 8) } @@ -95,14 +95,14 @@ class CryptoTests: XCTestCase { let string = "The quick brown fox jumps over the lazy dog" let expectedHash = "D7A8FBB307D7809469CA9ABCB0082E4F8D5651E46D3CDB762D02D0BF37C9E592" // hex let stringData = string.data(using: .utf8)! - let result = ARTCrypto.generateHashSHA256(stringData) + let result = Crypto.generateHashSHA256(stringData) XCTAssertEqual(result.hexString, expectedHash) } func test__010__Crypto__encrypt__should_generate_a_new_IV_every_time_it_s_called__and_should_be_the_first_block_encrypted() { - let params = ARTCipherParams(algorithm: "aes", key: key as ARTCipherKeyCompatible) + let params = CipherParams(algorithm: "aes", key: key as CipherKeyCompatible) let logger = InternalLog(core: MockInternalLogCore()) - let cipher = ARTCrypto.cipher(with: params, logger: logger) + let cipher = Crypto.cipher(with: params, logger: logger) let data = "data".data(using: String.Encoding.utf8)! var distinctOutputs = Set() @@ -113,9 +113,9 @@ class CryptoTests: XCTestCase { distinctOutputs.insert(output!) let firstBlock = output!.subdata(with: NSMakeRange(0, Int((cipher as! ARTCbcCipher).blockLength))) - let paramsWithIV = ARTCipherParams(algorithm: "aes", key: key as ARTCipherKeyCompatible, iv: firstBlock) + let paramsWithIV = CipherParams(algorithm: "aes", key: key as CipherKeyCompatible, iv: firstBlock) var sameOutput: NSData? - ARTCrypto.cipher(with: paramsWithIV, logger: logger).encrypt(data, output: &sameOutput) + Crypto.cipher(with: paramsWithIV, logger: logger).encrypt(data, output: &sameOutput) XCTAssertEqual(output!, sameOutput!) } @@ -131,12 +131,12 @@ class CryptoTests: XCTestCase { func reusableTestsTestFixture(_ cryptoFixture: (fileName: String, expectedEncryptedEncoding: String, keyLength: UInt), testCase: TestCase_ReusableTestsTestFixture, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil) throws { let (key, iv, items) = AblyTests.loadCryptoTestData(cryptoFixture.fileName) let logger = InternalLog(core: MockInternalLogCore()) - let decoder = ARTDataEncoder(cipherParams: nil, logger: logger, error: nil) - let cipherParams = ARTCipherParams(algorithm: "aes", key: key as ARTCipherKeyCompatible, iv: iv) - let encrypter = ARTDataEncoder(cipherParams: cipherParams, logger: logger, error: nil) + let decoder = DataEncoder(cipherParams: nil, logger: logger, error: nil) + let cipherParams = CipherParams(algorithm: "aes", key: key as CipherKeyCompatible, iv: iv) + let encrypter = DataEncoder(cipherParams: cipherParams, logger: logger, error: nil) - func extractMessage(_ fixture: AblyTests.CryptoTestItem.TestMessage) -> ARTMessage { - let msg = ARTMessage(name: fixture.name, data: fixture.data) + func extractMessage(_ fixture: AblyTests.CryptoTestItem.TestMessage) -> Message { + let msg = Message(name: fixture.name, data: fixture.data) msg.encoding = fixture.encoding return msg } @@ -150,11 +150,11 @@ class CryptoTests: XCTestCase { expect(encryptedFixture.encoding).to(endWith("\(cryptoFixture.expectedEncryptedEncoding)/base64")) var error: NSError? - let decoded = fixture.decode(with: decoder, error: &error) as! ARTMessage + let decoded = fixture.decode(with: decoder, error: &error) as! Message XCTAssertNil(error) XCTAssertNotNil(decoded) - let encrypted = try XCTUnwrap(decoded.encode(with: encrypter, error: &error) as? ARTMessage) + let encrypted = try XCTUnwrap(decoded.encode(with: encrypter, error: &error) as? Message) XCTAssertNil(error) XCTAssertNotNil(encrypted) @@ -173,11 +173,11 @@ class CryptoTests: XCTestCase { expect(encryptedFixture.encoding).to(endWith("\(cryptoFixture.expectedEncryptedEncoding)/base64")) var error: NSError? - let decoded = fixture.decode(with: decoder, error: &error) as! ARTMessage + let decoded = fixture.decode(with: decoder, error: &error) as! Message XCTAssertNil(error) XCTAssertNotNil(decoded) - let decrypted = try XCTUnwrap(encryptedFixture.decode(with: encrypter, error: &error) as? ARTMessage) + let decrypted = try XCTUnwrap(encryptedFixture.decode(with: encrypter, error: &error) as? Message) XCTAssertNil(error) XCTAssertNotNil(decrypted) @@ -197,12 +197,12 @@ class CryptoTests: XCTestCase { func reusableTestsTestManualDecryption(fileName: String, expectedEncryptedEncoding: String, keyLength: UInt) throws { let (key, iv, jsonItems) = AblyTests.loadCryptoTestRawData(fileName) - let decoder = ARTDataEncoder(cipherParams: nil, logger: .init(core: MockInternalLogCore()), error: nil) - let cipherParams = ARTCipherParams(algorithm: "aes", key: key as ARTCipherKeyCompatible, iv: iv) - let channelOptions = ARTChannelOptions(cipher: cipherParams) + let decoder = DataEncoder(cipherParams: nil, logger: .init(core: MockInternalLogCore()), error: nil) + let cipherParams = CipherParams(algorithm: "aes", key: key as CipherKeyCompatible, iv: iv) + let channelOptions = ChannelOptions(cipher: cipherParams) - func extractMessage(_ rawFixture: CryptoData.Item.Encoded) -> ARTMessage { - let msg = ARTMessage(name: rawFixture.name, data: rawFixture.data) + func extractMessage(_ rawFixture: CryptoData.Item.Encoded) -> Message { + let msg = Message(name: rawFixture.name, data: rawFixture.data) msg.encoding = rawFixture.encoding return msg } @@ -214,12 +214,12 @@ class CryptoTests: XCTestCase { expect(encryptedFixture.encoding).to(endWith("\(expectedEncryptedEncoding)/base64")) var error: NSError? - let decoded = fixture.decode(with: decoder, error: &error) as! ARTMessage + let decoded = fixture.decode(with: decoder, error: &error) as! Message XCTAssertNil(error) XCTAssertNotNil(decoded) let rawDictionary = try XCTUnwrap(JSONUtility.codableToDictionary(encryptedFixture)) - let decrypted = try XCTUnwrap(ARTMessage.fromEncoded(rawDictionary, channelOptions: channelOptions)) + let decrypted = try XCTUnwrap(Message.fromEncoded(rawDictionary, channelOptions: channelOptions)) XCTAssertNotNil(decrypted) XCTAssertEqual(decrypted, decoded) @@ -228,14 +228,14 @@ class CryptoTests: XCTestCase { // a bunch at once let encryptedFixtures = try jsonItems.map { try XCTUnwrap(JSONUtility.codableToDictionary($0.encrypted)) } - let decryptedArray = try XCTUnwrap(ARTMessage.fromEncodedArray(encryptedFixtures, channelOptions: channelOptions)) + let decryptedArray = try XCTUnwrap(Message.fromEncodedArray(encryptedFixtures, channelOptions: channelOptions)) XCTAssertEqual(decryptedArray.count, jsonItems.count) for i in 0..= 40150 status: 401, message: "" // arbitrarily chosen diff --git a/Test/Tests/DefaultInternalLogCoreTests.swift b/Test/Tests/DefaultInternalLogCoreTests.swift index b3432af56..6ea88c7e5 100644 --- a/Test/Tests/DefaultInternalLogCoreTests.swift +++ b/Test/Tests/DefaultInternalLogCoreTests.swift @@ -4,7 +4,7 @@ import Ably.Private class DefaultInternalLogCoreTests: XCTestCase { func test_initWithClientOptions_whenClientOptionsLogLevelIsNotNone() throws { // Given: client options whose logLevel is .verbose (arbitrarily chosen, not .none), and whose logHandler has logLevel .info (arbitrarily chosen, not equal to .verbose) - let clientOptions = ARTClientOptions() + let clientOptions = ClientOptions() clientOptions.logLevel = .verbose clientOptions.logHandler.logLevel = .info @@ -21,7 +21,7 @@ class DefaultInternalLogCoreTests: XCTestCase { func test_initWithClientOptions_whenClientOptionsLogLevelIsNone() throws { // Given: client options whose logLevel is .none, and whose logHandler has logLevel .info (arbitrarily chosen, not equal to .none) - let clientOptions = ARTClientOptions() + let clientOptions = ClientOptions() clientOptions.logLevel = .none clientOptions.logHandler.logLevel = .info @@ -39,7 +39,7 @@ class DefaultInternalLogCoreTests: XCTestCase { let mock = MockVersion2Log() let core = DefaultInternalLogCore(logger: mock) - let logLevels: [ARTLogLevel] = [.verbose, .debug, .info, .warn, .error, .none] + let logLevels: [LogLevel] = [.verbose, .debug, .info, .warn, .error, .none] for (index, level) in logLevels.enumerated() { let message = "Message \(index)" core.log(message, with: level, file: "/foo/bar/myFile.m", line: 123) diff --git a/Test/Tests/DeltaCodecTests.swift b/Test/Tests/DeltaCodecTests.swift index 439bc809b..220df0ebe 100644 --- a/Test/Tests/DeltaCodecTests.swift +++ b/Test/Tests/DeltaCodecTests.swift @@ -26,7 +26,7 @@ class DeltaCodecTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe, .publish] channelOptions.params = [ "delta": "vcdiff", @@ -45,7 +45,7 @@ class DeltaCodecTests: XCTestCase { fail("TestProxyTransport is not be assigned"); return } - var receivedMessages: [ARTMessage] = [] + var receivedMessages: [Message] = [] channel.subscribe { message in receivedMessages.append(message) } @@ -79,7 +79,7 @@ class DeltaCodecTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.params = ["delta": "vcdiff"] let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) @@ -109,7 +109,7 @@ class DeltaCodecTests: XCTestCase { return protocolMessage } - var receivedMessages: [ARTMessage] = [] + var receivedMessages: [Message] = [] channel.subscribe { message in receivedMessages.append(message) } @@ -139,7 +139,7 @@ class DeltaCodecTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.params = ["delta": "vcdiff"] let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) @@ -164,7 +164,7 @@ class DeltaCodecTests: XCTestCase { return protocolMessage } - var receivedMessages: [ARTMessage] = [] + var receivedMessages: [Message] = [] channel.subscribe { message in receivedMessages.append(message) } diff --git a/Test/Tests/LogAdapterTests.swift b/Test/Tests/LogAdapterTests.swift index fbc6e0dc1..59294f4dc 100644 --- a/Test/Tests/LogAdapterTests.swift +++ b/Test/Tests/LogAdapterTests.swift @@ -2,19 +2,19 @@ import XCTest import Ably.Private class LogAdapterTests: XCTestCase { - class MockARTLog: ARTLog { - var lastReceivedLogMessageArguments: (message: String, level: ARTLogLevel)? + class MockLog: Log { + var lastReceivedLogMessageArguments: (message: String, level: LogLevel)? - override func log(_ message: String, with level: ARTLogLevel) { + override func log(_ message: String, with level: LogLevel) { lastReceivedLogMessageArguments = (message: message, level: level) } } func test_logMessage() { - let underlyingLogger = MockARTLog() + let underlyingLogger = MockLog() let logger = LogAdapter(logger: underlyingLogger) - let logLevels: [ARTLogLevel] = [.verbose, .debug, .info, .warn, .error, .none] + let logLevels: [LogLevel] = [.verbose, .debug, .info, .warn, .error, .none] for (index, level) in logLevels.enumerated() { let message = "Message \(index)" logger.log(message, with: level, file: "myFile.m", line: 123) @@ -26,7 +26,7 @@ class LogAdapterTests: XCTestCase { } func test_logLevel() { - let underlyingLogger = ARTLog() + let underlyingLogger = Log() underlyingLogger.logLevel = .info let logger = LogAdapter(logger: underlyingLogger) @@ -34,7 +34,7 @@ class LogAdapterTests: XCTestCase { } func test_setLogLevel() { - let underlyingLogger = ARTLog() + let underlyingLogger = Log() underlyingLogger.logLevel = .info let logger = LogAdapter(logger: underlyingLogger) diff --git a/Test/Tests/ObjectLifetimesTests.swift b/Test/Tests/ObjectLifetimesTests.swift index 8a64e57a8..20d35a207 100644 --- a/Test/Tests/ObjectLifetimesTests.swift +++ b/Test/Tests/ObjectLifetimesTests.swift @@ -2,8 +2,8 @@ import Ably import Nimble import XCTest -private let options: ARTClientOptions = { - let options = ARTClientOptions(key: "fake:key") +private let options: ClientOptions = { + let options = ClientOptions(key: "fake:key") options.autoConnect = false return options }() @@ -17,7 +17,7 @@ class ObjectLifetimesTests: XCTestCase { } func test__001__ObjectLifetimes__user_code_releases_public_object__the_object_s_internal_child_s_back_reference_is_released_too() { - var realtime: ARTRealtime? = ARTRealtime(options: options) + var realtime: Realtime? = Realtime(options: options) weak var internalRealtime: ARTRealtimeInternal? = realtime!.internal weak var internalConn: ARTConnectionInternal? = realtime!.connection.internal weak var internalRest: ARTRestInternal? = realtime!.internal.rest @@ -45,7 +45,7 @@ class ObjectLifetimesTests: XCTestCase { } func test__002__ObjectLifetimes__user_code_holds_only_reference_to_public_object_s_public_child__still_can_access_parent_s_internal_object() { - let conn = ARTRealtime(options: options).connection + let conn = Realtime(options: options).connection waitUntil(timeout: testTimeout) { done in conn.ping { _ in @@ -55,7 +55,7 @@ class ObjectLifetimesTests: XCTestCase { } func test__003__ObjectLifetimes__user_code_holds_only_reference_to_public_object_s_public_child__when_it_s_released__schedules_async_release_of_parent_s_internal_object_in_internal_queue() { - var conn: ARTConnection? = ARTRealtime(options: options).connection + var conn: Connection? = Realtime(options: options).connection weak var weakConn = conn!.internal_nosync waitUntil(timeout: testTimeout) { done in @@ -80,7 +80,7 @@ class ObjectLifetimesTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var client: ARTRealtime? = ARTRealtime(options: options) + var client: Realtime? = Realtime(options: options) weak var weakClient = client!.internal XCTAssertNotNil(weakClient) @@ -90,7 +90,7 @@ class ObjectLifetimesTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client!.channels.get(channelName).subscribe(attachCallback: { _ in client = nil - ARTRest(options: options).channels.get(channelName).publish(nil, data: "bar") + Rest(options: options).channels.get(channelName).publish(nil, data: "bar") }, callback: { msg in XCTAssertEqual(msg.data as? String, "bar") done() @@ -102,10 +102,10 @@ class ObjectLifetimesTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var client: ARTRealtime? = ARTRealtime(options: options) + var client: Realtime? = Realtime(options: options) weak var weakClient = client!.internal - var channel: ARTRealtimeChannel? = client!.channels.get(test.uniqueChannelName()) + var channel: RealtimeChannel? = client!.channels.get(test.uniqueChannelName()) weak var weakChannel = channel!.internal waitUntil(timeout: testTimeout) { done in diff --git a/Test/Tests/PushActivationStateMachineTests.swift b/Test/Tests/PushActivationStateMachineTests.swift index ba6130b62..f87528e7b 100644 --- a/Test/Tests/PushActivationStateMachineTests.swift +++ b/Test/Tests/PushActivationStateMachineTests.swift @@ -2,16 +2,16 @@ import Ably import Nimble import XCTest -private var rest: ARTRest! +private var rest: Rest! private var httpExecutor: MockHTTPExecutor! private var storage: MockDeviceStorage! -private var initialStateMachine: ARTPushActivationStateMachine! +private var initialStateMachine: PushActivationStateMachine! private let expectedFormFactor = "phone" private let expectedPlatform = "ios" private let expectedPushRecipient: [String: [String: AnyHashable]] = ["recipient": ["transportType": "apns"]] -private var stateMachine: ARTPushActivationStateMachine! +private var stateMachine: PushActivationStateMachine! class PushActivationStateMachineTests: XCTestCase { // XCTest invokes this method before executing the first test in the test suite. We use it to ensure that the global variables are initialized at the same moment, and in the same order, as they would have been when we used the Quick testing framework. @@ -31,12 +31,12 @@ class PushActivationStateMachineTests: XCTestCase { override func setUp() { super.setUp() - rest = ARTRest(key: "xxxx:xxxx") + rest = Rest(key: "xxxx:xxxx") httpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = httpExecutor storage = MockDeviceStorage() rest.internal.storage = storage - initialStateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + initialStateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) } override func tearDown() { @@ -46,14 +46,14 @@ class PushActivationStateMachineTests: XCTestCase { } func test__002__Activation_state_machine__should_set_NotActivated_state_as_current_state_when_disk_is_empty() { - expect(initialStateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(initialStateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) } func test__003__Activation_state_machine__should_read_the_current_state_from_disk() { - let storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeviceRegistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + let storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeviceRegistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) XCTAssertEqual(storage.keysRead.count, 2) XCTAssertEqual(storage.keysRead.filter { $0.hasSuffix("CurrentState") }.count, 1) expect(storage.keysWritten).to(beEmpty()) @@ -66,16 +66,16 @@ class PushActivationStateMachineTests: XCTestCase { let storage = MockDeviceStorage() storage.simulateOnNextRead(data: stateEncodedFromOldVersion, for: ARTPushActivationCurrentStateKey) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateAfterRegistrationSyncFailed.self)) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + expect(stateMachine.current).to(beAKindOf(PushActivationStateAfterRegistrationSyncFailed.self)) } // RSH3a func beforeEach__Activation_state_machine__State_NotActivated() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateNotActivated(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateNotActivated(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) } // RSH3a1 @@ -88,9 +88,9 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hook.remove() } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertTrue(deactivatedCallbackCalled) } @@ -119,12 +119,12 @@ class PushActivationStateMachineTests: XCTestCase { func test__014__Activation_state_machine__State_NotActivated__on_Event_CalledActivate__local_device__should_have_a_generated_id() { beforeEach__Activation_state_machine__State_NotActivated() - let options = ARTClientOptions(key: "xxxx:xxxx") - let rest = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let rest = Rest(options: options) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) XCTAssertEqual(rest.device.id.count, 36) } @@ -132,12 +132,12 @@ class PushActivationStateMachineTests: XCTestCase { func test__015__Activation_state_machine__State_NotActivated__on_Event_CalledActivate__local_device__should_have_a_generated_secret() throws { beforeEach__Activation_state_machine__State_NotActivated() - let options = ARTClientOptions(key: "xxxx:xxxx") - let rest = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let rest = Rest(options: options) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) let secret = try XCTUnwrap(rest.device.secret, "Device Secret should be available in storage") let data = try XCTUnwrap(Data(base64Encoded: secret), "Device Secret should be encoded with Base64") @@ -149,16 +149,16 @@ class PushActivationStateMachineTests: XCTestCase { func test__016__Activation_state_machine__State_NotActivated__on_Event_CalledActivate__local_device__should_have_a_clientID_if_the_client_is_identified() { beforeEach__Activation_state_machine__State_NotActivated() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.clientId = "deviceClient" - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) XCTAssertNil(rest.device.clientId) - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) XCTAssertNotNil(rest.device.id) XCTAssertNotNil(rest.device.secret) @@ -179,14 +179,14 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventCalledActivate { + if event is PushActivationEventCalledActivate { partialDone() } - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { partialDone() } } - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) } } @@ -194,32 +194,32 @@ class PushActivationStateMachineTests: XCTestCase { func test__010__Activation_state_machine__State_NotActivated__on_Event_CalledActivate__none_of_them_then_should_transition_to_WaitingForPushDeviceDetails() { beforeEach__Activation_state_machine__State_NotActivated() - stateMachine.send(ARTPushActivationEventCalledActivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + stateMachine.send(PushActivationEventCalledActivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) } // RSH3a3 func test__008__Activation_state_machine__State_NotActivated__on_Event_GotPushDeviceDetails() { beforeEach__Activation_state_machine__State_NotActivated() - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) } // RSH3b func beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) } // RSH3b1 func test__017__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_CalledActivate() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - stateMachine.send(ARTPushActivationEventCalledActivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + stateMachine.send(PushActivationEventCalledActivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) } // RSH3b2 @@ -232,8 +232,8 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hook.remove() } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + stateMachine.send(PushActivationEventCalledDeactivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertTrue(deactivatedCallbackCalled) } @@ -243,7 +243,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__022__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GotPushDeviceDetails__should_use_custom_registerCallback_and_fire_GotDeviceRegistration_event() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) let delegate = StateMachineDelegateCustomCallbacks() stateMachine.delegate = delegate @@ -251,10 +251,10 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventGotPushDeviceDetails { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + if event is PushActivationEventGotPushDeviceDetails { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) partialDone() - } else if event is ARTPushActivationEventGotDeviceRegistration { + } else if event is PushActivationEventGotDeviceRegistration { stateMachine.transitions = nil partialDone() } @@ -265,10 +265,10 @@ class PushActivationStateMachineTests: XCTestCase { partialDone() return nil } - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForNewPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForNewPushDeviceDetails.self)) XCTAssertEqual(httpExecutor.requests.count, 0) } @@ -276,7 +276,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__023__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GotPushDeviceDetails__should_use_custom_registerCallback_and_fire_GettingDeviceRegistrationFailed_event() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) let delegate = StateMachineDelegateCustomCallbacks() stateMachine.delegate = delegate @@ -285,10 +285,10 @@ class PushActivationStateMachineTests: XCTestCase { let simulatedError = NSError(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) let partialDone = AblyTests.splitDone(3, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventGotPushDeviceDetails { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + if event is PushActivationEventGotPushDeviceDetails { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) partialDone() - } else if let event = event as? ARTPushActivationEventGettingDeviceRegistrationFailed { + } else if let event = event as? PushActivationEventGettingDeviceRegistrationFailed { XCTAssertEqual(event.error.domain, ARTAblyErrorDomain) XCTAssertEqual(event.error.code, simulatedError.code) stateMachine.transitions = nil @@ -301,10 +301,10 @@ class PushActivationStateMachineTests: XCTestCase { partialDone() return simulatedError } - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertEqual(httpExecutor.requests.count, 0) } @@ -312,7 +312,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__024__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GotPushDeviceDetails__should_fire_GotDeviceRegistration_event() throws { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) let delegate = StateMachineDelegate() stateMachine.delegate = delegate @@ -326,18 +326,18 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventGotPushDeviceDetails { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + if event is PushActivationEventGotPushDeviceDetails { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) partialDone() - } else if event is ARTPushActivationEventGotDeviceRegistration { + } else if event is PushActivationEventGotDeviceRegistration { stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForNewPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForNewPushDeviceDetails.self)) XCTAssertTrue(setAndPersistIdentityTokenDetailsCalled) XCTAssertEqual(httpExecutor.requests.count, 1) let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations" } @@ -362,7 +362,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__025__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GotPushDeviceDetails__should_fire_GettingDeviceRegistrationFailed_event() throws { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) let delegate = StateMachineDelegate() stateMachine.delegate = delegate @@ -373,20 +373,20 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventGotPushDeviceDetails { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + if event is PushActivationEventGotPushDeviceDetails { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) partialDone() - } else if let event = event as? ARTPushActivationEventGettingDeviceRegistrationFailed { + } else if let event = event as? PushActivationEventGettingDeviceRegistrationFailed { XCTAssertEqual(event.error.domain, ARTAblyErrorDomain) XCTAssertEqual(event.error.code, simulatedError.code) stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertEqual(httpExecutor.requests.count, 1) let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations" } XCTAssertEqual(requests.count, 1) @@ -407,7 +407,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__026__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GotPushDeviceDetails__should_transition_to_WaitingForDeviceRegistration() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) let delegate = StateMachineDelegate() stateMachine.delegate = delegate @@ -421,15 +421,15 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventGotPushDeviceDetails { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + if event is PushActivationEventGotPushDeviceDetails { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) partialDone() - } else if event is ARTPushActivationEventGotDeviceRegistration { + } else if event is PushActivationEventGotDeviceRegistration { stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventGotPushDeviceDetails()) + stateMachine.send(PushActivationEventGotPushDeviceDetails()) } XCTAssertTrue(setAndPersistIdentityTokenDetailsCalled) @@ -439,7 +439,7 @@ class PushActivationStateMachineTests: XCTestCase { func test__019__Activation_state_machine__State_WaitingForPushDeviceDetails__on_Event_GettingPushDeviceDetailsFailed() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - let expectedError = ARTErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) + let expectedError = ErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) let delegate = StateMachineDelegate() stateMachine.delegate = delegate @@ -449,17 +449,17 @@ class PushActivationStateMachineTests: XCTestCase { XCTAssertEqual(error, expectedError) done() } - stateMachine.send(ARTPushActivationEventGettingPushDeviceDetailsFailed(error: expectedError)) + stateMachine.send(PushActivationEventGettingPushDeviceDetailsFailed(error: expectedError)) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) } // https://github.com/ably/ably-cocoa/issues/966 func test__020__Activation_state_machine__State_WaitingForPushDeviceDetails__when_initializing_from_persistent_state_with_a_deviceToken__GotPushDeviceDetails_should_be_re_emitted() { beforeEach__Activation_state_machine__State_WaitingForPushDeviceDetails() - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage rest.device.setAndPersistAPNSDeviceToken("foo") defer { rest.device.setAndPersistAPNSDeviceToken(nil) } @@ -467,7 +467,7 @@ class PushActivationStateMachineTests: XCTestCase { var registered = false let delegate = StateMachineDelegateCustomCallbacks() - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: delegate, logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: delegate, logger: .init(core: MockInternalLogCore())) delegate.onPushCustomRegister = { _, _ in registered = true return nil @@ -479,9 +479,9 @@ class PushActivationStateMachineTests: XCTestCase { // RSH3c func beforeEach__Activation_state_machine__State_WaitingForDeviceRegistration() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeviceRegistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeviceRegistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) rest.internal.setupLocalDevice_nosync() } @@ -489,8 +489,8 @@ class PushActivationStateMachineTests: XCTestCase { func test__027__Activation_state_machine__State_WaitingForDeviceRegistration__on_Event_CalledActivate() { beforeEach__Activation_state_machine__State_WaitingForDeviceRegistration() - stateMachine.send(ARTPushActivationEventCalledActivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeviceRegistration.self)) + stateMachine.send(PushActivationEventCalledActivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeviceRegistration.self)) } // RSH3c2 / RSH8c @@ -511,7 +511,7 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hookDevice.remove() } - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -519,8 +519,8 @@ class PushActivationStateMachineTests: XCTestCase { clientId: "" ) - stateMachine.send(ARTPushActivationEventGotDeviceRegistration(identityTokenDetails: testIdentityTokenDetails)) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForNewPushDeviceDetails.self)) + stateMachine.send(PushActivationEventGotDeviceRegistration(identityTokenDetails: testIdentityTokenDetails)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForNewPushDeviceDetails.self)) XCTAssertTrue(activatedCallbackCalled) XCTAssertTrue(setAndPersistIdentityTokenDetailsCalled) expect(storage.keysWritten.keys).to(contain(["ARTDeviceId", "ARTDeviceSecret", "ARTDeviceIdentityToken"])) @@ -530,29 +530,29 @@ class PushActivationStateMachineTests: XCTestCase { func test__029__Activation_state_machine__State_WaitingForDeviceRegistration__on_Event_GettingDeviceRegistrationFailed() { beforeEach__Activation_state_machine__State_WaitingForDeviceRegistration() - let expectedError = ARTErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) + let expectedError = ErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) var activatedCallbackCalled = false let hook = stateMachine.testSuite_getArgument(from: NSSelectorFromString("callActivatedCallback:"), at: 0, callback: { arg0 in activatedCallbackCalled = true - guard let error = arg0 as? ARTErrorInfo else { + guard let error = arg0 as? ErrorInfo else { fail("Error is missing"); return } XCTAssertEqual(error, expectedError) }) defer { hook.remove() } - stateMachine.send(ARTPushActivationEventGettingDeviceRegistrationFailed(error: expectedError)) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + stateMachine.send(PushActivationEventGettingDeviceRegistrationFailed(error: expectedError)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertTrue(activatedCallbackCalled) } // RSH3d func beforeEach__Activation_state_machine__State_WaitingForNewPushDeviceDetails() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForNewPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForNewPushDeviceDetails(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) rest.internal.setupLocalDevice_nosync() } @@ -566,8 +566,8 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hook.remove() } - stateMachine.send(ARTPushActivationEventCalledActivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForNewPushDeviceDetails.self)) + stateMachine.send(PushActivationEventCalledActivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForNewPushDeviceDetails.self)) XCTAssertTrue(activatedCallbackCalled) } @@ -604,14 +604,14 @@ class PushActivationStateMachineTests: XCTestCase { } // RSH3e - func reusableTestsTestStateWaitingForRegistrationSyncThrough(_ fromEvent: ARTPushActivationEvent, testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil) { + func reusableTestsTestStateWaitingForRegistrationSyncThrough(_ fromEvent: PushActivationEvent, testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil) { func beforeEach() { contextBeforeEach?() - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForRegistrationSync(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()), from: fromEvent)) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForRegistrationSync(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()), from: fromEvent)) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - (stateMachine.current as! ARTPushActivationStateWaitingForRegistrationSync).fromEvent = fromEvent + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + (stateMachine.current as! PushActivationStateWaitingForRegistrationSync).fromEvent = fromEvent } // RSH3e1 @@ -624,9 +624,9 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hook.remove() } - stateMachine.send(ARTPushActivationEventCalledActivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForRegistrationSync.self)) - if !fromEvent.isKind(of: ARTPushActivationEventCalledActivate.self) { XCTAssertTrue(activatedCallbackCalled) + stateMachine.send(PushActivationEventCalledActivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForRegistrationSync.self)) + if !fromEvent.isKind(of: PushActivationEventCalledActivate.self) { XCTAssertTrue(activatedCallbackCalled) XCTAssertEqual(stateMachine.pendingEvents.count, 0) } else { XCTAssertFalse(activatedCallbackCalled) @@ -661,7 +661,7 @@ class PushActivationStateMachineTests: XCTestCase { updatedCallbackCalled = true } - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -669,14 +669,14 @@ class PushActivationStateMachineTests: XCTestCase { clientId: "" ) - stateMachine.send(ARTPushActivationEventRegistrationSynced(identityTokenDetails: testIdentityTokenDetails)) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForNewPushDeviceDetails.self)) + stateMachine.send(PushActivationEventRegistrationSynced(identityTokenDetails: testIdentityTokenDetails)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForNewPushDeviceDetails.self)) XCTAssertTrue(setAndPersistIdentityTokenDetailsCalled) // RSH3e2c - expect(updatedCallbackCalled).toEventually(equal(!(fromEvent is ARTPushActivationEventCalledActivate)), timeout: testTimeout) + expect(updatedCallbackCalled).toEventually(equal(!(fromEvent is PushActivationEventCalledActivate)), timeout: testTimeout) // RSH3e2b - expect(activateCallbackCalled).toEventually(equal(fromEvent is ARTPushActivationEventCalledActivate), timeout: testTimeout) + expect(activateCallbackCalled).toEventually(equal(fromEvent is PushActivationEventCalledActivate), timeout: testTimeout) contextAfterEach?() } @@ -685,12 +685,12 @@ class PushActivationStateMachineTests: XCTestCase { func test__on_Event_SyncRegistrationFailed() { beforeEach() - let expectedError = ARTErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) + let expectedError = ErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) var updatedCallbackCalled = false let hook = stateMachine.testSuite_getArgument(from: NSSelectorFromString("callUpdatedCallback:"), at: 0, callback: { arg0 in updatedCallbackCalled = true - guard let error = arg0 as? ARTErrorInfo else { + guard let error = arg0 as? ErrorInfo else { fail("Error is missing"); return } XCTAssertEqual(error, expectedError) @@ -706,13 +706,13 @@ class PushActivationStateMachineTests: XCTestCase { activateCallbackCalled = true } - stateMachine.send(ARTPushActivationEventSyncRegistrationFailed(error: expectedError)) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateAfterRegistrationSyncFailed.self)) + stateMachine.send(PushActivationEventSyncRegistrationFailed(error: expectedError)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateAfterRegistrationSyncFailed.self)) // RSH3e3a - expect(updatedCallbackCalled).toEventually(equal(!(fromEvent is ARTPushActivationEventCalledActivate)), timeout: testTimeout) + expect(updatedCallbackCalled).toEventually(equal(!(fromEvent is PushActivationEventCalledActivate)), timeout: testTimeout) // RSH3e3c - expect(activateCallbackCalled).toEventually(equal(fromEvent is ARTPushActivationEventCalledActivate), timeout: testTimeout) + expect(activateCallbackCalled).toEventually(equal(fromEvent is PushActivationEventCalledActivate), timeout: testTimeout) contextAfterEach?() } @@ -727,44 +727,44 @@ class PushActivationStateMachineTests: XCTestCase { } } - func reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough) { - reusableTestsTestStateWaitingForRegistrationSyncThrough(ARTPushActivationEventCalledActivate(), testCase: testCase) + func reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough) { + reusableTestsTestStateWaitingForRegistrationSyncThrough(PushActivationEventCalledActivate(), testCase: testCase) } - func test__036__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__on_Event_CalledActivate() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_CalledActivate) + func test__036__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__on_Event_CalledActivate() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_CalledActivate) } - func test__037__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__on_Event_RegistrationSynced() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_RegistrationSynced) + func test__037__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__on_Event_RegistrationSynced() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_RegistrationSynced) } - func test__038__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__on_Event_SyncRegistrationFailed() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_SyncRegistrationFailed) + func test__038__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__on_Event_SyncRegistrationFailed() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventCalledActivate__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_SyncRegistrationFailed) } - func reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough) { - reusableTestsTestStateWaitingForRegistrationSyncThrough(ARTPushActivationEventGotPushDeviceDetails(), testCase: testCase) + func reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: TestCase_ReusableTestsTestStateWaitingForRegistrationSyncThrough) { + reusableTestsTestStateWaitingForRegistrationSyncThrough(PushActivationEventGotPushDeviceDetails(), testCase: testCase) } - func test__039__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__on_Event_CalledActivate() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_CalledActivate) + func test__039__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__on_Event_CalledActivate() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_CalledActivate) } - func test__040__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__on_Event_RegistrationSynced() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_RegistrationSynced) + func test__040__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__on_Event_RegistrationSynced() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_RegistrationSynced) } - func test__041__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__on_Event_SyncRegistrationFailed() { - reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_ARTPushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_SyncRegistrationFailed) + func test__041__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__on_Event_SyncRegistrationFailed() { + reusableTestsWrapper__Activation_state_machine__State_WaitingForRegistrationSync_through_PushActivationEventGotPushDeviceDetails__reusableTestsTestStateWaitingForRegistrationSyncThrough(testCase: .on_Event_SyncRegistrationFailed) } // RSH3f func beforeEach__Activation_state_machine__State_AfterRegistrationSyncFailed() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateAfterRegistrationSyncFailed(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateAfterRegistrationSyncFailed(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) } // RSH3f1 @@ -832,28 +832,28 @@ class PushActivationStateMachineTests: XCTestCase { // RSH3g func beforeEach__Activation_state_machine__State_WaitingForDeregistration() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) } // RSH3g1 func test__053__Activation_state_machine__State_WaitingForDeregistration__on_Event_CalledDeactivate() { beforeEach__Activation_state_machine__State_WaitingForDeregistration() - stateMachine.send(ARTPushActivationEventCalledDeactivate()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + stateMachine.send(PushActivationEventCalledDeactivate()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) } // RSH3g2 func test__054__Activation_state_machine__State_WaitingForDeregistration__on_Event_Deregistered() { - storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.clientId = "client1" - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = storage - stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) rest.internal.setupLocalDevice_nosync() @@ -871,8 +871,8 @@ class PushActivationStateMachineTests: XCTestCase { } defer { hookDevice.remove() } - stateMachine.send(ARTPushActivationEventDeregistered()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + stateMachine.send(PushActivationEventDeregistered()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertTrue(deactivatedCallbackCalled) XCTAssertTrue(resetDetailsCalled) @@ -882,8 +882,8 @@ class PushActivationStateMachineTests: XCTestCase { XCTAssertNil(stateMachine.rest.device.push.recipient["push"]) XCTAssertNil(storage.object(forKey: ARTDeviceIdentityTokenKey)) - XCTAssertNil(ARTLocalDevice.apnsDeviceToken(ofType: ARTAPNSDeviceDefaultTokenType, from: storage)) - XCTAssertNil(ARTLocalDevice.apnsDeviceToken(ofType: ARTAPNSDeviceLocationTokenType, from: storage)) + XCTAssertNil(LocalDevice.apnsDeviceToken(ofType: ARTAPNSDeviceDefaultTokenType, from: storage)) + XCTAssertNil(LocalDevice.apnsDeviceToken(ofType: ARTAPNSDeviceLocationTokenType, from: storage)) // Should be replaced with `nil` checks after issue https://github.com/ably/specification/issues/180 resolved XCTAssertNotNil(stateMachine.rest.device.id) @@ -896,20 +896,20 @@ class PushActivationStateMachineTests: XCTestCase { func test__055__Activation_state_machine__State_WaitingForDeregistration__on_Event_DeregistrationFailed() { beforeEach__Activation_state_machine__State_WaitingForDeregistration() - let expectedError = ARTErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) + let expectedError = ErrorInfo(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) var deactivatedCallbackCalled = false let hook = stateMachine.testSuite_getArgument(from: NSSelectorFromString("callDeactivatedCallback:"), at: 0, callback: { arg0 in deactivatedCallbackCalled = true - guard let error = arg0 as? ARTErrorInfo else { + guard let error = arg0 as? ErrorInfo else { fail("Error is missing"); return } XCTAssertEqual(error, expectedError) }) defer { hook.remove() } - stateMachine.send(ARTPushActivationEventDeregistrationFailed(error: expectedError)) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + stateMachine.send(PushActivationEventDeregistrationFailed(error: expectedError)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) XCTAssertTrue(deactivatedCallbackCalled) } @@ -917,15 +917,15 @@ class PushActivationStateMachineTests: XCTestCase { func test__056__Activation_state_machine__should_be_possible_to_activate_and_deactivate_and_then_activate_again_with_different_clientId() { beforeEach__Activation_state_machine__State_NotActivated() - let options1 = ARTClientOptions(key: "xxxx:xxxx") + let options1 = ClientOptions(key: "xxxx:xxxx") options1.clientId = "client1" - let rest1 = ARTRest(options: options1) + let rest1 = Rest(options: options1) httpExecutor = MockHTTPExecutor() rest1.internal.httpExecutor = httpExecutor rest1.internal.storage = storage let stateMachineDelegate = StateMachineDelegate() - let stateMachine1 = ARTPushActivationStateMachine(rest: rest1.internal, delegate: stateMachineDelegate, logger: .init(core: MockInternalLogCore())) + let stateMachine1 = PushActivationStateMachine(rest: rest1.internal, delegate: stateMachineDelegate, logger: .init(core: MockInternalLogCore())) let testDeviceToken = "xxxx-xxxx-xxxx-xxxx-xxxx" stateMachine1.rest.device.setAndPersistAPNSDeviceToken(testDeviceToken) @@ -934,33 +934,33 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) stateMachine1.transitions = { event, _, _ in - if event is ARTPushActivationEventCalledActivate { + if event is PushActivationEventCalledActivate { XCTAssertEqual(rest1.internal.device_nosync.clientId, "client1") partialDone() } - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { partialDone() - stateMachine1.send(ARTPushActivationEventCalledDeactivate()) + stateMachine1.send(PushActivationEventCalledDeactivate()) } - if event is ARTPushActivationEventCalledDeactivate { + if event is PushActivationEventCalledDeactivate { partialDone() } } - stateMachine1.send(ARTPushActivationEventCalledActivate()) + stateMachine1.send(PushActivationEventCalledActivate()) } XCTAssertNil(rest1.device.clientId) // after deactivation, RSH3g2a - let options2 = ARTClientOptions(key: "xxxx:xxxx") + let options2 = ClientOptions(key: "xxxx:xxxx") options2.clientId = "client2" - let rest2 = ARTRest(options: options2) + let rest2 = Rest(options: options2) rest2.internal.storage = storage rest2.internal.httpExecutor = httpExecutor XCTAssertNil(rest2.device.clientId) - let stateMachine2 = ARTPushActivationStateMachine(rest: rest2.internal, delegate: stateMachineDelegate, logger: .init(core: MockInternalLogCore())) - stateMachine2.send(ARTPushActivationEventCalledActivate()) + let stateMachine2 = PushActivationStateMachine(rest: rest2.internal, delegate: stateMachineDelegate, logger: .init(core: MockInternalLogCore())) + stateMachine2.send(PushActivationEventCalledActivate()) XCTAssertEqual(rest2.device.clientId, "client2") XCTAssertTrue(rest1.device === rest2.device) @@ -969,35 +969,35 @@ class PushActivationStateMachineTests: XCTestCase { // RSH4 func test__005__Activation_state_machine__should_queue_event_that_has_no_transition_defined_for_it() throws { // Start with WaitingForDeregistration state - let storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + let storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) stateMachine.transitions = { _, _, _ in fail("Should not handle the CalledActivate event because it should be queued") } - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) expect(stateMachine.pendingEvents).toEventually(haveCount(1), timeout: testTimeout) stateMachine.transitions = nil let pendingEvent = try XCTUnwrap(stateMachine.pendingEvents.firstObject, "Pending event is missing") - expect(pendingEvent).to(beAKindOf(ARTPushActivationEventCalledActivate.self)) + expect(pendingEvent).to(beAKindOf(PushActivationEventCalledActivate.self)) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, previousState, currentState in - if previousState is ARTPushActivationStateWaitingForDeregistration, currentState is ARTPushActivationStateNotActivated { + if previousState is PushActivationStateWaitingForDeregistration, currentState is PushActivationStateNotActivated { // Handle Deregistered event partialDone() - } else if event is ARTPushActivationEventDeregistered, previousState is ARTPushActivationStateNotActivated, currentState is ARTPushActivationStateWaitingForPushDeviceDetails { + } else if event is PushActivationEventDeregistered, previousState is PushActivationStateNotActivated, currentState is PushActivationStateWaitingForPushDeviceDetails { // Consume queued CalledActivate event partialDone() } } - stateMachine.send(ARTPushActivationEventDeregistered()) - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + stateMachine.send(PushActivationEventDeregistered()) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) } stateMachine.transitions = nil @@ -1006,14 +1006,14 @@ class PushActivationStateMachineTests: XCTestCase { // RSH5 func test__006__Activation_state_machine__event_handling_sould_be_atomic_and_sequential() { - let storage = MockDeviceStorage(startWith: ARTPushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) + let storage = MockDeviceStorage(startWith: PushActivationStateWaitingForDeregistration(machine: initialStateMachine, logger: .init(core: MockInternalLogCore()))) rest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) - stateMachine.send(ARTPushActivationEventCalledActivate()) + let stateMachine = PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + stateMachine.send(PushActivationEventCalledActivate()) DispatchQueue(label: "QueueA").sync { - stateMachine.send(ARTPushActivationEventDeregistered()) + stateMachine.send(PushActivationEventDeregistered()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForPushDeviceDetails.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForPushDeviceDetails.self)) } func test__001__should_remove_identityTokenDetails_from_cache_and_storage() { @@ -1039,34 +1039,34 @@ class PushActivationStateMachineTests: XCTestCase { func test__the_local_device_has_id_and_deviceIdentityToken__emits_a_SyncRegistrationFailed_event_with_code_61002_if_client_IDs_don_t_match() { contextBeforeEach?() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.clientId = "deviceClient" - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = storage rest.internal.setupLocalDevice_nosync() XCTAssertEqual(rest.device.clientId, "deviceClient") - let newOptions = ARTClientOptions(key: "xxxx:xxxx") + let newOptions = ClientOptions(key: "xxxx:xxxx") newOptions.clientId = "instanceClient" - let newRest = ARTRest(options: newOptions) + let newRest = Rest(options: newOptions) newRest.internal.storage = storage - let stateMachine = ARTPushActivationStateMachine(rest: newRest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) + let stateMachine = PushActivationStateMachine(rest: newRest.internal, delegate: StateMachineDelegate(), logger: .init(core: MockInternalLogCore())) storage.simulateOnNextRead(string: testDeviceId, for: ARTDeviceIdKey) - let testDeviceIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "deviceClient") + let testDeviceIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "deviceClient") stateMachine.rest.device.setAndPersistIdentityTokenDetails(testDeviceIdentityTokenDetails) defer { stateMachine.rest.device.setAndPersistIdentityTokenDetails(nil) } waitUntil(timeout: testTimeout) { done in stateMachine.transitions = { event, _, _ in - if let event = event as? ARTPushActivationEventSyncRegistrationFailed { + if let event = event as? PushActivationEventSyncRegistrationFailed { XCTAssertEqual(event.error.code, 61002) done() } } - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) } contextAfterEach?() @@ -1077,7 +1077,7 @@ class PushActivationStateMachineTests: XCTestCase { storage.simulateOnNextRead(string: testDeviceId, for: ARTDeviceIdKey) - let testDeviceIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testDeviceIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") stateMachine.rest.device.setAndPersistIdentityTokenDetails(testDeviceIdentityTokenDetails) } @@ -1096,10 +1096,10 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledActivate { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForRegistrationSync.self)) + if event is PushActivationEventCalledActivate { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForRegistrationSync.self)) partialDone() - } else if event is ARTPushActivationEventRegistrationSynced { + } else if event is PushActivationEventRegistrationSynced { stateMachine.transitions = nil partialDone() } @@ -1110,7 +1110,7 @@ class PushActivationStateMachineTests: XCTestCase { partialDone() return nil } - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) } XCTAssertEqual(httpExecutor.requests.count, 0) @@ -1128,15 +1128,15 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledActivate { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForRegistrationSync.self)) + if event is PushActivationEventCalledActivate { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForRegistrationSync.self)) partialDone() - } else if event is ARTPushActivationEventRegistrationSynced || event is ARTPushActivationEventSyncRegistrationFailed { + } else if event is PushActivationEventRegistrationSynced || event is PushActivationEventSyncRegistrationFailed { stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventCalledActivate()) + stateMachine.send(PushActivationEventCalledActivate()) } let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations/\(rest.device.id)" } @@ -1187,11 +1187,11 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledDeactivate { + if event is PushActivationEventCalledDeactivate { // RSH3d2d - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) partialDone() - } else if event is ARTPushActivationEventDeregistered { + } else if event is PushActivationEventDeregistered { stateMachine.transitions = nil partialDone() } @@ -1202,10 +1202,10 @@ class PushActivationStateMachineTests: XCTestCase { partialDone() return nil } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertEqual(httpExecutor.requests.count, 0) contextAfterEach?() @@ -1222,10 +1222,10 @@ class PushActivationStateMachineTests: XCTestCase { let simulatedError = NSError(domain: ARTAblyErrorDomain, code: 1234, userInfo: nil) let partialDone = AblyTests.splitDone(3, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledDeactivate { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + if event is PushActivationEventCalledDeactivate { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) partialDone() - } else if let event = event as? ARTPushActivationEventDeregistrationFailed { + } else if let event = event as? PushActivationEventDeregistrationFailed { XCTAssertEqual(event.error.domain, ARTAblyErrorDomain) XCTAssertEqual(event.error.code, simulatedError.code) stateMachine.transitions = nil @@ -1238,10 +1238,10 @@ class PushActivationStateMachineTests: XCTestCase { partialDone() return simulatedError } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) XCTAssertEqual(httpExecutor.requests.count, 0) contextAfterEach?() @@ -1262,19 +1262,19 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledDeactivate { + if event is PushActivationEventCalledDeactivate { // RSH3d2d - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) partialDone() - } else if event is ARTPushActivationEventDeregistered { + } else if event is PushActivationEventDeregistered { stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertEqual(httpExecutor.requests.count, 1) let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations/\(deviceId)" } XCTAssertEqual(requests.count, 1) @@ -1300,7 +1300,7 @@ class PushActivationStateMachineTests: XCTestCase { let delegate = StateMachineDelegate() stateMachine.delegate = delegate - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -1318,19 +1318,19 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledDeactivate { + if event is PushActivationEventCalledDeactivate { // RSH3d2d - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) partialDone() - } else if event is ARTPushActivationEventDeregistered { + } else if event is PushActivationEventDeregistered { stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateNotActivated.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateNotActivated.self)) XCTAssertEqual(httpExecutor.requests.count, 1) let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations/\(deviceId)" } XCTAssertEqual(requests.count, 1) @@ -1363,20 +1363,20 @@ class PushActivationStateMachineTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, currentState in - if event is ARTPushActivationEventCalledDeactivate { - expect(currentState).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + if event is PushActivationEventCalledDeactivate { + expect(currentState).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) partialDone() - } else if let event = event as? ARTPushActivationEventDeregistrationFailed { + } else if let event = event as? PushActivationEventDeregistrationFailed { XCTAssertEqual(event.error.domain, ARTAblyErrorDomain) XCTAssertEqual(event.error.code, simulatedError.code) stateMachine.transitions = nil partialDone() } } - stateMachine.send(ARTPushActivationEventCalledDeactivate()) + stateMachine.send(PushActivationEventCalledDeactivate()) } - expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForDeregistration.self)) + expect(stateMachine.current).to(beAKindOf(PushActivationStateWaitingForDeregistration.self)) XCTAssertEqual(httpExecutor.requests.count, 1) let requests = httpExecutor.requests.compactMap { $0.url?.path }.filter { $0 == "/push/deviceRegistrations/\(rest.device.id)" } XCTAssertEqual(requests.count, 1) @@ -1405,25 +1405,25 @@ class PushActivationStateMachineTests: XCTestCase { } } -class StateMachineDelegate: NSObject, ARTPushRegistererDelegate { - var onDidActivateAblyPush: ((ARTErrorInfo?) -> Void)? - var onDidUpdateAblyPush: ((ARTErrorInfo?) -> Void)? - var onDidDeactivateAblyPush: ((ARTErrorInfo?) -> Void)? - var onDidAblyPushRegistrationFail: ((ARTErrorInfo?) -> Void)? +class StateMachineDelegate: NSObject, PushRegistererDelegate { + var onDidActivateAblyPush: ((ErrorInfo?) -> Void)? + var onDidUpdateAblyPush: ((ErrorInfo?) -> Void)? + var onDidDeactivateAblyPush: ((ErrorInfo?) -> Void)? + var onDidAblyPushRegistrationFail: ((ErrorInfo?) -> Void)? - func didActivateAblyPush(_ error: ARTErrorInfo?) { + func didActivateAblyPush(_ error: ErrorInfo?) { onDidActivateAblyPush?(error) } - func didUpdateAblyPush(_ error: ARTErrorInfo?) { + func didUpdateAblyPush(_ error: ErrorInfo?) { onDidUpdateAblyPush?(error) } - func didDeactivateAblyPush(_ error: ARTErrorInfo?) { + func didDeactivateAblyPush(_ error: ErrorInfo?) { onDidDeactivateAblyPush?(error) } - func didAblyPushRegistrationFail(_ error: ARTErrorInfo?) { + func didAblyPushRegistrationFail(_ error: ErrorInfo?) { onDidAblyPushRegistrationFail?(error) } } @@ -1431,16 +1431,16 @@ class StateMachineDelegate: NSObject, ARTPushRegistererDelegate { typealias ARTDeviceId = String class StateMachineDelegateCustomCallbacks: StateMachineDelegate { - var onPushCustomRegister: ((ARTErrorInfo?, ARTDeviceDetails?) -> NSError?)? - var onPushCustomRegisterIdentity: ((ARTErrorInfo?, ARTDeviceDetails?) throws -> ARTDeviceIdentityTokenDetails)? - var onPushCustomDeregister: ((ARTErrorInfo?, ARTDeviceId?) -> NSError?)? + var onPushCustomRegister: ((ErrorInfo?, DeviceDetails?) -> NSError?)? + var onPushCustomRegisterIdentity: ((ErrorInfo?, DeviceDetails?) throws -> DeviceIdentityTokenDetails)? + var onPushCustomDeregister: ((ErrorInfo?, ARTDeviceId?) -> NSError?)? - func ablyPushCustomRegister(_ error: ARTErrorInfo?, deviceDetails: ARTDeviceDetails?, callback: @escaping (ARTDeviceIdentityTokenDetails?, ARTErrorInfo?) -> Void) { + func ablyPushCustomRegister(_ error: ErrorInfo?, deviceDetails: DeviceDetails?, callback: @escaping (DeviceIdentityTokenDetails?, ErrorInfo?) -> Void) { var registerError: NSError? - var identity: ARTDeviceIdentityTokenDetails? + var identity: DeviceIdentityTokenDetails? if let register = onPushCustomRegister { registerError = register(error, deviceDetails) - identity = ARTDeviceIdentityTokenDetails(token: "123456", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + identity = DeviceIdentityTokenDetails(token: "123456", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") } else { do { identity = try onPushCustomRegisterIdentity!(error, deviceDetails) @@ -1449,14 +1449,14 @@ class StateMachineDelegateCustomCallbacks: StateMachineDelegate { } } delay(0) { - callback(identity, registerError == nil ? nil : ARTErrorInfo.create(from: registerError!)) + callback(identity, registerError == nil ? nil : ErrorInfo.create(from: registerError!)) } } - func ablyPushCustomDeregister(_ error: ARTErrorInfo?, deviceId: String?, callback: ((ARTErrorInfo?) -> Void)? = nil) { + func ablyPushCustomDeregister(_ error: ErrorInfo?, deviceId: String?, callback: ((ErrorInfo?) -> Void)? = nil) { let error = onPushCustomDeregister?(error, deviceId) delay(0) { - callback?(error == nil ? nil : ARTErrorInfo.create(from: error!)) + callback?(error == nil ? nil : ErrorInfo.create(from: error!)) } } } diff --git a/Test/Tests/PushAdminTests.swift b/Test/Tests/PushAdminTests.swift index 852b45221..d994ce29c 100644 --- a/Test/Tests/PushAdminTests.swift +++ b/Test/Tests/PushAdminTests.swift @@ -2,10 +2,10 @@ import Ably import Nimble import XCTest -private var rest: ARTRest! +private var rest: Rest! private var mockHttpExecutor: MockHTTPExecutor! private var storage: MockDeviceStorage! -private var localDevice: ARTLocalDevice! +private var localDevice: LocalDevice! private let recipient = [ "clientId": "bob", @@ -19,11 +19,11 @@ private let payload = [ private let quxChannelName = "pushenabled:qux" -private let subscription = ARTPushChannelSubscription(clientId: "newClient", channel: quxChannelName) +private let subscription = PushChannelSubscription(clientId: "newClient", channel: quxChannelName) class PushAdminTests: XCTestCase { - private static let deviceDetails: ARTDeviceDetails = { - let deviceDetails = ARTDeviceDetails(id: "testDeviceDetails") + private static let deviceDetails: DeviceDetails = { + let deviceDetails = DeviceDetails(id: "testDeviceDetails") deviceDetails.platform = "ios" deviceDetails.formFactor = "phone" deviceDetails.metadata = [String : String]() @@ -34,8 +34,8 @@ class PushAdminTests: XCTestCase { return deviceDetails }() - private static let deviceDetails1ClientA: ARTDeviceDetails = { - let deviceDetails = ARTDeviceDetails(id: "deviceDetails1ClientA") + private static let deviceDetails1ClientA: DeviceDetails = { + let deviceDetails = DeviceDetails(id: "deviceDetails1ClientA") deviceDetails.platform = "android" deviceDetails.formFactor = "tablet" deviceDetails.clientId = "clientA" @@ -47,8 +47,8 @@ class PushAdminTests: XCTestCase { return deviceDetails }() - private static let deviceDetails2ClientA: ARTDeviceDetails = { - let deviceDetails = ARTDeviceDetails(id: "deviceDetails2ClientA") + private static let deviceDetails2ClientA: DeviceDetails = { + let deviceDetails = DeviceDetails(id: "deviceDetails2ClientA") deviceDetails.platform = "android" deviceDetails.formFactor = "tablet" deviceDetails.clientId = "clientA" @@ -60,8 +60,8 @@ class PushAdminTests: XCTestCase { return deviceDetails }() - private static let deviceDetails3ClientB: ARTDeviceDetails = { - let deviceDetails = ARTDeviceDetails(id: "deviceDetails3ClientB") + private static let deviceDetails3ClientB: DeviceDetails = { + let deviceDetails = DeviceDetails(id: "deviceDetails3ClientB") deviceDetails.platform = "android" deviceDetails.formFactor = "tablet" deviceDetails.clientId = "clientB" @@ -73,21 +73,21 @@ class PushAdminTests: XCTestCase { return deviceDetails }() - private static let allDeviceDetails: [ARTDeviceDetails] = [ + private static let allDeviceDetails: [DeviceDetails] = [ deviceDetails, deviceDetails1ClientA, deviceDetails2ClientA, deviceDetails3ClientB, ] - private static let subscriptionFooDevice1 = ARTPushChannelSubscription(deviceId: "deviceDetails1ClientA", channel: "pushenabled:foo") - private static let subscriptionFooDevice2 = ARTPushChannelSubscription(deviceId: "deviceDetails2ClientA", channel: "pushenabled:foo") - private static let subscriptionBarDevice2 = ARTPushChannelSubscription(deviceId: "deviceDetails2ClientA", channel: "pushenabled:bar") - private static let subscriptionFooClientA = ARTPushChannelSubscription(clientId: "clientA", channel: "pushenabled:foo") - private static let subscriptionFooClientB = ARTPushChannelSubscription(clientId: "clientB", channel: "pushenabled:foo") - private static let subscriptionBarClientB = ARTPushChannelSubscription(clientId: "clientB", channel: "pushenabled:bar") + private static let subscriptionFooDevice1 = PushChannelSubscription(deviceId: "deviceDetails1ClientA", channel: "pushenabled:foo") + private static let subscriptionFooDevice2 = PushChannelSubscription(deviceId: "deviceDetails2ClientA", channel: "pushenabled:foo") + private static let subscriptionBarDevice2 = PushChannelSubscription(deviceId: "deviceDetails2ClientA", channel: "pushenabled:bar") + private static let subscriptionFooClientA = PushChannelSubscription(clientId: "clientA", channel: "pushenabled:foo") + private static let subscriptionFooClientB = PushChannelSubscription(clientId: "clientB", channel: "pushenabled:foo") + private static let subscriptionBarClientB = PushChannelSubscription(clientId: "clientB", channel: "pushenabled:bar") - private static let allSubscriptions: [ARTPushChannelSubscription] = [ + private static let allSubscriptions: [PushChannelSubscription] = [ subscriptionFooDevice1, subscriptionFooDevice2, subscriptionBarDevice2, @@ -104,7 +104,7 @@ class PushAdminTests: XCTestCase { override class func setUp() { super.setUp() let test = Test() // a slight abuse of the meaning of Test, but we only have one instance of +setUp so doesn’t seem worth worrying over - let options: ARTClientOptions + let options: ClientOptions do { options = try AblyTests.commonAppSetup(for: test) } catch { @@ -112,7 +112,7 @@ class PushAdminTests: XCTestCase { } options.pushFullWait = true options.dispatchQueue = AblyTests.createUserQueue(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = MockDeviceStorage() let group = DispatchGroup() @@ -138,14 +138,14 @@ class PushAdminTests: XCTestCase { override class func tearDown() { let test = Test() // a slight abuse of the meaning of Test, but we only have one instance of +tearDown so doesn’t seem worth worrying over - let options: ARTClientOptions + let options: ClientOptions do { options = try AblyTests.commonAppSetup(for: test) } catch { fatalError("commonAppSetup failed: \(error)") } options.dispatchQueue = AblyTests.createUserQueue(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = MockDeviceStorage() let group = DispatchGroup() @@ -183,7 +183,7 @@ class PushAdminTests: XCTestCase { override func setUp() { super.setUp() - rest = ARTRest(key: "xxxx:xxxx") + rest = Rest(key: "xxxx:xxxx") mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor storage = MockDeviceStorage() @@ -226,7 +226,7 @@ class PushAdminTests: XCTestCase { func skipped__test__002__publish__should_publish_successfully() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well let publishObject = ["transportType": "ablyChannel", @@ -259,7 +259,7 @@ class PushAdminTests: XCTestCase { func skipped__test__003__publish__should_fail_with_a_bad_recipient() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well @@ -287,7 +287,7 @@ class PushAdminTests: XCTestCase { func skipped__test__004__publish__should_fail_with_an_empty_recipient() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well @@ -314,7 +314,7 @@ class PushAdminTests: XCTestCase { func test__005__publish__should_fail_with_an_empty_payload() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } let channel = realtime.channels.get("pushenabled:\(test.uniqueChannelName())") // works with pure test.uniqueChannelName() as well @@ -343,7 +343,7 @@ class PushAdminTests: XCTestCase { func test__006__Device_Registrations__get__should_return_a_device() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.get("testDeviceDetails") { device, error in @@ -359,7 +359,7 @@ class PushAdminTests: XCTestCase { func test__007__Device_Registrations__get__should_not_return_a_device_if_it_doesnt_exist() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.get("madeup") { device, error in @@ -376,11 +376,11 @@ class PushAdminTests: XCTestCase { func test__008__Device_Registrations__get__push_device_authentication__should_include_DeviceIdentityToken_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -406,7 +406,7 @@ class PushAdminTests: XCTestCase { func test__009__Device_Registrations__get__push_device_authentication__should_include_DeviceSecret_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor @@ -426,7 +426,7 @@ class PushAdminTests: XCTestCase { func test__010__Device_Registrations__list__should_list_devices_by_id() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.list(["deviceId": "testDeviceDetails"]) { result, error in @@ -442,7 +442,7 @@ class PushAdminTests: XCTestCase { func test__011__Device_Registrations__list__should_list_devices_by_client_id() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.list(["clientId": "clientA"]) { result, error in @@ -458,7 +458,7 @@ class PushAdminTests: XCTestCase { func test__012__Device_Registrations__list__should_list_devices_sorted() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.list(["direction": "forwards"]) { result, error in @@ -474,7 +474,7 @@ class PushAdminTests: XCTestCase { func test__013__Device_Registrations__list__should_return_an_empty_list_when_id_does_not_exist() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.deviceRegistrations.list(["deviceId": "madeup"]) { result, error in @@ -494,7 +494,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in @@ -517,7 +517,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in @@ -538,11 +538,11 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -572,7 +572,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor @@ -596,7 +596,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let params = [ @@ -672,7 +672,7 @@ class PushAdminTests: XCTestCase { func test__019__Channel_Subscriptions__save__should_add_a_subscription() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let testProxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) realtime.internal.rest.httpExecutor = testProxyHTTPExecutor @@ -693,9 +693,9 @@ class PushAdminTests: XCTestCase { func test__020__Channel_Subscriptions__save__should_update_a_subscription() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } - let updateSubscription = ARTPushChannelSubscription(clientId: subscription.clientId!, channel: "pushenabled:foo") + let updateSubscription = PushChannelSubscription(clientId: subscription.clientId!, channel: "pushenabled:foo") waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.save(updateSubscription) { error in XCTAssertNil(error) @@ -706,9 +706,9 @@ class PushAdminTests: XCTestCase { func test__021__Channel_Subscriptions__save__should_fail_with_a_bad_recipient() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } - let invalidSubscription = ARTPushChannelSubscription(deviceId: "madeup", channel: "pushenabled:foo") + let invalidSubscription = PushChannelSubscription(deviceId: "madeup", channel: "pushenabled:foo") waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.save(invalidSubscription) { error in guard let error = error else { @@ -723,11 +723,11 @@ class PushAdminTests: XCTestCase { func test__022__Channel_Subscriptions__save__push_device_authentication__should_include_DeviceIdentityToken_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -739,7 +739,7 @@ class PushAdminTests: XCTestCase { realtime.internal.rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { realtime.internal.rest.device.setAndPersistIdentityTokenDetails(nil) } - let subscription = ARTPushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) + let subscription = PushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.save(subscription) { error in @@ -756,11 +756,11 @@ class PushAdminTests: XCTestCase { func test__023__Channel_Subscriptions__save__push_device_authentication__should_include_DeviceSecret_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let subscription = ARTPushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) + let subscription = PushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.save(subscription) { error in @@ -779,7 +779,7 @@ class PushAdminTests: XCTestCase { func test__024__Channel_Subscriptions__list__should_receive_a_list_of_subscriptions() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.save(subscription) { error in @@ -800,7 +800,7 @@ class PushAdminTests: XCTestCase { func test__025__Channel_Subscriptions__listChannels__should_receive_a_list_of_subscriptions() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.listChannels { result, error in @@ -819,7 +819,7 @@ class PushAdminTests: XCTestCase { func test__026__Channel_Subscriptions__remove__should_remove_a_subscription() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let testProxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) realtime.internal.rest.httpExecutor = testProxyHTTPExecutor @@ -851,11 +851,11 @@ class PushAdminTests: XCTestCase { func test__027__Channel_Subscriptions__remove__push_device_authentication__should_include_DeviceIdentityToken_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails( + let testIdentityTokenDetails = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -867,7 +867,7 @@ class PushAdminTests: XCTestCase { realtime.internal.rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { realtime.internal.rest.device.setAndPersistIdentityTokenDetails(nil) } - let subscription = ARTPushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) + let subscription = PushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.remove(subscription) { error in @@ -884,11 +884,11 @@ class PushAdminTests: XCTestCase { func test__028__Channel_Subscriptions__remove__push_device_authentication__should_include_DeviceSecret_HTTP_header() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } realtime.internal.rest.httpExecutor = mockHttpExecutor - let subscription = ARTPushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) + let subscription = PushChannelSubscription(deviceId: localDevice.id, channel: quxChannelName) waitUntil(timeout: testTimeout) { done in realtime.push.admin.channelSubscriptions.remove(subscription) { error in @@ -909,7 +909,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let params = [ @@ -965,7 +965,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let params = [ @@ -1011,7 +1011,7 @@ class PushAdminTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.pushFullWait = true - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let params = [ @@ -1055,7 +1055,7 @@ class PushAdminTests: XCTestCase { func test__032__Channel_Subscriptions__removeWhere__should_not_remove_by_inexistent_deviceId() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } let params = [ diff --git a/Test/Tests/PushChannelTests.swift b/Test/Tests/PushChannelTests.swift index 6bfc04eca..db5d2616b 100644 --- a/Test/Tests/PushChannelTests.swift +++ b/Test/Tests/PushChannelTests.swift @@ -4,17 +4,17 @@ import XCTest class PushChannelTests: XCTestCase { private struct TestEnvironment { - var rest: ARTRest + var rest: Rest var mockHttpExecutor: MockHTTPExecutor var userQueue: DispatchQueue init(test: Test) { mockHttpExecutor = MockHTTPExecutor() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") userQueue = AblyTests.createUserQueue(for: test) options.dispatchQueue = userQueue options.internalDispatchQueue = AblyTests.queue - rest = ARTRest(options: options) + rest = Rest(options: options) rest.internal.options.clientId = "tester" rest.internal.httpExecutor = mockHttpExecutor rest.internal.resetDeviceSingleton() @@ -48,7 +48,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -84,7 +84,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -110,7 +110,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -162,7 +162,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -196,7 +196,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -222,7 +222,7 @@ class PushChannelTests: XCTestCase { let testEnvironment = TestEnvironment(test: test) let rest = testEnvironment.rest - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } @@ -313,7 +313,7 @@ class PushChannelTests: XCTestCase { let channel = testEnvironment.rest.channels.get(test.uniqueChannelName()) expect { try channel.push.listSubscriptions([:]) { _, _ in } }.to(throwError { (error: NSError) in - XCTAssertEqual(error.code, ARTDataQueryError.missingRequiredFields.rawValue) + XCTAssertEqual(error.code, DataQueryError.missingRequiredFields.rawValue) }) } @@ -327,7 +327,7 @@ class PushChannelTests: XCTestCase { ] let channel = testEnvironment.rest.channels.get(test.uniqueChannelName()) expect { try channel.push.listSubscriptions(params) { _, _ in } }.to(throwError { (error: NSError) in - XCTAssertEqual(error.code, ARTDataQueryError.invalidParameters.rawValue) + XCTAssertEqual(error.code, DataQueryError.invalidParameters.rawValue) }) } @@ -339,12 +339,12 @@ class PushChannelTests: XCTestCase { options.clientId = "tester" // Prevent channel name to be prefixed by test-* options.testOptions.channelNamePrefix = nil - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.storage = MockDeviceStorage() rest.internal.setupLocalDevice_nosync() // Activate device - let testIdentityTokenDetails = ARTDeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") + let testIdentityTokenDetails = DeviceIdentityTokenDetails(token: "xxxx-xxxx-xxx", issued: Date(), expires: Date.distantFuture, capability: "", clientId: "") rest.device.setAndPersistIdentityTokenDetails(testIdentityTokenDetails) defer { rest.device.setAndPersistIdentityTokenDetails(nil) } diff --git a/Test/Tests/PushTests.swift b/Test/Tests/PushTests.swift index 8470e28be..77bd69433 100644 --- a/Test/Tests/PushTests.swift +++ b/Test/Tests/PushTests.swift @@ -2,7 +2,7 @@ import Ably import Nimble import XCTest -private var rest: ARTRest! +private var rest: Rest! private var mockHttpExecutor: MockHTTPExecutor! private var storage: MockDeviceStorage! private var stateMachineDelegate: StateMachineDelegate! @@ -33,7 +33,7 @@ class PushTests: XCTestCase { override func setUp() { super.setUp() - rest = ARTRest(key: "xxxx:xxxx") + rest = Rest(key: "xxxx:xxxx") rest.internal.resetDeviceSingleton() mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor @@ -50,7 +50,7 @@ class PushTests: XCTestCase { defer { rest.push.internal.activationMachine.transitions = nil } waitUntil(timeout: testTimeout) { done in rest.push.internal.activationMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventCalledActivate { + if event is PushActivationEventCalledActivate { done() } } @@ -63,7 +63,7 @@ class PushTests: XCTestCase { defer { rest.push.internal.activationMachine.transitions = nil } waitUntil(timeout: testTimeout) { done in rest.push.internal.activationMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventCalledDeactivate { + if event is PushActivationEventCalledDeactivate { done() } } @@ -85,7 +85,7 @@ class PushTests: XCTestCase { } waitUntil(timeout: testTimeout) { done in stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { done() } } @@ -99,14 +99,14 @@ class PushTests: XCTestCase { defer { stateMachine.transitions = nil } waitUntil(timeout: testTimeout) { done in stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGettingPushDeviceDetailsFailed { + if event is PushActivationEventGettingPushDeviceDetailsFailed { done() } } rest.push.activate() let error = NSError(domain: ARTAblyErrorDomain, code: 42, userInfo: nil) - ARTPush.didFailToRegisterForRemoteNotificationsWithError(error, rest: rest) + Push.didFailToRegisterForRemoteNotificationsWithError(error, rest: rest) } } @@ -126,7 +126,7 @@ class PushTests: XCTestCase { }) } - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let storage = MockDeviceStorage() @@ -134,7 +134,7 @@ class PushTests: XCTestCase { rest.internal.resetDeviceSingleton() - var stateMachine: ARTPushActivationStateMachine! + var stateMachine: PushActivationStateMachine! waitUntil(timeout: testTimeout) { done in rest.push.internal.getActivationMachine { machine in stateMachine = machine @@ -158,9 +158,9 @@ class PushTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { partialDone() - } else if event is ARTPushActivationEventGotDeviceRegistration { + } else if event is PushActivationEventGotDeviceRegistration { stateMachine.transitions = nil partialDone() } @@ -194,12 +194,12 @@ class PushTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) rest.push.internal.activationMachine.onEvent = { event, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { partialDone() } } - ARTPush.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) - ARTPush.didRegisterForLocationNotifications(withDeviceToken: TestLocationDeviceToken.tokenData, rest: rest) + Push.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) + Push.didRegisterForLocationNotifications(withDeviceToken: TestLocationDeviceToken.tokenData, rest: rest) } let expectedDeviceTokenKey = "ARTAPNSDeviceToken-default" // ARTAPNSDeviceTokenKeyOfType(nil) expect(storage.keysWritten.keys).to(contain([expectedDeviceTokenKey])) @@ -212,19 +212,19 @@ class PushTests: XCTestCase { // https://github.com/ably/ably-cocoa/issues/888 func test__007__activation__should_not_sync_the_local_device_dispatched_in_internal_queue() { - expect { ARTPush.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) }.toNot(raiseException()) + expect { Push.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) }.toNot(raiseException()) } // RSH8 func test__008__LocalDevice__has_a_device_method_that_returns_a_LocalDevice() { - let _: ARTLocalDevice = ARTRest(key: "fake:key").device - let _: ARTLocalDevice = ARTRealtime(key: "fake:key").device + let _: LocalDevice = Rest(key: "fake:key").device + let _: LocalDevice = Realtime(key: "fake:key").device } // RSH8a func test__009__LocalDevice__the_device_is_lazily_populated_from_the_persisted_state() { let testToken = "testDeviceToken" - let testIdentity = ARTDeviceIdentityTokenDetails( + let testIdentity = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -232,7 +232,7 @@ class PushTests: XCTestCase { clientId: "client1" ) - let rest = ARTRest(key: "fake:key") + let rest = Rest(key: "fake:key") rest.internal.storage = storage storage.simulateOnNextRead(string: "testId", for: ARTDeviceIdKey) @@ -252,7 +252,7 @@ class PushTests: XCTestCase { // RSH8d func test__012__LocalDevice__when_using_token_authentication__new_clientID_is_set() { - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.autoConnect = false options.authCallback = { _, callback in delay(0.1) { @@ -260,7 +260,7 @@ class PushTests: XCTestCase { } } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let storage = MockDeviceStorage() realtime.internal.rest.storage = storage @@ -280,11 +280,11 @@ class PushTests: XCTestCase { // RSH8d func test__013__LocalDevice__when_getting_a_client_ID_from_CONNECTED_message__new_clientID_is_set() { - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let storage = MockDeviceStorage() realtime.internal.rest.storage = storage @@ -309,7 +309,7 @@ class PushTests: XCTestCase { // RSH8e func test__010__LocalDevice__authentication_on_registered_device_sends_a_GotPushDeviceDetails_with_new_clientID() { let testDeviceToken = "testDeviceToken" - let testDeviceIdentity = ARTDeviceIdentityTokenDetails( + let testDeviceIdentity = DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -318,7 +318,7 @@ class PushTests: XCTestCase { ) let expectedClient = "testClient" - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.autoConnect = false options.authCallback = { _, callback in delay(0.1) { @@ -326,20 +326,20 @@ class PushTests: XCTestCase { } } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let mockHttpExecutor = MockHTTPExecutor() realtime.internal.rest.httpExecutor = mockHttpExecutor let logger = InternalLog(core: MockInternalLogCore()) let storage = MockDeviceStorage( - startWith: ARTPushActivationStateWaitingForNewPushDeviceDetails( - machine: ARTPushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: logger), + startWith: PushActivationStateWaitingForNewPushDeviceDetails( + machine: PushActivationStateMachine(rest: rest.internal, delegate: StateMachineDelegate(), logger: logger), logger: logger ) ) realtime.internal.rest.storage = storage - var stateMachine: ARTPushActivationStateMachine! + var stateMachine: PushActivationStateMachine! waitUntil(timeout: testTimeout) { done in realtime.internal.rest.push.getActivationMachine { machine in stateMachine = machine @@ -356,7 +356,7 @@ class PushTests: XCTestCase { waitUntil(timeout: testTimeout) { done in stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { done() } } @@ -368,7 +368,7 @@ class PushTests: XCTestCase { let expectation = XCTestExpectation(description: "Consecutive Authorization") expectation.isInverted = true stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { fail("GotPushDeviceDetails should only be emitted when clientId is different from the present identified client") } } @@ -385,7 +385,7 @@ class PushTests: XCTestCase { let stateMachineDelegate = StateMachineDelegateCustomCallbacks() stateMachineDelegate.onPushCustomRegisterIdentity = { _, _ in - ARTDeviceIdentityTokenDetails( + DeviceIdentityTokenDetails( token: "123456", issued: Date(), expires: Date.distantFuture, @@ -407,7 +407,7 @@ class PushTests: XCTestCase { rest.push.activate() - ARTPush.didRegisterForRemoteNotifications(withDeviceToken: "testDeviceToken".data(using: .utf8)!, rest: rest) + Push.didRegisterForRemoteNotifications(withDeviceToken: "testDeviceToken".data(using: .utf8)!, rest: rest) } XCTAssertEqual(rest.device.clientId, expectedClientId) @@ -420,7 +420,7 @@ class PushTests: XCTestCase { options.key = "xxxx:xxxx" let pushRegistererDelegate = StateMachineDelegate() options.pushRegistererDelegate = pushRegistererDelegate - let rest = ARTRest(options: options) + let rest = Rest(options: options) waitUntil(timeout: testTimeout) { done in pushRegistererDelegate.onDidActivateAblyPush = { _ in done() @@ -429,7 +429,7 @@ class PushTests: XCTestCase { fail("should not be called") } rest.push.activate() - ARTPush.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) + Push.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) } } @@ -439,7 +439,7 @@ class PushTests: XCTestCase { options.key = "xxxx:xxxx" var pushRegistererDelegate: StateMachineDelegate? = StateMachineDelegate() options.pushRegistererDelegate = pushRegistererDelegate - let rest = ARTRest(options: options) + let rest = Rest(options: options) XCTAssertNotNil(rest.internal.options.pushRegistererDelegate) pushRegistererDelegate = nil XCTAssertNil(rest.internal.options.pushRegistererDelegate) @@ -458,7 +458,7 @@ class PushTests: XCTestCase { } waitUntil(timeout: testTimeout) { done in rest.push.internal.activationMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventCalledActivate { + if event is PushActivationEventCalledActivate { done() } } @@ -473,7 +473,7 @@ class PushTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.key = "xxxx:xxxx" - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let storage = MockDeviceStorage() @@ -481,7 +481,7 @@ class PushTests: XCTestCase { rest.internal.resetDeviceSingleton() - var stateMachine: ARTPushActivationStateMachine! + var stateMachine: PushActivationStateMachine! waitUntil(timeout: testTimeout) { done in rest.push.internal.getActivationMachine { machine in stateMachine = machine @@ -496,14 +496,14 @@ class PushTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(4, done: done) stateMachine.transitions = { event, _, _ in - if event is ARTPushActivationEventGotPushDeviceDetails { + if event is PushActivationEventGotPushDeviceDetails { partialDone() } - else if event is ARTPushActivationEventGotDeviceRegistration { + else if event is PushActivationEventGotDeviceRegistration { partialDone() - ARTPush.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) + Push.didRegisterForRemoteNotifications(withDeviceToken: TestDeviceToken.tokenData, rest: rest) } - else if event is ARTPushActivationEventRegistrationSynced { + else if event is PushActivationEventRegistrationSynced { stateMachine.transitions = nil partialDone() } @@ -548,7 +548,7 @@ class PushTests: XCTestCase { options.key = "xxxx:xxxx" let pushRegistererDelegate = StateMachineDelegate() options.pushRegistererDelegate = pushRegistererDelegate - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let storage = MockDeviceStorage() @@ -561,7 +561,7 @@ class PushTests: XCTestCase { defer { rest.device.setAndPersistAPNSDeviceToken(nil) } func requestLocationDeviceToken() { - ARTPush.didRegisterForLocationNotifications(withDeviceToken: TestLocationDeviceToken.tokenData, rest: rest) + Push.didRegisterForLocationNotifications(withDeviceToken: TestLocationDeviceToken.tokenData, rest: rest) } waitUntil(timeout: testTimeout) { done in diff --git a/Test/Tests/ReadmeExamplesTests.swift b/Test/Tests/ReadmeExamplesTests.swift index 07e03a910..ef010e546 100644 --- a/Test/Tests/ReadmeExamplesTests.swift +++ b/Test/Tests/ReadmeExamplesTests.swift @@ -7,19 +7,19 @@ import XCTest class ReadmeExamplesTests: XCTestCase { func test__001__testMakeKeyInstance() { - let client = ARTRealtime(key: "xxxx:xxxx") + let client = Realtime(key: "xxxx:xxxx") client.connection.close() } func test__002__testMakeTokenInstance() { - let client = ARTRealtime(token: "xxxx") + let client = Realtime(token: "xxxx") client.connection.close() } func test__003__testListenToConnectionStateChanges() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } client.connection.on { stateChange in @@ -35,9 +35,9 @@ class ReadmeExamplesTests: XCTestCase { } func test__004__testNoAutoConnect() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connection.connect() client.connection.close() } @@ -45,7 +45,7 @@ class ReadmeExamplesTests: XCTestCase { func test__005__testSubscribeAndPublishingToChannel() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -66,7 +66,7 @@ class ReadmeExamplesTests: XCTestCase { func test__006__testQueryingTheHistory() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -88,7 +88,7 @@ class ReadmeExamplesTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) options.clientId = "foo" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } client.connection.on { stateChange in @@ -107,7 +107,7 @@ class ReadmeExamplesTests: XCTestCase { func test__008__testQueryingThePresenceHistory() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -127,7 +127,7 @@ class ReadmeExamplesTests: XCTestCase { func test__009__testMakeRestClientAndChannel() { let test = Test() - let client = ARTRest(key: "xxxx:xxxx") + let client = Rest(key: "xxxx:xxxx") let channel = client.channels.get(test.uniqueChannelName()) _ = channel } @@ -135,7 +135,7 @@ class ReadmeExamplesTests: XCTestCase { func test__010__testRestPublishMessage() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) channel.publish("myEvent", data: "Hello!") @@ -144,7 +144,7 @@ class ReadmeExamplesTests: XCTestCase { func test__011__testRestQueryingTheHistory() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) channel.history { messagesPage, _ in @@ -161,7 +161,7 @@ class ReadmeExamplesTests: XCTestCase { func test__012__testRestPresenceOnAChannel() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) channel.presence.get { membersPage, _ in @@ -178,7 +178,7 @@ class ReadmeExamplesTests: XCTestCase { func test__013__testRestQueryingThePresenceHistory() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) channel.presence.history { presencePage, _ in @@ -194,19 +194,19 @@ class ReadmeExamplesTests: XCTestCase { func test__014__testGenerateToken() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) client.auth.requestToken(nil, with: nil) { tokenDetails, _ in let tokenDetails = tokenDetails! print(tokenDetails.token) // "xVLyHw.CLchevH3hF....MDh9ZC_Q" - let client = ARTRest(token: tokenDetails.token) + let client = Rest(token: tokenDetails.token) _ = client } } func test__015__testFetchingStats() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) client.channels.get(test.uniqueChannelName()).publish("foo", data: "bar") { _ in client.stats { statsPage, _ in let statsPage = statsPage! @@ -220,7 +220,7 @@ class ReadmeExamplesTests: XCTestCase { func test__016__testFetchingTime() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) client.time { time, _ in print(time as Any) // 2016-02-09 03:59:24 +0000 diff --git a/Test/Tests/RealtimeClientChannelTests.swift b/Test/Tests/RealtimeClientChannelTests.swift index 9727094f5..10027f937 100644 --- a/Test/Tests/RealtimeClientChannelTests.swift +++ b/Test/Tests/RealtimeClientChannelTests.swift @@ -2,28 +2,28 @@ import Ably import Nimble import XCTest -private let attachResumeExpectedValues: [ARTRealtimeChannelState: Bool] = [ +private let attachResumeExpectedValues: [RealtimeChannelState: Bool] = [ .initialized: false, .attached: true, .detaching: false, .failed: false, ] -private var rtl6c2TestsClient: ARTRealtime! -private var rtl6c2TestsChannel: ARTRealtimeChannel! +private var rtl6c2TestsClient: Realtime! +private var rtl6c2TestsChannel: RealtimeChannel! private func rtl16c2TestsPublish(_ done: @escaping () -> Void) { rtl6c2TestsChannel.publish(nil, data: "message") { error in XCTAssertNil(error) - XCTAssertEqual(rtl6c2TestsClient.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(rtl6c2TestsClient.connection.state, RealtimeConnectionState.connected) done() } } -private var options: ARTClientOptions! -private var rtl6c4TestsClient: ARTRealtime! -private var rtl6c4TestsChannel: ARTRealtimeChannel! +private var options: ClientOptions! +private var rtl6c4TestsClient: Realtime! +private var rtl6c4TestsChannel: RealtimeChannel! -private let previousConnectionStateTtl = ARTDefault.connectionStateTtl() +private let previousConnectionStateTtl = Default.connectionStateTtl() private func setupDependencies(for test: Test) throws { if options == nil { @@ -47,17 +47,17 @@ private func rtl6c4TestsPublish(_ done: @escaping () -> Void) { private func testHandlesDecodingErrorInFixture(_ cryptoFixtureFileName: String, for test: Test, channelName: String) throws { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - options.logHandler = ARTLog(capturingOutput: true) + options.logHandler = Log(capturingOutput: true) options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let (keyData, ivData, messages) = AblyTests.loadCryptoTestData(cryptoFixtureFileName) let testMessage = messages[0] - let cipherParams = ARTCipherParams(algorithm: "aes", key: keyData as ARTCipherKeyCompatible, iv: ivData) - let channelOptions = ARTRealtimeChannelOptions(cipher: cipherParams) + let cipherParams = CipherParams(algorithm: "aes", key: keyData as CipherKeyCompatible, iv: ivData) + let channelOptions = RealtimeChannelOptions(cipher: cipherParams) let channel = client.channels.get(channelName, options: channelOptions) let transport = client.internal.transport as! TestProxyTransport @@ -109,18 +109,18 @@ private func testHandlesDecodingErrorInFixture(_ cryptoFixtureFileName: String, private func testWithUntilAttach(_ untilAttach: Bool, for test: Test, channelName: String) throws { let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.rest.httpExecutor = testHTTPExecutor - let query = ARTRealtimeHistoryQuery() + let query = RealtimeHistoryQuery() query.untilAttach = untilAttach channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in expect { @@ -183,7 +183,7 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel2.on(.attached) { _ in - XCTAssertEqual(channel2.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel2.state, RealtimeChannelState.attached) done() } channel2.attach() @@ -218,8 +218,8 @@ class RealtimeClientChannelTests: XCTestCase { expect(channel2.internal.presence.members).toEventually(haveCount(2), timeout: testTimeout) expect(channel2.internal.presence.members.keys).to(allPass { $0.hasPrefix("\(channel1.internal.connectionId):Client") || $0.hasPrefix("\(channel2.internal.connectionId):Client") }) - XCTAssertEqual(channel2.internal.presence.members["\(channel1.internal.connectionId):Client 1"]!.action, ARTPresenceAction.present) - XCTAssertEqual(channel2.internal.presence.members["\(channel2.internal.connectionId):Client 2"]!.action, ARTPresenceAction.present) + XCTAssertEqual(channel2.internal.presence.members["\(channel1.internal.connectionId):Client 1"]!.action, PresenceAction.present) + XCTAssertEqual(channel2.internal.presence.members["\(channel2.internal.connectionId):Client 2"]!.action, PresenceAction.present) } // RTL2 @@ -227,25 +227,25 @@ class RealtimeClientChannelTests: XCTestCase { // RTL2a func test__003__Channel__EventEmitter__channel_states_and_events__should_implement_the_EventEmitter_and_emit_events_for_state_changes() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(channel.internal.statesEventEmitter).to(beAKindOf(ARTEventEmitter.self)) + expect(channel.internal.statesEventEmitter).to(beAKindOf(EventEmitter.self)) var channelOnMethodCalled = false - channel.internal.testSuite_injectIntoMethod(after: #selector(ARTEventEmitter.on(_:))) { + channel.internal.testSuite_injectIntoMethod(after: #selector(EventEmitter.on(_:))) { channelOnMethodCalled = true } // The `channel.on` should use `statesEventEmitter` var statesEventEmitterOnMethodCalled = false - channel.internal.statesEventEmitter.testSuite_injectIntoMethod(after: #selector(ARTEventEmitter.on(_:))) { + channel.internal.statesEventEmitter.testSuite_injectIntoMethod(after: #selector(EventEmitter.on(_:))) { statesEventEmitterOnMethodCalled = true } var emitCounter = 0 - channel.internal.statesEventEmitter.testSuite_injectIntoMethod(after: #selector(ARTEventEmitter.emit(_:with:))) { + channel.internal.statesEventEmitter.testSuite_injectIntoMethod(after: #selector(EventEmitter.emit(_:with:))) { emitCounter += 1 } @@ -258,11 +258,11 @@ class RealtimeClientChannelTests: XCTestCase { switch stateChange.current { case .attached: - XCTAssertEqual(stateChange.event, ARTChannelEvent.attached) + XCTAssertEqual(stateChange.event, ChannelEvent.attached) XCTAssertNil(stateChange.reason) channel.detach() case .detached: - XCTAssertEqual(stateChange.event, ARTChannelEvent.detached) + XCTAssertEqual(stateChange.event, ChannelEvent.detached) guard let error = stateChange.reason else { fail("Detach state change reason is nil"); done(); return } @@ -284,11 +284,11 @@ class RealtimeClientChannelTests: XCTestCase { return } - XCTAssertEqual(states[0].rawValue, ARTRealtimeChannelState.initialized.rawValue, "Should be INITIALIZED state") - XCTAssertEqual(states[1].rawValue, ARTRealtimeChannelState.attaching.rawValue, "Should be ATTACHING state") - XCTAssertEqual(states[2].rawValue, ARTRealtimeChannelState.attached.rawValue, "Should be ATTACHED state") - XCTAssertEqual(states[3].rawValue, ARTRealtimeChannelState.detaching.rawValue, "Should be DETACHING state") - XCTAssertEqual(states[4].rawValue, ARTRealtimeChannelState.detached.rawValue, "Should be DETACHED state") + XCTAssertEqual(states[0].rawValue, RealtimeChannelState.initialized.rawValue, "Should be INITIALIZED state") + XCTAssertEqual(states[1].rawValue, RealtimeChannelState.attaching.rawValue, "Should be ATTACHING state") + XCTAssertEqual(states[2].rawValue, RealtimeChannelState.attached.rawValue, "Should be ATTACHED state") + XCTAssertEqual(states[3].rawValue, RealtimeChannelState.detaching.rawValue, "Should be DETACHING state") + XCTAssertEqual(states[4].rawValue, RealtimeChannelState.detached.rawValue, "Should be DETACHED state") } // RTL2a @@ -296,7 +296,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, capability: "{\"secret\":[\"subscribe\"]}") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -305,16 +305,16 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertEqual(channel.state, stateChange.current) switch stateChange.current { case .attaching: - XCTAssertEqual(stateChange.event, ARTChannelEvent.attaching) + XCTAssertEqual(stateChange.event, ChannelEvent.attaching) XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.initialized) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.initialized) case .failed: guard let reason = stateChange.reason else { fail("Reason is nil"); done(); return } - XCTAssertEqual(stateChange.event, ARTChannelEvent.failed) + XCTAssertEqual(stateChange.event, ChannelEvent.failed) XCTAssertEqual(reason.code, ARTErrorCode.operationNotPermittedWithProvidedCapability.intValue) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attaching) done() default: break @@ -327,7 +327,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL2a func test__005__Channel__EventEmitter__channel_states_and_events__should_implement_the_EventEmitter_and_emit_events_for_SUSPENDED_state_changes() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -341,8 +341,8 @@ class RealtimeClientChannelTests: XCTestCase { client.simulateSuspended(beforeSuspension: { done in channel.once(.suspended) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) - XCTAssertEqual(stateChange.event, ARTChannelEvent.suspended) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) + XCTAssertEqual(stateChange.event, ChannelEvent.suspended) XCTAssertEqual(channel.state, stateChange.current) done() } @@ -352,7 +352,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL2g func test__006__Channel__EventEmitter__channel_states_and_events__can_emit_an_UPDATE_event() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -371,16 +371,16 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.on(.update) { stateChange in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) XCTAssertEqual(stateChange.previous, channel.state) XCTAssertEqual(stateChange.current, channel.state) - XCTAssertEqual(stateChange.event, ARTChannelEvent.update) + XCTAssertEqual(stateChange.event, ChannelEvent.update) XCTAssertFalse(stateChange.resumed) XCTAssertNil(stateChange.reason) done() } - let attachedMessage = ARTProtocolMessage() + let attachedMessage = ProtocolMessage() attachedMessage.action = .attached attachedMessage.channel = channel.name client.internal.transport?.receive(attachedMessage) @@ -392,7 +392,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.logLevel = .debug - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -429,21 +429,21 @@ class RealtimeClientChannelTests: XCTestCase { // RTL2b func test__008__Channel__EventEmitter__channel_states_and_events__state_attribute_should_be_the_current_state_of_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTL2c func test__009__Channel__EventEmitter__channel_states_and_events__should_contain_an_ErrorInfo_object_with_details_when_an_error_occurs() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -466,7 +466,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL2d func test__010__Channel__EventEmitter__channel_states_and_events__a_ChannelStateChange_is_emitted_as_the_first_argument_for_every_channel_state_change() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -487,8 +487,8 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.once(.failed) { stateChange in XCTAssertNotNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.failed) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) + XCTAssertEqual(stateChange.current, RealtimeChannelState.failed) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) done() } AblyTests.queue.async { @@ -502,7 +502,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.tokenDetails = try getTestTokenDetails(for: test, ttl: 5.0) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -523,9 +523,9 @@ class RealtimeClientChannelTests: XCTestCase { fail("Error is nil"); done(); return } XCTAssertEqual(error.code, ARTErrorCode.tokenExpired.intValue) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) client.connection.once(.connected) { stateChange in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) partialDone() } channel.on { stateChange in @@ -547,7 +547,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__011b__Channel__EventEmitter__channel_states_and_events__ChannelStateChange_will_contain_a_resumed_boolean_attribute_with_value__true__if_the_bit_flag_RESUMED_was_included_for_recovered_connection() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -568,7 +568,7 @@ class RealtimeClientChannelTests: XCTestCase { options.recover = client.connection.createRecoveryKey() - let recoveredClient = ARTRealtime(options: options) + let recoveredClient = Realtime(options: options) defer { recoveredClient.dispose(); recoveredClient.close() } let recoveredChannel = recoveredClient.channels.get(channelName) @@ -595,7 +595,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -604,7 +604,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) waitUntil(timeout: testTimeout) { done in let pmError = AblyTests.newErrorProtocolMessage() @@ -619,17 +619,17 @@ class RealtimeClientChannelTests: XCTestCase { client.internal.onError(pmError) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } func test__018__Channel__connection_state__changes_to_FAILED__ATTACHED_channel_should_transition_to_FAILED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let pmError = AblyTests.newErrorProtocolMessage() @@ -644,7 +644,7 @@ class RealtimeClientChannelTests: XCTestCase { client.internal.onError(pmError) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } func test__019__Channel__connection_state__changes_to_FAILED__channel_being_released_waiting_for_DETACH_shouldn_t_crash__issue__918_() throws { @@ -652,7 +652,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -667,7 +667,7 @@ class RealtimeClientChannelTests: XCTestCase { if i == 0 { channel0Name = channelName } let channel = client.channels.get(channelName) channel.attach() // No need to wait; ATTACHING state is good enough. - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attaching), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attaching), timeout: testTimeout) } waitUntil(timeout: testTimeout) { done in @@ -691,7 +691,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.queueMessages = false options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -723,7 +723,7 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.internal.setReachabilityClass(TestReachability.self) let channel = client.channels.get(test.uniqueChannelName()) @@ -776,37 +776,37 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let channel = client.channels.get(test.uniqueChannelName()) channel.attach() let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) client.close() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closing) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closed) } func test__023__Channel__connection_state__changes_to_CLOSED__ATTACHED_channel_should_transition_to_DETACHED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) client.close() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closing) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closed) } // RTL3c @@ -816,7 +816,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -825,23 +825,23 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.attached] - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) client.internal.onSuspended() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.suspended) + XCTAssertEqual(channel.state, RealtimeChannelState.suspended) } func test__025__Channel__connection_state__changes_to_SUSPENDED__ATTACHED_channel_should_transition_to_SUSPENDED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) client.internal.onSuspended() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.suspended) + XCTAssertEqual(channel.state, RealtimeChannelState.suspended) } func test__026__Channel__connection_state__changes_to_SUSPENDED__channel_being_released_waiting_for_DETACH_shouldn_t_crash__issue__918_() throws { @@ -849,7 +849,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -864,7 +864,7 @@ class RealtimeClientChannelTests: XCTestCase { if i == 0 { channel0Name = channelName } let channel = client.channels.get(channelName) channel.attach() // No need to wait; ATTACHING state is good enough. - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attaching), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attaching), timeout: testTimeout) } waitUntil(timeout: testTimeout) { done in @@ -886,7 +886,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.suspendedRetryTimeout = 1.0 - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -907,8 +907,8 @@ class RealtimeClientChannelTests: XCTestCase { } } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTL3d @@ -944,7 +944,7 @@ class RealtimeClientChannelTests: XCTestCase { let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.setReachabilityClass(TestReachability.self) defer { client.simulateRestoreInternetConnection(transportFactory: transportFactory) @@ -1006,7 +1006,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, ttl: 5.0) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1027,7 +1027,7 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connection.once(.disconnected) { _ in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) done() } } @@ -1038,7 +1038,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL4a func test__027__Channel__attach__if_already_ATTACHED_or_ATTACHING_nothing_is_done() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1046,19 +1046,19 @@ class RealtimeClientChannelTests: XCTestCase { channel.attach { errorInfo in XCTAssertNil(errorInfo) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) channel.attach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.attach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) done() } } @@ -1069,7 +1069,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, key: options.key!, capability: "{\"restricted\":[\"*\"]}") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1088,24 +1088,24 @@ class RealtimeClientChannelTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertEqual(channel.errorReason?.code, ARTErrorCode.operationNotPermittedWithProvidedCapability.intValue) } // RTL4g func test__029__Channel__attach__if_the_channel_is_in_the_FAILED_state__the_attach_request_sets_its_errorReason_to_null__and_proceeds_with_a_channel_attach() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let errorMsg = AblyTests.newErrorProtocolMessage() errorMsg.channel = channel.name client.internal.onError(errorMsg) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertNotNil(channel.errorReason) waitUntil(timeout: testTimeout) { done in @@ -1115,7 +1115,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) XCTAssertNil(channel.errorReason) } @@ -1126,18 +1126,18 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.closed] let channel = client.channels.get(test.uniqueChannelName()) client.close() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closing) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -1149,13 +1149,13 @@ class RealtimeClientChannelTests: XCTestCase { func test__040__Channel__attach__results_in_an_error_if_the_connection_state_is__CLOSED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) client.close() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.attach { error in @@ -1172,7 +1172,7 @@ class RealtimeClientChannelTests: XCTestCase { let channel = client.channels.get(test.uniqueChannelName()) client.internal.onSuspended() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.suspended) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.suspended) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNotNil(error) @@ -1183,12 +1183,12 @@ class RealtimeClientChannelTests: XCTestCase { func test__042__Channel__attach__results_in_an_error_if_the_connection_state_is__FAILED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) client.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.failed) waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNotNil(error) @@ -1203,7 +1203,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1224,17 +1224,17 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in client.connect() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) channel.attach { error in - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNil(error) done() } @@ -1244,19 +1244,19 @@ class RealtimeClientChannelTests: XCTestCase { func skipped__test__045__Channel__attach__happens_when_connection_is_CONNECTED_if_it_s_currently__DISCONNECTED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in client.internal.onDisconnected() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.disconnected) channel.attach { error in - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNil(error) done() } @@ -1269,20 +1269,20 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) XCTAssertEqual(transport.protocolMessagesSent.filter { $0.action == .attach }.count, 1) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) XCTAssertEqual(transport.protocolMessagesReceived.filter { $0.action == .attached }.count, 1) } @@ -1294,27 +1294,27 @@ class RealtimeClientChannelTests: XCTestCase { let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.setReachabilityClass(TestReachability.self) client.connect() defer { client.dispose(); client.close() } - let latestAttachProtocolMessage: () throws -> ARTProtocolMessage = { + let latestAttachProtocolMessage: () throws -> ProtocolMessage = { let transport = try XCTUnwrap(client.internal.transport as? TestProxyTransport) let protocolAttachMessagesSent = transport.protocolMessagesSent.filter { $0.action == .attach } return try XCTUnwrap(protocolAttachMessagesSent.last) } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).to(equal(ARTRealtimeChannelState.attaching)) + expect(channel.state).to(equal(RealtimeChannelState.attaching)) let firstProtocolAttachMessage = try latestAttachProtocolMessage() expect(firstProtocolAttachMessage.channelSerial).to(beNil()) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -1332,9 +1332,9 @@ class RealtimeClientChannelTests: XCTestCase { client.simulateNoInternetConnection(transportFactory: transportFactory) client.simulateRestoreInternetConnection(after: 0.1, transportFactory: transportFactory) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let secondProtocolAttachMessage = try latestAttachProtocolMessage() expect(secondProtocolAttachMessage.channelSerial).to(equal(channel.internal.channelSerial)) @@ -1345,7 +1345,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, capability: "{ \"main\":[\"subscribe\"] }") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1362,7 +1362,7 @@ class RealtimeClientChannelTests: XCTestCase { } XCTAssertEqual(channel.errorReason!.code, ARTErrorCode.operationNotPermittedWithProvidedCapability.intValue) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } // RTL4f @@ -1374,7 +1374,7 @@ class RealtimeClientChannelTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not set"); return @@ -1389,7 +1389,7 @@ class RealtimeClientChannelTests: XCTestCase { done() } } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.suspended), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.suspended), timeout: testTimeout) XCTAssertNotNil(channel.errorReason) transport.actionsIgnored = [] @@ -1409,7 +1409,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__033__Channel__attach__if_called_with_a_callback_should_call_it_once_attached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1417,7 +1417,7 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.attach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) done() } } @@ -1425,17 +1425,17 @@ class RealtimeClientChannelTests: XCTestCase { func test__034__Channel__attach__if_called_with_a_callback_and_already_attaching_should_call_the_callback_once_attached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) channel.attach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) done() } } @@ -1443,13 +1443,13 @@ class RealtimeClientChannelTests: XCTestCase { func test__035__Channel__attach__if_called_with_a_callback_and_already_attached_should_call_the_callback_with_nil_error() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.attach { errorInfo in @@ -1463,7 +1463,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__036__Channel__attach__if_the_channel_is_in_a_pending_state_ATTACHING__do_the_attach_operation_after_the_completion_of_the_pending_request() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1477,8 +1477,8 @@ class RealtimeClientChannelTests: XCTestCase { let partialDone = AblyTests.splitDone(2, done: done) channel.once(.attaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.initialized) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.initialized) channel.attach() partialDone() } @@ -1496,7 +1496,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__037__Channel__attach__if_the_channel_is_in_a_pending_state_DETACHING__do_the_attach_operation_after_the_completion_of_the_pending_request() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -1510,27 +1510,27 @@ class RealtimeClientChannelTests: XCTestCase { let partialDone = AblyTests.splitDone(4, done: done) channel.once(.detaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) channel.attach() partialDone() } channel.once(.detached) { stateChange in expect(stateChange.reason?.message).to(contain("channel has detached")) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.detaching) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.detaching) partialDone() } channel.once(.attaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.detached) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.detached) partialDone() } channel.once(.attached) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attaching) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attaching) partialDone() } channel.detach() @@ -1564,7 +1564,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Reason error is nil"); return } expect(error.message).to(contain("timed out")) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) done() } } @@ -1589,7 +1589,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Expecting TestProxyTransport"); return } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.publish] waitUntil(timeout: testTimeout) { done in @@ -1616,7 +1616,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL4j1 func test__047__Channel__attach__attach_resume__should_have_correct_AttachResume_value() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1661,7 +1661,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let channelName = test.uniqueChannelName() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) @@ -1672,10 +1672,10 @@ class RealtimeClientChannelTests: XCTestCase { } } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.params = ["rewind": "1"] - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.dispose(); client1.close() } let channelWithAttachResume = client1.channels.get(channelName, options: channelOptions) channelWithAttachResume.internal.attachResume = true @@ -1693,7 +1693,7 @@ class RealtimeClientChannelTests: XCTestCase { } channelOptions.modes = [.subscribe] - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.dispose(); client2.close() } let channelWithoutAttachResume = client2.channels.get(channelName, options: channelOptions) waitUntil(timeout: testTimeout) { done in @@ -1708,31 +1708,31 @@ class RealtimeClientChannelTests: XCTestCase { // RTL5a func test__049__Channel__detach__if_state_is_INITIALIZED_or_DETACHED_nothing_is_done() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.detach { errorInfo in XCTAssertNil(errorInfo) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attaching), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attaching), timeout: testTimeout) channel.detach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.detach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) done() } } @@ -1742,7 +1742,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__050__Channel__detach__if_the_channel_is_in_a_pending_state_DETACHING__do_the_detach_operation_after_the_completion_of_the_pending_request() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -1766,14 +1766,14 @@ class RealtimeClientChannelTests: XCTestCase { let partialDone = AblyTests.splitDone(2, done: done) channel.once(.detaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) channel.detach() partialDone() } channel.once(.detached) { stateChange in - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.detaching) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.detaching) partialDone() } channel.detach() @@ -1794,7 +1794,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__051__Channel__detach__if_the_channel_is_in_a_pending_state_ATTACHING__do_the_detach_operation_after_the_completion_of_the_pending_request() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1802,21 +1802,21 @@ class RealtimeClientChannelTests: XCTestCase { let partialDone = AblyTests.splitDone(3, done: done) channel.once(.attaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.initialized) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.initialized) channel.detach() partialDone() } channel.once(.attached) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attaching) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attaching) partialDone() } channel.once(.detaching) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detaching) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detaching) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) partialDone() } channel.attach() @@ -1826,12 +1826,12 @@ class RealtimeClientChannelTests: XCTestCase { // RTL5b func test__052__Channel__detach__results_in_an_error_if_the_connection_state_is_FAILED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) client.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.failed) waitUntil(timeout: testTimeout) { done in channel.detach { errorInfo in @@ -1847,40 +1847,40 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) channel.detach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel.state, RealtimeChannelState.detaching) XCTAssertEqual(transport.protocolMessagesSent.filter { $0.action == .detach }.count, 1) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) XCTAssertEqual(transport.protocolMessagesReceived.filter { $0.action == .detached }.count, 1) } // RTL5e func test__054__Channel__detach__if_called_with_a_callback_should_call_it_once_detached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.detach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) done() } } @@ -1889,20 +1889,20 @@ class RealtimeClientChannelTests: XCTestCase { // RTL5e func test__055__Channel__detach__if_called_with_a_callback_and_already_detaching_should_call_the_callback_once_detached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.detach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel.state, RealtimeChannelState.detaching) channel.detach { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) done() } } @@ -1911,15 +1911,15 @@ class RealtimeClientChannelTests: XCTestCase { // RTL5e func test__056__Channel__detach__if_called_with_a_callback_and_already_detached_should_should_call_the_callback_with_nil_error() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) channel.detach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.detach { errorInfo in @@ -1936,17 +1936,17 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false options.testOptions.realtimeRequestTimeout = 1.0 options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.detached] let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) var callbackCalled = false channel.detach { error in @@ -1958,7 +1958,7 @@ class RealtimeClientChannelTests: XCTestCase { callbackCalled = true } let start = NSDate() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) XCTAssertNotNil(channel.errorReason) expect(callbackCalled).toEventually(beTrue(), timeout: testTimeout) let end = NSDate() @@ -1972,20 +1972,20 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.closed] let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) client.close() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closing) waitUntil(timeout: testTimeout) { done in channel.detach { error in @@ -1997,15 +1997,15 @@ class RealtimeClientChannelTests: XCTestCase { func test__060__Channel__detach__results_in_an_error_if_the_connection_state_is__FAILED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) client.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.failed) waitUntil(timeout: testTimeout) { done in channel.detach { error in XCTAssertNotNil(error) @@ -2020,14 +2020,14 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.initialized) channel.detach { error in XCTAssertNil(error) @@ -2042,7 +2042,7 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2050,8 +2050,8 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connect() channel.attach() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) channel.detach { error in XCTAssertNil(error) @@ -2063,21 +2063,21 @@ class RealtimeClientChannelTests: XCTestCase { func test__063__Channel__detach__happens_when_channel_is_ATTACHED_if_connection_is_currently__DISCONNECTED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in client.internal.onDisconnected() channel.attach() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.disconnected) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.disconnected) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) channel.detach { error in - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNil(error) done() } @@ -2087,7 +2087,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL5j func test__058__Channel__detach__if_the_channel_state_is_SUSPENDED__the__detach__request_transitions_the_channel_immediately_to_the_DETACHED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2099,14 +2099,14 @@ class RealtimeClientChannelTests: XCTestCase { } channel.internal.setSuspended(.init(state: .ok)) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.suspended) + XCTAssertEqual(channel.state, RealtimeChannelState.suspended) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.once(.detached) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.detached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.suspended) + XCTAssertEqual(stateChange.current, RealtimeChannelState.detached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.suspended) partialDone() } channel.detach { error in @@ -2115,7 +2115,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) } // RTL6 @@ -2127,12 +2127,12 @@ class RealtimeClientChannelTests: XCTestCase { let channelName = test.uniqueChannelName() - let rest = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let rest = Rest(options: try AblyTests.commonAppSetup(for: test)) let restChannel = rest.channels.get(channelName) - var restEncodedMessage: ARTMessage? + var restEncodedMessage: Message? restChannel.internal.testSuite_getReturnValue(from: NSSelectorFromString("encodeMessageIfNeeded:error:")) { value in - restEncodedMessage = value as? ARTMessage + restEncodedMessage = value as? Message } waitUntil(timeout: testTimeout) { done in @@ -2142,15 +2142,15 @@ class RealtimeClientChannelTests: XCTestCase { } } - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.close() } let realtimeChannel = realtime.channels.get(channelName) realtimeChannel.attach() - expect(realtimeChannel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(realtimeChannel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) - var realtimeEncodedMessage: ARTMessage? + var realtimeEncodedMessage: Message? realtimeChannel.internal.testSuite_getReturnValue(from: NSSelectorFromString("encodeMessageIfNeeded:error:")) { value in - realtimeEncodedMessage = value as? ARTMessage + realtimeEncodedMessage = value as? Message } waitUntil(timeout: testTimeout) { done in @@ -2172,7 +2172,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__067__Channel__publish__should_invoke_callback__when_the_message_is_successfully_delivered() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -2201,7 +2201,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let channelname = test.uniqueChannelName() options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelname)\":[\"subscribe\"] }") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -2239,7 +2239,7 @@ class RealtimeClientChannelTests: XCTestCase { options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelToSucceedName)\":[\"subscribe\", \"publish\"], \"\(options.testOptions.channelNamePrefix!)-\(channelToFailName)\":[\"subscribe\"] }") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } struct TotalMessages { @@ -2295,8 +2295,8 @@ class RealtimeClientChannelTests: XCTestCase { let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in @@ -2317,8 +2317,8 @@ class RealtimeClientChannelTests: XCTestCase { } } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in @@ -2328,7 +2328,7 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertEqual((client.internal.transport as! TestProxyTransport).protocolMessagesSent.filter { $0.action == .message }.count, 1) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) } func test__073__Channel__publish__Connection_state_conditions__if_the_connection_is_CONNECTED_and_the_channel_is__DETACHED_then_the_messages_should_be_published_immediately() throws { @@ -2346,8 +2346,8 @@ class RealtimeClientChannelTests: XCTestCase { done() } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) waitUntil(timeout: testTimeout) { done in channel.publish(nil, data: "message") { error in @@ -2357,7 +2357,7 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertEqual((client.internal.transport as! TestProxyTransport).protocolMessagesSent.filter { $0.action == .message }.count, 1) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) } func test__074__Channel__publish__Connection_state_conditions__if_the_connection_is_CONNECTED_and_the_channel_is__ATTACHING_then_the_messages_should_be_published_immediately() throws { @@ -2371,7 +2371,7 @@ class RealtimeClientChannelTests: XCTestCase { } } channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) guard let transport = client.internal.transport as? TestProxyTransport else { fail("Expecting TestProxyTransport"); return } @@ -2385,7 +2385,7 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertEqual((client.internal.transport as! TestProxyTransport).protocolMessagesSent.filter { $0.action == .message }.count, 1) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) } func test__075__Channel__publish__Connection_state_conditions__if_the_connection_is_CONNECTED_and_the_channel_is__DETACHING_then_the_messages_should_be_published_immediately() throws { @@ -2398,9 +2398,9 @@ class RealtimeClientChannelTests: XCTestCase { done() } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) channel.detach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel.state, RealtimeChannelState.detaching) guard let transport = client.internal.transport as? TestProxyTransport else { fail("Expecting TestProxyTransport"); return } @@ -2414,7 +2414,7 @@ class RealtimeClientChannelTests: XCTestCase { XCTAssertEqual((client.internal.transport as! TestProxyTransport).protocolMessagesSent.filter { $0.action == .message }.count, 1) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel.state, RealtimeChannelState.detaching) } // RTL6c2 @@ -2435,7 +2435,7 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - XCTAssertEqual(rtl6c2TestsClient.connection.state, ARTRealtimeConnectionState.initialized) + XCTAssertEqual(rtl6c2TestsClient.connection.state, RealtimeConnectionState.initialized) rtl16c2TestsPublish(done) rtl6c2TestsClient.connect() XCTAssertEqual(rtl6c2TestsClient.internal.queuedMessages.count, 1) @@ -2450,7 +2450,7 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in rtl6c2TestsClient.connect() - XCTAssertEqual(rtl6c2TestsClient.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(rtl6c2TestsClient.connection.state, RealtimeConnectionState.connecting) rtl16c2TestsPublish(done) XCTAssertEqual(rtl6c2TestsClient.internal.queuedMessages.count, 1) } @@ -2463,11 +2463,11 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() - expect(rtl6c2TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c2TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) rtl6c2TestsClient.internal.onDisconnected() waitUntil(timeout: testTimeout) { done in - XCTAssertEqual(rtl6c2TestsClient.connection.state, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(rtl6c2TestsClient.connection.state, RealtimeConnectionState.disconnected) rtl16c2TestsPublish(done) XCTAssertEqual(rtl6c2TestsClient.internal.queuedMessages.count, 1) } @@ -2480,9 +2480,9 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() - XCTAssertEqual(rtl6c2TestsChannel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(rtl6c2TestsChannel.state, RealtimeChannelState.initialized) - expect(rtl6c2TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c2TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl16c2TestsPublish(done) @@ -2498,11 +2498,11 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__the_message(for: test, channelName: test.uniqueChannelName()) rtl6c2TestsClient.connect() - expect(rtl6c2TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c2TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl6c2TestsChannel.attach() - XCTAssertEqual(rtl6c2TestsChannel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(rtl6c2TestsChannel.state, RealtimeChannelState.attaching) rtl16c2TestsPublish(done) XCTAssertEqual(rtl6c2TestsClient.internal.queuedMessages.count, 0) XCTAssertEqual((rtl6c2TestsClient.internal.transport as! TestProxyTransport).protocolMessagesSent.filter { $0.action == .message }.count, 1) @@ -2539,7 +2539,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - XCTAssertEqual(rtl6c2TestsChannel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(rtl6c2TestsChannel.state, RealtimeChannelState.attached) waitUntil(timeout: testTimeout) { done in rtl16c2TestsPublish(done) @@ -2553,14 +2553,14 @@ class RealtimeClientChannelTests: XCTestCase { func beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for test: Test, channelName: String) throws { try setupDependencies(for: test) - ARTDefault.setConnectionStateTtl(0.3) + Default.setConnectionStateTtl(0.3) rtl6c4TestsClient = AblyTests.newRealtime(options).client rtl6c4TestsChannel = rtl6c4TestsClient.channels.get(channelName) } func afterEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the() { rtl6c4TestsClient.close() - ARTDefault.setConnectionStateTtl(previousConnectionStateTtl) + Default.setConnectionStateTtl(previousConnectionStateTtl) } func test__082__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the__connection_is_SUSPENDED() throws { @@ -2568,9 +2568,9 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) rtl6c4TestsClient.internal.onSuspended() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.suspended), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.suspended), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2583,9 +2583,9 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) rtl6c4TestsClient.close() - XCTAssertEqual(rtl6c4TestsClient.connection.state, ARTRealtimeConnectionState.closing) + XCTAssertEqual(rtl6c4TestsClient.connection.state, RealtimeConnectionState.closing) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2598,9 +2598,9 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) rtl6c4TestsClient.close() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2613,9 +2613,9 @@ class RealtimeClientChannelTests: XCTestCase { try beforeEach__Channel__publish__Connection_state_conditions__will_result_in_an_error_if_the(for: test, channelName: test.uniqueChannelName()) rtl6c4TestsClient.connect() - expect(rtl6c4TestsClient.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(rtl6c4TestsClient.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) rtl6c4TestsClient.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(rtl6c4TestsClient.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(rtl6c4TestsClient.connection.state, RealtimeConnectionState.failed) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2629,9 +2629,9 @@ class RealtimeClientChannelTests: XCTestCase { rtl6c4TestsClient.connect() rtl6c4TestsChannel.attach() - expect(rtl6c4TestsChannel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(rtl6c4TestsChannel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) rtl6c4TestsChannel.internal.setSuspended(.init(state: .ok)) - expect(rtl6c4TestsChannel.state).toEventually(equal(ARTRealtimeChannelState.suspended), timeout: testTimeout) + expect(rtl6c4TestsChannel.state).toEventually(equal(RealtimeChannelState.suspended), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2645,10 +2645,10 @@ class RealtimeClientChannelTests: XCTestCase { rtl6c4TestsClient.connect() rtl6c4TestsChannel.attach() - expect(rtl6c4TestsChannel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(rtl6c4TestsChannel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let protocolError = AblyTests.newErrorProtocolMessage() rtl6c4TestsChannel.internal.onError(protocolError) - expect(rtl6c4TestsChannel.state).toEventually(equal(ARTRealtimeChannelState.failed), timeout: testTimeout) + expect(rtl6c4TestsChannel.state).toEventually(equal(RealtimeChannelState.failed), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in rtl6c4TestsPublish(done) } @@ -2659,23 +2659,23 @@ class RealtimeClientChannelTests: XCTestCase { // RTL6c5 func test__070__Channel__publish__Connection_state_conditions__publish_should_not_trigger_an_implicit_attach() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let protocolError = AblyTests.newErrorProtocolMessage() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.publish(nil, data: "message") { error in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) channel.publish(nil, data: "message") { error in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertNotNil(error) done() } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) AblyTests.queue.async { channel.internal.onError(protocolError) } @@ -2719,9 +2719,9 @@ class RealtimeClientChannelTests: XCTestCase { // TODO: limit the total number of messages bundled per ProtocolMessage let maxMessages = 50 - var messages = [ARTMessage]() + var messages = [Message]() for i in 1 ... maxMessages { - messages.append(ARTMessage(name: "total number of messages", data: "message\(i)")) + messages.append(Message(name: "total number of messages", data: "message\(i)")) } waitUntil(timeout: testTimeout) { done in channel.publish(messages) { error in @@ -2834,9 +2834,9 @@ class RealtimeClientChannelTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - var messages = [ARTMessage]() + var messages = [Message]() for i in 1 ... 3 { - messages.append(ARTMessage(name: "name\(i)", data: "data\(i)", clientId: "clientId\(i)")) + messages.append(Message(name: "name\(i)", data: "data\(i)", clientId: "clientId\(i)")) } waitUntil(timeout: testTimeout) { done in @@ -2855,13 +2855,13 @@ class RealtimeClientChannelTests: XCTestCase { // FIXME: Fix flaky presence tests and re-enable. See https://ably-real-time.slack.com/archives/C030C5YLY/p1623172436085700 func skipped__test__090__Channel__publish__message_bundling__should_only_bundle_messages_when_it_respects_all_of_the_constraints() throws { let test = Test() - let defaultMaxMessageSize = ARTDefault.maxMessageSize() - ARTDefault.setMaxMessageSize(256) - defer { ARTDefault.setMaxMessageSize(defaultMaxMessageSize) } + let defaultMaxMessageSize = Default.maxMessageSize() + Default.setMaxMessageSize(256) + defer { Default.setMaxMessageSize(defaultMaxMessageSize) } let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelOne = client.channels.get(test.uniqueChannelName(prefix: "bundlingOne")) let channelTwo = client.channels.get(test.uniqueChannelName(prefix: "bundlingTwo")) @@ -2869,13 +2869,13 @@ class RealtimeClientChannelTests: XCTestCase { channelTwo.publish("2a", data: ["expectedBundle": 0]) channelOne.publish("a", data: ["expectedBundle": 1]) channelOne.publish([ - ARTMessage(name: "b", data: ["expectedBundle": 1]), - ARTMessage(name: "c", data: ["expectedBundle": 1]), + Message(name: "b", data: ["expectedBundle": 1]), + Message(name: "c", data: ["expectedBundle": 1]), ]) channelOne.publish("d", data: ["expectedBundle": 1]) channelTwo.publish("2b", data: ["expectedBundle": 2]) channelOne.publish("e", data: ["expectedBundle": 3]) - channelOne.publish([ARTMessage(name: "f", data: ["expectedBundle": 3])]) + channelOne.publish([Message(name: "f", data: ["expectedBundle": 3])]) // RTL6d2 channelOne.publish("g", data: ["expectedBundle": 4], clientId: "foo") channelOne.publish("h", data: ["expectedBundle": 4], clientId: "foo") @@ -2885,7 +2885,7 @@ class RealtimeClientChannelTests: XCTestCase { channelOne.publish("k", data: ["expectedBundle": 7, "moreData": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"] as [String : Any]) channelOne.publish("l", data: ["expectedBundle": 8]) // RTL6d7 - channelOne.publish([ARTMessage(id: "bundle_m", name: "m", data: ["expectedBundle": 9])]) + channelOne.publish([Message(id: "bundle_m", name: "m", data: ["expectedBundle": 9])]) channelOne.publish("z_last", data: ["expectedBundle": 10]) let expectationMessageBundling = XCTestExpectation(description: "message-bundling") @@ -2928,7 +2928,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__091__Channel__publish__message_bundling__should_publish_only_once_on_multiple_explicit_publish_requests_for_a_given_message_with_client_supplied_ids() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName(prefix: "idempotentRealtimePublishing")) @@ -2942,7 +2942,7 @@ class RealtimeClientChannelTests: XCTestCase { let expectationEvent0 = XCTestExpectation(description: "event0") let expectationEnd = XCTestExpectation(description: "end") - var event0Msgs: [ARTMessage] = [] + var event0Msgs: [Message] = [] channel.subscribe("event0") { message in event0Msgs.append(message) expectationEvent0.fulfill() @@ -2953,9 +2953,9 @@ class RealtimeClientChannelTests: XCTestCase { expectationEnd.fulfill() } - channel.publish([ARTMessage(id: "some_msg_id", name: "event0", data: "")]) - channel.publish([ARTMessage(id: "some_msg_id", name: "event0", data: "")]) - channel.publish([ARTMessage(id: "some_msg_id", name: "event0", data: "")]) + channel.publish([Message(id: "some_msg_id", name: "event0", data: "")]) + channel.publish([Message(id: "some_msg_id", name: "event0", data: "")]) + channel.publish([Message(id: "some_msg_id", name: "event0", data: "")]) channel.publish("end", data: nil) AblyTests.wait(for: [expectationEvent0, expectationEnd]) @@ -2966,7 +2966,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL6e1 func test__095__Channel__publish__Unidentified_clients_using_Basic_Auth__should_have_the_provided_clientId_on_received_message_when_it_was_published_with_clientId() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } XCTAssertNil(client.auth.clientId) @@ -2975,7 +2975,7 @@ class RealtimeClientChannelTests: XCTestCase { var resultClientId: String? - let message = ARTMessage(name: nil, data: "message") + let message = Message(name: nil, data: "message") message.clientId = "client_string" waitUntil(timeout: testTimeout) { done in @@ -2996,7 +2996,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL6f func test__065__Channel__publish__Message_connectionId_should_match_the_current_Connection_id_for_all_published_messages() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3016,7 +3016,7 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3027,7 +3027,7 @@ class RealtimeClientChannelTests: XCTestCase { result.append(message.data as! JSONObject) } - let messages = [ARTMessage(name: nil, data: ["key": 1]), ARTMessage(name: nil, data: ["key": 2])] + let messages = [Message(name: nil, data: ["key": 1]), Message(name: nil, data: ["key": 2])] channel.publish(messages) let transport = client.internal.transport as! TestProxyTransport @@ -3038,7 +3038,7 @@ class RealtimeClientChannelTests: XCTestCase { func test__097__Channel__publish__expect_either__a_name_string_and_data_payload() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3059,15 +3059,15 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["data": "message", "connectionId": client.connection.id!] - var resultMessage: ARTMessage? + var resultMessage: Message? channel.subscribe { message in resultMessage = message } @@ -3082,7 +3082,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let rawProtoMsgsSent: [NSDictionary] = transport.rawDataSent.toMsgPackArray() - let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ARTProtocolMessageAction.message.rawValue } + let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ProtocolMessageAction.message.rawValue } let messagesList = rawMessagesSent[0]["messages"] as! NSArray let resultObject = messagesList[0] as! [String: String] @@ -3098,15 +3098,15 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["name": "click", "connectionId": client.connection.id!] - var resultMessage: ARTMessage? + var resultMessage: Message? channel.subscribe(expectedObject["name"]!) { message in resultMessage = message } @@ -3121,7 +3121,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let rawProtoMsgsSent: [NSDictionary] = transport.rawDataSent.toMsgPackArray() - let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ARTProtocolMessageAction.message.rawValue } + let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ProtocolMessageAction.message.rawValue } let messagesList = rawMessagesSent[0]["messages"] as! NSArray let resultObject = messagesList[0] as! NSDictionary @@ -3137,12 +3137,12 @@ class RealtimeClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedObject = ["name": "click", "data": "message", "connectionId": client.connection.id!] waitUntil(timeout: testTimeout) { done in @@ -3155,7 +3155,7 @@ class RealtimeClientChannelTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let rawProtoMsgsSent: [NSDictionary] = transport.rawDataSent.toMsgPackArray() - let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ARTProtocolMessageAction.message.rawValue } + let rawMessagesSent = rawProtoMsgsSent.filter { $0["action"] as! UInt == ProtocolMessageAction.message.rawValue } let messagesList = rawMessagesSent[0]["messages"] as! NSArray let resultObject = messagesList[0] as! NSDictionary @@ -3173,12 +3173,12 @@ class RealtimeClientChannelTests: XCTestCase { options.clientId = "client_string" options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: nil, data: "message") + let message = Message(name: nil, data: "message") XCTAssertNil(message.clientId) waitUntil(timeout: testTimeout) { done in @@ -3203,11 +3203,11 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: nil, data: "message", clientId: options.clientId!) + let message = Message(name: nil, data: "message", clientId: options.clientId!) var resultClientId: String? waitUntil(timeout: testTimeout) { done in @@ -3230,19 +3230,19 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: nil, data: "message", clientId: "tester")]) { error in - XCTAssertEqual(error?.code, Int(ARTState.mismatchedClientId.rawValue)) + channel.publish([Message(name: nil, data: "message", clientId: "tester")]) { error in + XCTAssertEqual(error?.code, Int(State.mismatchedClientId.rawValue)) done() } } waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: nil, data: "message")]) { error in + channel.publish([Message(name: nil, data: "message")]) { error in XCTAssertNil(error) done() } @@ -3256,10 +3256,10 @@ class RealtimeClientChannelTests: XCTestCase { options.authCallback = { _, completion in getTestTokenDetails(for: test, clientId: "john", completion: completion) } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: nil, data: "message", clientId: "john") + let message = Message(name: nil, data: "message", clientId: "john") waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) channel.subscribe { received in @@ -3280,10 +3280,10 @@ class RealtimeClientChannelTests: XCTestCase { options.authCallback = { _, completion in getTestTokenDetails(for: test, clientId: "john", completion: completion) } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: nil, data: "message", clientId: "tester") + let message = Message(name: nil, data: "message", clientId: "tester") waitUntil(timeout: testTimeout) { done in channel.publish([message]) { error in XCTAssertEqual(error!.code, ARTErrorCode.invalidClientId.intValue) @@ -3295,7 +3295,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL6h func test__066__Channel__publish__should_provide_an_optional_argument_that_allows_the_clientId_value_to_be_specified() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3319,7 +3319,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL7a func test__106__Channel__subscribe__with_no_arguments_subscribes_a_listener_to_all_messages() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3341,7 +3341,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL7b func test__107__Channel__subscribe__with_a_single_name_argument_subscribes_a_listener_to_only_messages_whose_name_member_matches_the_string_name() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3364,19 +3364,19 @@ class RealtimeClientChannelTests: XCTestCase { func test__108__Channel__subscribe__with_a_attach_callback_should_subscribe_and_call_the_callback_when_attached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let publishedMessage = ARTMessage(name: "foo", data: "bar") + let publishedMessage = Message(name: "foo", data: "bar") waitUntil(timeout: testTimeout) { done in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.subscribe(attachCallback: { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) channel.publish([publishedMessage]) }) { message in XCTAssertEqual(message.name, publishedMessage.name) @@ -3384,32 +3384,32 @@ class RealtimeClientChannelTests: XCTestCase { done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) } } // RTL7c func test__109__Channel__subscribe__should_implicitly_attach_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.subscribe { _ in } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTL7c func test__110__Channel__subscribe__should_result_in_an_error_if_channel_is_in_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) waitUntil(timeout: testTimeout) { done in channel.subscribe(attachCallback: { errorInfo in @@ -3440,13 +3440,13 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - options.logHandler = ARTLog(capturingOutput: true) + options.logHandler = Log(capturingOutput: true) options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - let channelOptions = ARTRealtimeChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) + let channelOptions = RealtimeChannelOptions(cipher: ["key": Crypto.generateRandomKey()] as CipherParamsCompatible) let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) let expectedMessage = ["key": 1] @@ -3487,11 +3487,11 @@ class RealtimeClientChannelTests: XCTestCase { func test__111__Channel__subscribe__should_exist_ensuring_published_messages_are_not_echoed_back_to_the_subscriber_when_echoMessages_is_false() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } options.echoMessages = false - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channelName = test.uniqueChannelName() @@ -3520,7 +3520,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL8a func test__115__Channel__unsubscribe__with_no_arguments_unsubscribes_the_provided_listener_to_all_messages_if_subscribed() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3543,7 +3543,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL8b func test__116__Channel__unsubscribe__with_a_single_name_argument_unsubscribes_the_provided_listener_if_previously_subscribed_with_a_name_specific_subscription() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3570,9 +3570,9 @@ class RealtimeClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } let channelRest = rest.channels.get(test.uniqueChannelName()) @@ -3580,23 +3580,23 @@ class RealtimeClientChannelTests: XCTestCase { var restChannelHistoryMethodWasCalled = false - let hookRest = channelRest.testSuite_injectIntoMethod(after: #selector(ARTRestChannel.history(_:callback:))) { + let hookRest = channelRest.testSuite_injectIntoMethod(after: #selector(RestChannel.history(_:callback:))) { restChannelHistoryMethodWasCalled = true } defer { hookRest.remove() } - let hookRealtime = channelRealtime.testSuite_injectIntoMethod(after: #selector(ARTRestChannel.history(_:callback:))) { + let hookRealtime = channelRealtime.testSuite_injectIntoMethod(after: #selector(RestChannel.history(_:callback:))) { restChannelHistoryMethodWasCalled = true } defer { hookRealtime.remove() } - let queryRealtime = ARTRealtimeHistoryQuery() + let queryRealtime = RealtimeHistoryQuery() queryRealtime.start = NSDate() as Date queryRealtime.end = NSDate() as Date queryRealtime.direction = .forwards queryRealtime.limit = 50 - let queryRest = queryRealtime as ARTDataQuery + let queryRest = queryRealtime as DataQuery waitUntil(timeout: testTimeout) { done in expect { @@ -3621,23 +3621,23 @@ class RealtimeClientChannelTests: XCTestCase { // RTL10b func test__123__Channel__history__supports_the_param_untilAttach__should_be_false_as_default() { - let query = ARTRealtimeHistoryQuery() + let query = RealtimeHistoryQuery() XCTAssertEqual(query.untilAttach, false) } func test__124__Channel__history__supports_the_param_untilAttach__should_invoke_an_error_when_the_untilAttach_is_specified_and_the_channel_is_not_attached() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTRealtimeHistoryQuery() + let query = RealtimeHistoryQuery() query.untilAttach = true do { try channel.history(query, callback: { _, _ in }) } catch let error as NSError { - if error.code != ARTRealtimeHistoryError.notAttached.rawValue { + if error.code != RealtimeHistoryError.notAttached.rawValue { fail("Shouldn't raise a global error, got \(error)") } return @@ -3658,22 +3658,22 @@ class RealtimeClientChannelTests: XCTestCase { func test__127__Channel__history__supports_the_param_untilAttach__should_retrieve_messages_prior_to_the_moment_that_the_channel_was_attached() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } options.autoConnect = false - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) channel1.attach() - expect(channel1.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel1.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) - var messages = [ARTMessage]() + var messages = [Message]() for i in 0 ..< 20 { - messages.append(ARTMessage(name: nil, data: "message \(i)")) + messages.append(Message(name: nil, data: "message \(i)")) } waitUntil(timeout: testTimeout) { done in channel1.publish(messages) { errorInfo in @@ -3685,7 +3685,7 @@ class RealtimeClientChannelTests: XCTestCase { client2.connect() let channel2 = client2.channels.get(channelName) channel2.attach() - expect(channel2.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel2.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) var counter = 20 channel2.subscribe { message in @@ -3693,9 +3693,9 @@ class RealtimeClientChannelTests: XCTestCase { counter += 1 } - messages = [ARTMessage]() + messages = [Message]() for i in 20 ..< 40 { - messages.append(ARTMessage(name: nil, data: "message \(i)")) + messages.append(Message(name: nil, data: "message \(i)")) } waitUntil(timeout: testTimeout) { done in channel1.publish(messages) { errorInfo in @@ -3704,7 +3704,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - let query = ARTRealtimeHistoryQuery() + let query = RealtimeHistoryQuery() query.untilAttach = true waitUntil(timeout: testTimeout) { done in @@ -3727,7 +3727,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL10c func test__118__Channel__history__should_return_a_PaginatedResult_page() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.close() } let channel = realtime.channels.get(test.uniqueChannelName()) @@ -3741,7 +3741,7 @@ class RealtimeClientChannelTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.history { result, error in XCTAssertNil(error) - expect(result).to(beAKindOf(ARTPaginatedResult.self)) + expect(result).to(beAKindOf(PaginatedResult.self)) guard let result = result else { fail("Result is empty"); done(); return } @@ -3758,21 +3758,21 @@ class RealtimeClientChannelTests: XCTestCase { func test__119__Channel__history__should_retrieve_all_available_messages() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) channel1.attach() - expect(channel1.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel1.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) - var messages = [ARTMessage]() + var messages = [Message]() for i in 0 ..< 20 { - messages.append(ARTMessage(name: nil, data: "message \(i)")) + messages.append(Message(name: nil, data: "message \(i)")) } waitUntil(timeout: testTimeout) { done in channel1.publish(messages) { errorInfo in @@ -3783,9 +3783,9 @@ class RealtimeClientChannelTests: XCTestCase { let channel2 = client2.channels.get(channelName) channel2.attach() - expect(channel2.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel2.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) - let query = ARTRealtimeHistoryQuery() + let query = RealtimeHistoryQuery() query.limit = 10 waitUntil(timeout: testTimeout) { done in @@ -3832,7 +3832,7 @@ class RealtimeClientChannelTests: XCTestCase { var hook: AspectToken? waitUntil(timeout: testTimeout) { done in - let attachedMessage = ARTProtocolMessage() + let attachedMessage = ProtocolMessage() attachedMessage.action = .attached attachedMessage.channel = channel.name @@ -3850,7 +3850,7 @@ class RealtimeClientChannelTests: XCTestCase { } hook!.remove() XCTAssertNil(channel.errorReason) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) waitUntil(timeout: testTimeout) { done in let attachedMessageWithError = AblyTests.newErrorProtocolMessage() @@ -3858,9 +3858,9 @@ class RealtimeClientChannelTests: XCTestCase { attachedMessageWithError.channel = channel.name channel.on { stateChange in - XCTAssertEqual(stateChange.event, ARTChannelEvent.update) - XCTAssertEqual(stateChange.current, ARTRealtimeChannelState.attached) - XCTAssertEqual(stateChange.previous, ARTRealtimeChannelState.attached) + XCTAssertEqual(stateChange.event, ChannelEvent.update) + XCTAssertEqual(stateChange.current, RealtimeChannelState.attached) + XCTAssertEqual(stateChange.previous, RealtimeChannelState.attached) XCTAssertTrue(stateChange.reason === attachedMessageWithError.error) XCTAssertTrue(stateChange.reason === channel.errorReason) XCTAssertFalse(stateChange.resumed) @@ -3870,7 +3870,7 @@ class RealtimeClientChannelTests: XCTestCase { // Inject additional ATTACHED action with an error client.internal.transport?.receive(attachedMessageWithError) - let attachedMessage = ARTProtocolMessage() + let attachedMessage = ProtocolMessage() attachedMessage.action = .attached attachedMessage.channel = channel.name attachedMessage.flags = 4 // resume @@ -3878,7 +3878,7 @@ class RealtimeClientChannelTests: XCTestCase { // Inject another ATTACHED action with resume flag, should not generate neither .attached nor .update events client.internal.transport?.receive(attachedMessage) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) } // RTL13 @@ -3897,7 +3897,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not set"); return @@ -4104,10 +4104,10 @@ class RealtimeClientChannelTests: XCTestCase { let mockJitterCoefficientGenerator = MockJitterCoefficientGenerator(coefficients: jitterCoefficients) options.testOptions.jitterCoefficientGenerator = mockJitterCoefficientGenerator - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) /* ...whose transport drops all incoming ATTACHED messages... @@ -4124,13 +4124,13 @@ class RealtimeClientChannelTests: XCTestCase { // ...(A) which we put into the ATTACHING state, channel.attach() - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) // When... struct ObservedStateChange { var observedAt: Date - var stateChange: ARTChannelStateChange + var stateChange: ChannelStateChange } let numberOfRetriesToWaitFor = 5 // arbitrarily-chosen, see (D) let retrySequenceDataGatherer = DataGatherer(description: "Observe emitted state changes") { submit in @@ -4269,7 +4269,7 @@ class RealtimeClientChannelTests: XCTestCase { // RTL14 func test__121__Channel__history__If_an_ERROR_ProtocolMessage_is_received_for_this_channel_then_the_channel_should_immediately_transition_to_the_FAILED_state__the_errorReason_should_be_set_and_an_error_should_be_emitted_on_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -4296,7 +4296,7 @@ class RealtimeClientChannelTests: XCTestCase { client.internal.transport?.receive(errorProtocolMessage) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } // RTL15 @@ -4309,7 +4309,7 @@ class RealtimeClientChannelTests: XCTestCase { defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let transport = try XCTUnwrap(client.internal.transport as? TestProxyTransport) @@ -4338,7 +4338,7 @@ class RealtimeClientChannelTests: XCTestCase { } partialDone() } - channel.publish([ARTMessage()]) + channel.publish([Message()]) } } } @@ -4351,33 +4351,33 @@ class RealtimeClientChannelTests: XCTestCase { defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) // Case for detached channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) expect(channel.internal.channelSerial).toNot(beNil()) channel.detach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) expect(channel.internal.channelSerial).to(beNil()) // Case for suspended channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) expect(channel.internal.channelSerial).toNot(beNil()) channel.internal.setSuspended(.init(state: .ok)) - expect(channel.state).to(equal(ARTRealtimeChannelState.suspended)) + expect(channel.state).to(equal(RealtimeChannelState.suspended)) expect(channel.internal.channelSerial).to(beNil()) // Case for failed channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) expect(channel.internal.channelSerial).toNot(beNil()) channel.internal.setFailed(.init(state: .ok)) - expect(channel.state).to(equal(ARTRealtimeChannelState.failed)) + expect(channel.state).to(equal(RealtimeChannelState.failed)) expect(channel.internal.channelSerial).to(beNil()) } @@ -4402,7 +4402,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Expecting TestProxyTransport"); return } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe, .publish] channelOptions.params = [ "delta": "vcdiff", @@ -4423,8 +4423,8 @@ class RealtimeClientChannelTests: XCTestCase { guard let lastAttach = attachMessages.last else { fail("Last ATTACH message is missing"); return } - expect(lastAttach.flags & Int64(ARTChannelMode.publish.rawValue)).to(beGreaterThan(0)) // true - expect(lastAttach.flags & Int64(ARTChannelMode.subscribe.rawValue)).to(beGreaterThan(0)) // true + expect(lastAttach.flags & Int64(ChannelMode.publish.rawValue)).to(beGreaterThan(0)) // true + expect(lastAttach.flags & Int64(ChannelMode.subscribe.rawValue)).to(beGreaterThan(0)) // true XCTAssertEqual(lastAttach.params, channelOptions.params) let attachedMessages = transport.protocolMessagesReceived.filter { $0.action == .attached } @@ -4432,8 +4432,8 @@ class RealtimeClientChannelTests: XCTestCase { guard let lastAttached = attachedMessages.last else { fail("Last ATTACH message is missing"); return } - expect(lastAttached.flags & Int64(ARTChannelMode.publish.rawValue)).to(beGreaterThan(0)) // true - expect(lastAttached.flags & Int64(ARTChannelMode.subscribe.rawValue)).to(beGreaterThan(0)) // true + expect(lastAttached.flags & Int64(ChannelMode.publish.rawValue)).to(beGreaterThan(0)) // true + expect(lastAttached.flags & Int64(ChannelMode.subscribe.rawValue)).to(beGreaterThan(0)) // true XCTAssertEqual(lastAttached.params, channelOptions.params) } @@ -4452,7 +4452,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Expecting TestProxyTransport"); return } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe] channelOptions.params = [ "delta": "vcdiff", @@ -4476,7 +4476,7 @@ class RealtimeClientChannelTests: XCTestCase { channel.attach() } - let subscribeFlag = Int64(ARTChannelMode.subscribe.rawValue) + let subscribeFlag = Int64(ChannelMode.subscribe.rawValue) let attachMessages = transport.protocolMessagesSent.filter { $0.action == .attach } XCTAssertEqual(attachMessages.count, 2) @@ -4503,7 +4503,7 @@ class RealtimeClientChannelTests: XCTestCase { defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe] channelOptions.params = [ "delta": "vcdiff", @@ -4536,7 +4536,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Expecting TestProxyTransport"); return } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe] channelOptions.params = [ "delta": "vcdiff", @@ -4555,7 +4555,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - let subscribeFlag = Int64(ARTChannelMode.subscribe.rawValue) + let subscribeFlag = Int64(ChannelMode.subscribe.rawValue) let attachMessages = transport.protocolMessagesSent.filter { $0.action == .attach } XCTAssertEqual(attachMessages.count, 2) @@ -4585,7 +4585,7 @@ class RealtimeClientChannelTests: XCTestCase { fail("Expecting TestProxyTransport"); return } - let channelOptions = ARTRealtimeChannelOptions() + let channelOptions = RealtimeChannelOptions() channelOptions.modes = [.subscribe] channelOptions.params = [ "delta": "vcdiff", @@ -4612,7 +4612,7 @@ class RealtimeClientChannelTests: XCTestCase { } } - let subscribeFlag = Int64(ARTChannelMode.subscribe.rawValue) + let subscribeFlag = Int64(ChannelMode.subscribe.rawValue) let attachMessages = transport.protocolMessagesSent.filter { $0.action == .attach } XCTAssertEqual(attachMessages.count, 2) @@ -4635,17 +4635,17 @@ class RealtimeClientChannelTests: XCTestCase { } } - var restChannelSetOptions: ARTChannelOptions? + var restChannelSetOptions: ChannelOptions? let token = channel.internal.restChannel.testSuite_getArgument(from: #selector(ARTRestChannelInternal.setOptions_nosync(_:)), at: 0) { arg in - guard let optionsArg = arg as? ARTChannelOptions else { - XCTFail("Expected setOptions: to have been called with an ARTChannelOptions instance") + guard let optionsArg = arg as? ChannelOptions else { + XCTFail("Expected setOptions: to have been called with an ChannelOptions instance") return } restChannelSetOptions = optionsArg } defer { token.remove() } - let channelOptions = ARTRealtimeChannelOptions(cipherKey: ARTCrypto.generateRandomKey() as NSData) + let channelOptions = RealtimeChannelOptions(cipherKey: Crypto.generateRandomKey() as NSData) waitUntil(timeout: testTimeout) { done in channel.setOptions(channelOptions) { error in @@ -4661,12 +4661,12 @@ class RealtimeClientChannelTests: XCTestCase { func test__122__Channel__history__should_not_emit_messages_to_subscribers_if_the_channel_is_in_any_state_other_than_ATTACHED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close(); client.dispose() } let channel = client.channels.get(test.uniqueChannelName()) - let m1 = ARTMessage(name: "m1", data: "d1") - let m2 = ARTMessage(name: "m2", data: "d2") + let m1 = Message(name: "m1", data: "d1") + let m2 = Message(name: "m2", data: "d2") var subscribeEmittedCount = 0 waitUntil(timeout: testTimeout) { done in @@ -4711,20 +4711,20 @@ class RealtimeClientChannelTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let clientSender = ARTRealtime(options: options) + let clientSender = Realtime(options: options) defer { clientSender.close() } clientSender.connect() - let clientReceiver = ARTRealtime(options: options) + let clientReceiver = Realtime(options: options) defer { clientReceiver.close() } clientReceiver.connect() - let key = ARTCrypto.generateRandomKey() + let key = Crypto.generateRandomKey() let channelName = test.uniqueChannelName() - let sender = clientSender.channels.get(channelName, options: ARTRealtimeChannelOptions(cipherKey: key as ARTCipherKeyCompatible)) - let receiver = clientReceiver.channels.get(channelName, options: ARTRealtimeChannelOptions(cipherKey: key as ARTCipherKeyCompatible)) + let sender = clientSender.channels.get(channelName, options: RealtimeChannelOptions(cipherKey: key as CipherKeyCompatible)) + let receiver = clientReceiver.channels.get(channelName, options: RealtimeChannelOptions(cipherKey: key as CipherKeyCompatible)) - var received = [ARTMessage]() + var received = [Message]() waitUntil(timeout: testTimeout) { done in receiver.attach { _ in @@ -4806,7 +4806,7 @@ class RealtimeClientChannelTests: XCTestCase { transport.setBeforeIncomingMessageModifier { protocolMessage in if protocolMessage.action == .attached { protocolMessage.action = .detached - protocolMessage.error = ARTErrorInfo.create(withCode: ARTErrorCode.internalError.intValue, status: 500, message: "fake error message text") + protocolMessage.error = ErrorInfo.create(withCode: ARTErrorCode.internalError.intValue, status: 500, message: "fake error message text") } return protocolMessage } @@ -4825,11 +4825,11 @@ class RealtimeClientChannelTests: XCTestCase { // TM2a func test__139__message_attributes__if_the_message_does_not_contain_an_id__it_should_be_set_to_protocolMsgId_index() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let p = ARTProtocolMessage() + let p = ProtocolMessage() p.id = "protocolId" - let m = ARTMessage(name: nil, data: "message without ID") + let m = Message(name: nil, data: "message without ID") p.messages = [m] let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in diff --git a/Test/Tests/RealtimeClientChannelsTests.swift b/Test/Tests/RealtimeClientChannelsTests.swift index 7cb29daa3..a74d5ea3a 100644 --- a/Test/Tests/RealtimeClientChannelsTests.swift +++ b/Test/Tests/RealtimeClientChannelsTests.swift @@ -3,7 +3,7 @@ import Nimble import XCTest // Swift isn't yet smart enough to do this automatically when bridging Objective-C APIs -extension ARTRealtimeChannels: Sequence { +extension RealtimeChannels: Sequence { public func makeIterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(iterate()) } @@ -13,7 +13,7 @@ class RealtimeClientChannelsTests: XCTestCase { // RTS2 func test__001__Channels__should_exist_methods_to_check_if_a_channel_exists_or_iterate_through_the_existing_channels() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } var disposable = [String]() @@ -30,7 +30,7 @@ class RealtimeClientChannelsTests: XCTestCase { XCTAssertFalse(client.channels.exists("testX")) for channel in client.channels { - XCTAssertTrue(disposable.contains((channel as! ARTRealtimeChannel).name)) + XCTAssertTrue(disposable.contains((channel as! RealtimeChannel).name)) } } @@ -40,7 +40,7 @@ class RealtimeClientChannelsTests: XCTestCase { func test__002__Channels__get__should_create_a_new_Channel_if_none_exists_or_return_the_existing_one() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } XCTAssertEqual(client.channels.internal.collection.count, 0) @@ -56,9 +56,9 @@ class RealtimeClientChannelsTests: XCTestCase { // RTS3b func test__003__Channels__get__should_be_possible_to_specify_a_ChannelOptions() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } - let options = ARTRealtimeChannelOptions() + let options = RealtimeChannelOptions() let channel = client.channels.get(test.uniqueChannelName(), options: options) XCTAssertTrue(channel.options === options) } @@ -66,11 +66,11 @@ class RealtimeClientChannelsTests: XCTestCase { // RTS3c func test__004__Channels__get__accessing_an_existing_Channel_with_options_should_update_the_options_and_then_return_the_object() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() XCTAssertNil(client.channels.get(channelName).options) - let options = ARTRealtimeChannelOptions() + let options = RealtimeChannelOptions() let channel = client.channels.get(channelName, options: options) XCTAssertTrue(channel.options === options) } @@ -79,7 +79,7 @@ class RealtimeClientChannelsTests: XCTestCase { func test__005__Channels__release__should_release_a_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -93,7 +93,7 @@ class RealtimeClientChannelsTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.channels.release(channelName) { errorInfo in XCTAssertNil(errorInfo) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) done() } } diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index 0b68a324f..536a52348 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -2,7 +2,7 @@ import Ably import Nimble import XCTest -func countChannels(_ channels: ARTRealtimeChannels) -> Int { +func countChannels(_ channels: RealtimeChannels) -> Int { var i = 0 for _ in channels { i += 1 @@ -10,11 +10,11 @@ func countChannels(_ channels: ARTRealtimeChannels) -> Int { return i } -private var ttlAndIdleIntervalPassedTestsClient: ARTRealtime! +private var ttlAndIdleIntervalPassedTestsClient: Realtime! private var ttlAndIdleIntervalPassedTestsConnectionId = "" private let customTtlInterval: TimeInterval = 0.1 private let customIdleInterval: TimeInterval = 0.1 -private var ttlAndIdleIntervalNotPassedTestsClient: ARTRealtime! +private var ttlAndIdleIntervalNotPassedTestsClient: Realtime! private var ttlAndIdleIntervalNotPassedTestsConnectionId = "" private let expectedHostOrder = [3, 4, 0, 2, 1] private let shuffleArrayInExpectedHostOrder = { (array: NSMutableArray) in @@ -24,12 +24,12 @@ private let shuffleArrayInExpectedHostOrder = { (array: NSMutableArray) in } } private func testUsesAlternativeHostOnResponse(_ caseTest: FakeNetworkResponse, channelName: String) { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(channelName) @@ -98,12 +98,12 @@ private func testMovesToDisconnectedWithNetworkingError(_ error: Error, for test } } -private var internetConnectionNotAvailableTestsClient: ARTRealtime! +private var internetConnectionNotAvailableTestsClient: Realtime! private let fixtures: [String: Any] = try! JSONUtility.jsonObject( data: try! Data(contentsOf: URL(fileURLWithPath: pathForTestResource(testResourcesPath + "messages-encoding.json"))) )! -private func expectDataToMatch(_ message: ARTMessage, _ fixtureMessage: Any) { +private func expectDataToMatch(_ message: Message, _ fixtureMessage: Any) { let dictionaryValue = fixtureMessage as! [String: Any] switch dictionaryValue["expectedType"] as! String { @@ -128,15 +128,15 @@ private func expectDataToMatch(_ message: ARTMessage, _ fixtureMessage: Any) { } } -private var jsonOptions: ARTClientOptions! -private var msgpackOptions: ARTClientOptions! +private var jsonOptions: ClientOptions! +private var msgpackOptions: ClientOptions! private func setupDependencies(for test: Test) throws { if jsonOptions == nil { jsonOptions = try AblyTests.commonAppSetup(for: test) jsonOptions.useBinaryProtocol = false // Keep the same key and channel prefix - msgpackOptions = (jsonOptions.copy() as! ARTClientOptions) + msgpackOptions = (jsonOptions.copy() as! ClientOptions) msgpackOptions.useBinaryProtocol = true } } @@ -166,15 +166,15 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) - let defaultMaxMessageSize = ARTDefault.maxMessageSize() + let client = Realtime(options: options) + let defaultMaxMessageSize = Default.maxMessageSize() XCTAssertEqual(defaultMaxMessageSize, 65536) defer { - ARTDefault.setMaxMessageSize(defaultMaxMessageSize) + Default.setMaxMessageSize(defaultMaxMessageSize) client.dispose() client.close() } - ARTDefault.setMaxMessageSize(1) + Default.setMaxMessageSize(1) waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -190,11 +190,11 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN2 func test__017__Connection__url__should_connect_to_the_default_host() { - let options = ARTClientOptions(key: "keytest:secret") + let options = ClientOptions(key: "keytest:secret") options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -211,7 +211,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -248,7 +248,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.echoMessages = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -286,7 +286,7 @@ class RealtimeClientConnectionTests: XCTestCase { // Default XCTAssertTrue(options.autoConnect, "autoConnect should be true by default") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } // The only way to control this functionality is with the options flag client.connection.on { stateChange in @@ -308,7 +308,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } var waiting = true @@ -339,7 +339,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in client.connection.once(.connecting) { _ in @@ -349,7 +349,7 @@ class RealtimeClientConnectionTests: XCTestCase { } XCTAssertNotNil(webSocketTransport.websocketURL) - // This test should not directly validate version against ARTDefault.version(), as + // This test should not directly validate version against Default.version(), as // ultimately the version header has been derived from that value. expect(webSocketTransport.websocketURL?.query).to(haveParam("v", withValue: "2")) @@ -368,7 +368,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() waitUntil(timeout: testTimeout) { done in @@ -402,10 +402,10 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let connection = client.connection - var events: [ARTRealtimeConnectionState] = [] + var events: [RealtimeConnectionState] = [] waitUntil(timeout: testTimeout) { done in var alreadyDisconnected = false @@ -462,21 +462,21 @@ class RealtimeClientConnectionTests: XCTestCase { return } - XCTAssertEqual(events[0].rawValue, ARTRealtimeConnectionState.initialized.rawValue, "Should be INITIALIZED state") - XCTAssertEqual(events[1].rawValue, ARTRealtimeConnectionState.connecting.rawValue, "Should be CONNECTING state") - XCTAssertEqual(events[2].rawValue, ARTRealtimeConnectionState.connected.rawValue, "Should be CONNECTED state") - XCTAssertEqual(events[3].rawValue, ARTRealtimeConnectionState.disconnected.rawValue, "Should be DISCONNECTED state") - XCTAssertEqual(events[4].rawValue, ARTRealtimeConnectionState.closing.rawValue, "Should be CLOSING state") - XCTAssertEqual(events[5].rawValue, ARTRealtimeConnectionState.closed.rawValue, "Should be CLOSED state") - XCTAssertEqual(events[6].rawValue, ARTRealtimeConnectionState.suspended.rawValue, "Should be SUSPENDED state") - XCTAssertEqual(events[7].rawValue, ARTRealtimeConnectionState.failed.rawValue, "Should be FAILED state") + XCTAssertEqual(events[0].rawValue, RealtimeConnectionState.initialized.rawValue, "Should be INITIALIZED state") + XCTAssertEqual(events[1].rawValue, RealtimeConnectionState.connecting.rawValue, "Should be CONNECTING state") + XCTAssertEqual(events[2].rawValue, RealtimeConnectionState.connected.rawValue, "Should be CONNECTED state") + XCTAssertEqual(events[3].rawValue, RealtimeConnectionState.disconnected.rawValue, "Should be DISCONNECTED state") + XCTAssertEqual(events[4].rawValue, RealtimeConnectionState.closing.rawValue, "Should be CLOSING state") + XCTAssertEqual(events[5].rawValue, RealtimeConnectionState.closed.rawValue, "Should be CLOSED state") + XCTAssertEqual(events[6].rawValue, RealtimeConnectionState.suspended.rawValue, "Should be SUSPENDED state") + XCTAssertEqual(events[7].rawValue, RealtimeConnectionState.failed.rawValue, "Should be FAILED state") } // RTN4h func test__021__Connection__event_emitter__should_never_emit_a_ConnectionState_event_for_a_state_equal_to_the_previous_state() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -493,13 +493,13 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connection.once(.update) { stateChange in XCTAssertNil(stateChange.reason) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.connected) XCTAssertEqual(stateChange.current, stateChange.previous) done() } - let authMessage = ARTProtocolMessage() + let authMessage = ProtocolMessage() authMessage.action = .auth client.internal.transport?.receive(authMessage) } @@ -511,10 +511,10 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let connection = client.connection - var events: [ARTRealtimeConnectionState] = [] + var events: [RealtimeConnectionState] = [] waitUntil(timeout: testTimeout) { done in connection.on { stateChange in @@ -540,17 +540,17 @@ class RealtimeClientConnectionTests: XCTestCase { return } - XCTAssertEqual(events[0].rawValue, ARTRealtimeConnectionState.connecting.rawValue, "Should be CONNECTING state") - XCTAssertEqual(events[1].rawValue, ARTRealtimeConnectionState.connected.rawValue, "Should be CONNECTED state") + XCTAssertEqual(events[0].rawValue, RealtimeConnectionState.connecting.rawValue, "Should be CONNECTING state") + XCTAssertEqual(events[1].rawValue, RealtimeConnectionState.connected.rawValue, "Should be CONNECTED state") } // RTN4c func test__023__Connection__event_emitter__should_emit_states_when_connection_is_closed() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) let connection = client.connection defer { client.dispose(); client.close() } - var events: [ARTRealtimeConnectionState] = [] + var events: [RealtimeConnectionState] = [] waitUntil(timeout: testTimeout) { done in connection.on { stateChange in @@ -577,8 +577,8 @@ class RealtimeClientConnectionTests: XCTestCase { return } - XCTAssertEqual(events[0].rawValue, ARTRealtimeConnectionState.closing.rawValue, "Should be CLOSING state") - XCTAssertEqual(events[1].rawValue, ARTRealtimeConnectionState.closed.rawValue, "Should be CLOSED state") + XCTAssertEqual(events[0].rawValue, RealtimeConnectionState.closing.rawValue, "Should be CLOSING state") + XCTAssertEqual(events[1].rawValue, RealtimeConnectionState.closed.rawValue, "Should be CLOSED state") } // RTN4d @@ -586,10 +586,10 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let connection = client.connection - XCTAssertEqual(connection.state.rawValue, ARTRealtimeConnectionState.initialized.rawValue, "Missing INITIALIZED state") + XCTAssertEqual(connection.state.rawValue, RealtimeConnectionState.initialized.rawValue, "Missing INITIALIZED state") waitUntil(timeout: testTimeout) { done in connection.on { stateChange in @@ -598,9 +598,9 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertNil(error) switch state { case .connecting: - XCTAssertEqual(connection.state.rawValue, ARTRealtimeConnectionState.connecting.rawValue, "Missing CONNECTING state") + XCTAssertEqual(connection.state.rawValue, RealtimeConnectionState.connecting.rawValue, "Missing CONNECTING state") case .connected: - XCTAssertEqual(connection.state.rawValue, ARTRealtimeConnectionState.connected.rawValue, "Missing CONNECTED state") + XCTAssertEqual(connection.state.rawValue, RealtimeConnectionState.connected.rawValue, "Missing CONNECTED state") done() default: break @@ -615,14 +615,14 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in - client.connection.once(ARTRealtimeConnectionEvent.connected) { stateChange in - expect(stateChange).to(beAKindOf(ARTConnectionStateChange.self)) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.connected) - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + client.connection.once(RealtimeConnectionEvent.connected) { stateChange in + expect(stateChange).to(beAKindOf(ConnectionStateChange.self)) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) done() } client.connect() @@ -633,21 +633,21 @@ class RealtimeClientConnectionTests: XCTestCase { func test__026__Connection__event_emitter__should_have_the_reason_which_contains_an_ErrorInfo() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let connection = client.connection - var errorInfo: ARTErrorInfo? + var errorInfo: ErrorInfo? waitUntil(timeout: testTimeout) { done in connection.on { stateChange in let state = stateChange.current let reason = stateChange.reason switch state { case .connected: - XCTAssertEqual(stateChange.event, ARTRealtimeConnectionEvent.connected) + XCTAssertEqual(stateChange.event, RealtimeConnectionEvent.connected) client.internal.onError(AblyTests.newErrorProtocolMessage()) case .failed: - XCTAssertEqual(stateChange.event, ARTRealtimeConnectionEvent.failed) + XCTAssertEqual(stateChange.event, RealtimeConnectionEvent.failed) errorInfo = reason done() default: @@ -688,12 +688,12 @@ class RealtimeClientConnectionTests: XCTestCase { } XCTAssertEqual(error.code, 1234) XCTAssertEqual(error.message, "fabricated error") - XCTAssertEqual(stateChange.event, ARTRealtimeConnectionEvent.update) + XCTAssertEqual(stateChange.event, RealtimeConnectionEvent.update) done() } let connectedMessageWithError = originalConnectedMessage - connectedMessageWithError.error = ARTErrorInfo.create(withCode: 1234, message: "fabricated error") + connectedMessageWithError.error = ErrorInfo.create(withCode: 1234, message: "fabricated error") client.internal.transport?.receive(connectedMessageWithError) } } @@ -703,7 +703,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.echoMessages = false - var disposable = [ARTRealtime]() + var disposable = [Realtime]() let numClients = 50 let numMessages = 5 let channelName = "chat" @@ -719,7 +719,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(numClients, done: done) for _ in 1 ... numClients { - let client = ARTRealtime(options: options) + let client = Realtime(options: options) disposable.append(client) let channel = client.channels.get(channelName) channel.attach { error in @@ -740,7 +740,7 @@ class RealtimeClientConnectionTests: XCTestCase { var messagesSent = 0 for client in disposable { let channel = client.channels.get(channelName) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) channel.subscribe { message in XCTAssertEqual(message.data as? String, "message_string") @@ -768,7 +768,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose() @@ -794,7 +794,7 @@ class RealtimeClientConnectionTests: XCTestCase { if let transport = client.internal.transport as? TestProxyTransport { // CONNECTED ProtocolMessage - expect(transport.protocolMessagesReceived.map { $0.action }).to(contain(ARTProtocolMessageAction.connected)) + expect(transport.protocolMessagesReceived.map { $0.action }).to(contain(ProtocolMessageAction.connected)) } else { XCTFail("MockTransport is not working") } @@ -810,7 +810,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -840,7 +840,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -883,7 +883,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.token = try getTestToken(for: test, key: options.key, capability: "{ \"\(options.testOptions.channelNamePrefix!)-\(channelName)\":[\"subscribe\"] }") options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -913,7 +913,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -956,7 +956,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -1200,7 +1200,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -1239,7 +1239,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.clientId = "client_string" options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } @@ -1268,7 +1268,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__038__Connection__connection_id__should_be_null_until_connected() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let connection = client.connection defer { client.dispose() @@ -1296,7 +1296,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__039__Connection__connection_id__should_have_unique_IDs() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for client in disposable { client.dispose() @@ -1309,7 +1309,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in for _ in 1 ... max { - disposable.append(ARTRealtime(options: options)) + disposable.append(Realtime(options: options)) let currentConnection = disposable.last!.connection currentConnection.on { stateChange in let state = stateChange.current @@ -1345,7 +1345,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__139__Connection__connection_id_and_key__should_be_nil_when_sdk_is_in_CLOSING_and_CLOSED_states() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1376,7 +1376,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__140__Connection__connection_id_and_key__should_be_nil_when_sdk_is_in_SUSPENDED_state() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1402,7 +1402,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__141__Connection__connection_id_and_key__should_be_nil_when_sdk_is_in_FAILED_state() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1413,7 +1413,7 @@ class RealtimeClientConnectionTests: XCTestCase { if stateChange.current == .connected { expect(client.connection.id).toNot(beNil()) expect(client.connection.key).toNot(beNil()) - client.internal.onError(ARTProtocolMessage()) + client.internal.onError(ProtocolMessage()) partialDone() } else if stateChange.current == .failed { @@ -1431,7 +1431,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__040__Connection__connection_key__should_be_null_until_connected() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -1459,7 +1459,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__041__Connection__connection_key__should_have_unique_connection_keys() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for client in disposable { client.dispose() @@ -1471,7 +1471,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in for _ in 1 ... max { - disposable.append(ARTRealtime(options: options)) + disposable.append(Realtime(options: options)) let currentConnection = disposable.last!.connection currentConnection.on { stateChange in let state = stateChange.current @@ -1503,7 +1503,7 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN11b func test__007__Connection__should_make_a_new_connection_with_a_new_transport_instance_if_the_state_is_CLOSING() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1607,11 +1607,11 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() } client.connect() - var lastStateChange: ARTConnectionStateChange? + var lastStateChange: ConnectionStateChange? client.connection.on { stateChange in lastStateChange = stateChange } @@ -1620,7 +1620,7 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertNil(lastStateChange) expect(lastStateChange).toEventuallyNot(beNil(), timeout: testTimeout) - expect(lastStateChange!.current).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + expect(lastStateChange!.current).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) } // RTN12a @@ -1629,14 +1629,14 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose() } let transport = client.internal.transport as! TestProxyTransport - var states: [ARTRealtimeConnectionState] = [] + var states: [RealtimeConnectionState] = [] waitUntil(timeout: testTimeout) { done in client.connection.on { stateChange in @@ -1663,8 +1663,8 @@ class RealtimeClientConnectionTests: XCTestCase { fail("Invalid number of connection states. Expected CLOSING and CLOSE states") return } - XCTAssertEqual(states[0], ARTRealtimeConnectionState.closing) - XCTAssertEqual(states[1], ARTRealtimeConnectionState.closed) + XCTAssertEqual(states[0], RealtimeConnectionState.closing) + XCTAssertEqual(states[1], RealtimeConnectionState.closed) } // RTN12b @@ -1673,7 +1673,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose() @@ -1683,7 +1683,7 @@ class RealtimeClientConnectionTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport transport.actionsIgnored += [.closed] - var states: [ARTRealtimeConnectionState] = [] + var states: [RealtimeConnectionState] = [] var start: NSDate? var end: NSDate? @@ -1708,15 +1708,15 @@ class RealtimeClientConnectionTests: XCTestCase { } expect(start).toEventuallyNot(beNil(), timeout: testTimeout) - expect(end).toEventuallyNot(beNil(), timeout: DispatchTimeInterval.milliseconds(Int(1000.0 * ARTDefault.realtimeRequestTimeout()))) + expect(end).toEventuallyNot(beNil(), timeout: DispatchTimeInterval.milliseconds(Int(1000.0 * Default.realtimeRequestTimeout()))) if states.count != 2 { fail("Invalid number of connection states. Expected CLOSING and CLOSE states") return } - XCTAssertEqual(states[0], ARTRealtimeConnectionState.closing) - XCTAssertEqual(states[1], ARTRealtimeConnectionState.closed) + XCTAssertEqual(states[0], RealtimeConnectionState.closing) + XCTAssertEqual(states[1], RealtimeConnectionState.closed) } // RTN12c @@ -1725,7 +1725,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose() @@ -1733,7 +1733,7 @@ class RealtimeClientConnectionTests: XCTestCase { } let transport = client.internal.transport as! TestProxyTransport - var states: [ARTRealtimeConnectionState] = [] + var states: [RealtimeConnectionState] = [] waitUntil(timeout: testTimeout) { done in client.connection.on { stateChange in @@ -1763,9 +1763,9 @@ class RealtimeClientConnectionTests: XCTestCase { return } - XCTAssertEqual(states[0], ARTRealtimeConnectionState.connected) - XCTAssertEqual(states[1], ARTRealtimeConnectionState.closing) - XCTAssertEqual(states[2], ARTRealtimeConnectionState.closed) + XCTAssertEqual(states[0], RealtimeConnectionState.connected) + XCTAssertEqual(states[1], RealtimeConnectionState.closing) + XCTAssertEqual(states[2], RealtimeConnectionState.closed) } // RTN12d @@ -1773,21 +1773,21 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.disconnectedRetryTimeout = 1.0 - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() client.dispose() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.internal.onDisconnected() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) client.connection.once { stateChange in - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.closed) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.closed) partialDone() } @@ -1795,7 +1795,7 @@ class RealtimeClientConnectionTests: XCTestCase { delay(options.disconnectedRetryTimeout + 0.5) { // Make sure the retry doesn't happen. - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closed) partialDone() } } @@ -1806,21 +1806,21 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.suspendedRetryTimeout = 1.0 - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() client.dispose() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.internal.onSuspended() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.suspended), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.suspended), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) client.connection.once { stateChange in - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.closed) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.closed) partialDone() } @@ -1828,7 +1828,7 @@ class RealtimeClientConnectionTests: XCTestCase { delay(options.suspendedRetryTimeout + 0.5) { // Make sure the retry doesn't happen. - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closed) partialDone() } } @@ -1842,13 +1842,13 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.suspendedRetryTimeout = 0.1 options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() client.dispose() } - var error: ARTErrorInfo? + var error: ErrorInfo? func ping() { error = nil waitUntil(timeout: testTimeout) { done in @@ -1859,32 +1859,32 @@ class RealtimeClientConnectionTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.initialized) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.initialized) ping() XCTAssertNotNil(error) client.connect() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.internal.onSuspended() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.suspended) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.suspended) ping() XCTAssertNotNil(error) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.close() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closing) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closing) ping() XCTAssertNotNil(error) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) ping() XCTAssertNotNil(error) client.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.failed) ping() XCTAssertNotNil(error) } @@ -1946,7 +1946,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.key = String(options.key!.reversed()) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -1981,7 +1981,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.token = try getTestToken(for: test, key: options.key, ttl: tokenTtl) options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -2036,7 +2036,7 @@ class RealtimeClientConnectionTests: XCTestCase { } options.autoConnect = false - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } var hookToken: AspectToken? @@ -2047,7 +2047,7 @@ class RealtimeClientConnectionTests: XCTestCase { partialDone() } hookToken = realtime.internal.testSuite_getArgument(from: NSSelectorFromString("onError:"), at: 0) { arg0 in - guard let message = arg0 as? ARTProtocolMessage, let error = message.error else { + guard let message = arg0 as? ProtocolMessage, let error = message.error else { fail("Expecting a protocol message with Token error"); partialDone(); return } XCTAssertEqual(error.code, ARTErrorCode.tokenExpired.intValue) @@ -2075,7 +2075,7 @@ class RealtimeClientConnectionTests: XCTestCase { } } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -2115,7 +2115,7 @@ class RealtimeClientConnectionTests: XCTestCase { } } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -2164,7 +2164,7 @@ class RealtimeClientConnectionTests: XCTestCase { let realtimeRequestTimeout = 0.5 options.testOptions.realtimeRequestTimeout = realtimeRequestTimeout - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } var start, end: NSDate? waitUntil(timeout: testTimeout) { done in @@ -2187,8 +2187,8 @@ class RealtimeClientConnectionTests: XCTestCase { func testRTN14dAndRTB1( test: Test, extraTimeNeededToObserveEachRetry: TimeInterval = 0, - modifyOptions: (ARTClientOptions) -> Void, - checkError: (ARTErrorInfo) -> Void + modifyOptions: (ClientOptions) -> Void, + checkError: (ErrorInfo) -> Void ) throws { let options = try AblyTests.commonAppSetup(for: test) options.disconnectedRetryTimeout = 1.0 @@ -2217,11 +2217,11 @@ class RealtimeClientConnectionTests: XCTestCase { let connectionStateTtl = timeNeededToObserveRetries + 1.0 // i.e. make sure that we don't become suspended before we've observed as many retries as we wish to - let previousConnectionStateTtl = ARTDefault.connectionStateTtl() - defer { ARTDefault.setConnectionStateTtl(previousConnectionStateTtl) } - ARTDefault.setConnectionStateTtl(connectionStateTtl) + let previousConnectionStateTtl = Default.connectionStateTtl() + defer { Default.setConnectionStateTtl(previousConnectionStateTtl) } + Default.setConnectionStateTtl(connectionStateTtl) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.shouldImmediatelyReconnect = false defer { client.connection.off() @@ -2230,7 +2230,7 @@ class RealtimeClientConnectionTests: XCTestCase { struct ObservedStateChange { var observedAt: Date - var stateChange: ARTConnectionStateChange + var stateChange: ConnectionStateChange } let retrySequenceDataGatherer = DataGatherer(description: "Observe emitted state changes") { submit in var observedStateChanges: [ObservedStateChange] = [] @@ -2343,7 +2343,7 @@ class RealtimeClientConnectionTests: XCTestCase { // Force a timeout } - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.shouldImmediatelyReconnect = false defer { client.dispose(); client.close() } @@ -2379,7 +2379,7 @@ class RealtimeClientConnectionTests: XCTestCase { let mockJitterCoefficientGenerator = MockJitterCoefficientGenerator(coefficients: jitterCoefficients) options.testOptions.jitterCoefficientGenerator = mockJitterCoefficientGenerator - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.setReachabilityClass(TestReachability.self) defer { client.simulateRestoreInternetConnection(transportFactory: transportFactory) @@ -2399,7 +2399,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connect() } - var events: [ARTRealtimeConnectionState] = [] + var events: [RealtimeConnectionState] = [] client.connection.on { stateChange in events.append(stateChange.current) } @@ -2467,11 +2467,11 @@ class RealtimeClientConnectionTests: XCTestCase { // Force a timeout } - let previousConnectionStateTtl = ARTDefault.connectionStateTtl() - defer { ARTDefault.setConnectionStateTtl(previousConnectionStateTtl) } - ARTDefault.setConnectionStateTtl(expectedTime) + let previousConnectionStateTtl = Default.connectionStateTtl() + defer { Default.setConnectionStateTtl(previousConnectionStateTtl) } + Default.setConnectionStateTtl(expectedTime) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.shouldImmediatelyReconnect = false defer { client.dispose(); client.close() } @@ -2509,7 +2509,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -2542,7 +2542,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedConnectionKey = client.connection.key! client.internal.onDisconnected() @@ -2577,7 +2577,7 @@ class RealtimeClientConnectionTests: XCTestCase { channel.publish(nil, data: "queued message") expect(client.internal.queuedMessages).toEventually(haveCount(1), timeout: testTimeout) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching, "Channel should be still attaching.") + XCTAssertEqual(channel.state, RealtimeChannelState.attaching, "Channel should be still attaching.") waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { stateChange in let transport = client.internal.transport as! TestProxyTransport @@ -2585,7 +2585,7 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertEqual(connectedPM.connectionId, expectedConnectionId) XCTAssertNil(stateChange.reason) XCTAssertEqual((transport.protocolMessagesSent.filter { $0.action == .attach }).count, 1) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching, "Channel should be attaching now.") + XCTAssertEqual(channel.state, RealtimeChannelState.attaching, "Channel should be attaching now.") done() } } @@ -2603,22 +2603,22 @@ class RealtimeClientConnectionTests: XCTestCase { let channel2 = client.channels.get(test.uniqueChannelName(prefix: "second_")) XCTAssertTrue(client.waitUntilConnected()) - expect(channel1.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) - expect(channel2.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel1.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) + expect(channel2.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let expectedConnectionId = client.connection.id let transport = client.internal.transport as! TestProxyTransport XCTAssertEqual((transport.protocolMessagesSent.filter { $0.action == .attach }).count, 2, "Should contain 2 attach messages.") // for channel 1 and 2 channel2.detach() - XCTAssertEqual(channel2.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel2.state, RealtimeChannelState.detaching) client.internal.onDisconnected() channel1.publish(nil, data: "queued message") expect(client.internal.queuedMessages).toEventually(haveCount(1), timeout: testTimeout) - XCTAssertEqual(channel1.state, ARTRealtimeChannelState.attached, "Channel should be still attached.") + XCTAssertEqual(channel1.state, RealtimeChannelState.attached, "Channel should be still attached.") waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { stateChange in let transport = client.internal.transport as! TestProxyTransport @@ -2626,8 +2626,8 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertEqual(connectedPM.connectionId, expectedConnectionId) XCTAssertNil(stateChange.reason) XCTAssertEqual((transport.protocolMessagesSent.filter { $0.action == .attach }).count, 1) - XCTAssertEqual(channel1.state, ARTRealtimeChannelState.attaching, "Channel should be attaching now.") - XCTAssertNotEqual(channel2.state, ARTRealtimeChannelState.attaching, "Channel 2 should not be attaching.") + XCTAssertEqual(channel1.state, RealtimeChannelState.attaching, "Channel should be attaching now.") + XCTAssertNotEqual(channel2.state, RealtimeChannelState.attaching, "Channel 2 should not be attaching.") done() } } @@ -2650,8 +2650,8 @@ class RealtimeClientConnectionTests: XCTestCase { transport.actionsIgnored += [.attached] XCTAssertEqual((transport.protocolMessagesSent.filter { $0.action == .attach }).count, 1) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.suspended), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.suspended), timeout: testTimeout) client.internal.onDisconnected() @@ -2665,11 +2665,11 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertEqual(connectedPM.connectionId, expectedConnectionId) XCTAssertNil(stateChange.reason) XCTAssertEqual((transport.protocolMessagesSent.filter { $0.action == .attach }).count, 1) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching, "Channel should be attaching now.") + XCTAssertEqual(channel.state, RealtimeChannelState.attaching, "Channel should be attaching now.") done() } } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTN15c7 @@ -2741,7 +2741,7 @@ class RealtimeClientConnectionTests: XCTestCase { defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.internal.onDisconnected() @@ -2762,7 +2762,7 @@ class RealtimeClientConnectionTests: XCTestCase { done() } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertTrue(channel.errorReason === protocolError.error) } @@ -2774,7 +2774,7 @@ class RealtimeClientConnectionTests: XCTestCase { defer { client.dispose(); client.close() } let restOptions = try AblyTests.clientOptions(for: test, key: options.key!) restOptions.testOptions.channelNamePrefix = options.testOptions.channelNamePrefix - let rest = ARTRest(options: restOptions) + let rest = Rest(options: restOptions) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -2829,7 +2829,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) - let expectedMessage = ARTMessage(name: "ios", data: "message1") + let expectedMessage = Message(name: "ios", data: "message1") channel.subscribe { message in XCTAssertEqual(message.name, expectedMessage.name) @@ -2850,13 +2850,13 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channel2 = client2.channels.get(channelName) @@ -2874,7 +2874,7 @@ class RealtimeClientConnectionTests: XCTestCase { client1.internal.onDisconnected() - channel2.publish(expectedMessages.map { ARTMessage(name: nil, data: $0) }) { errorInfo in + channel2.publish(expectedMessages.map { Message(name: nil, data: $0) }) { errorInfo in XCTAssertNil(errorInfo) } @@ -2885,7 +2885,7 @@ class RealtimeClientConnectionTests: XCTestCase { } } - expect(client1.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client1.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) expect(receivedMessages).toEventually(equal(expectedMessages), timeout: testTimeout) } @@ -2897,13 +2897,13 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) client.internal.onDisconnected() @@ -2947,7 +2947,7 @@ class RealtimeClientConnectionTests: XCTestCase { fail("TestProxyTransport not setup"); done(); return } - var sentPendingMessage: ARTMessage? + var sentPendingMessage: Message? channel.publish(nil, data: "message") { _ in if resumed { guard let transport2 = client.internal.transport as? TestProxyTransport else { @@ -2978,7 +2978,7 @@ class RealtimeClientConnectionTests: XCTestCase { } client.internal.testSuite_injectIntoMethod(before: Selector(("resendPendingMessagesWithResumed:"))) { XCTAssertEqual(client.internal.pendingMessages.count, 1) - let pm: ARTProtocolMessage? = (client.internal.pendingMessages.firstObject as? ARTPendingMessage)?.msg + let pm: ProtocolMessage? = (client.internal.pendingMessages.firstObject as? ARTPendingMessage)?.msg sentPendingMessage = pm?.messages?[0] } client.internal.testSuite_injectIntoMethod(after: Selector(("resendPendingMessagesWithResumed:"))) { @@ -3043,7 +3043,7 @@ class RealtimeClientConnectionTests: XCTestCase { if let error = error { fail(error.message) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) ttlAndIdleIntervalPassedTestsClient.internal.onDisconnected() } ttlAndIdleIntervalPassedTestsClient.connection.once(.disconnected) { _ in @@ -3102,14 +3102,14 @@ class RealtimeClientConnectionTests: XCTestCase { options.token = try getTestToken(for: test, key: options.key, ttl: tokenTtl) options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() } client.connect() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let firstTransport = client.internal.transport as? TestProxyTransport waitUntil(timeout: testTimeout) { done in @@ -3155,12 +3155,12 @@ class RealtimeClientConnectionTests: XCTestCase { let tokenTtl = 3.0 let tokenDetails = try getTestTokenDetails(for: test, key: key, ttl: tokenTtl) options.token = tokenDetails.token - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in client.connection.once(.failed) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) XCTAssertEqual(stateChange.reason?.code, ARTErrorCode.tokenExpired.intValue) done() } @@ -3183,7 +3183,7 @@ class RealtimeClientConnectionTests: XCTestCase { } options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() @@ -3192,7 +3192,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in // Wait for token to expire client.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) guard let error = stateChange.reason else { fail("Error is nil"); done(); return } @@ -3220,13 +3220,13 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let clientSend = ARTRealtime(options: options) + let clientSend = Realtime(options: options) defer { clientSend.close() } let channelName = test.uniqueChannelName() let channelSend = clientSend.channels.get(channelName) - let clientReceive = ARTRealtime(options: options) + let clientReceive = Realtime(options: options) defer { clientReceive.close() } let channelReceive = clientReceive.channels.get(channelName) @@ -3252,7 +3252,7 @@ class RealtimeClientConnectionTests: XCTestCase { } } - let clientRecover = ARTRealtime(options: options) + let clientRecover = Realtime(options: options) defer { clientRecover.close() } let channelRecover = clientRecover.channels.get(channelName) @@ -3268,10 +3268,10 @@ class RealtimeClientConnectionTests: XCTestCase { func test__082__Connection__Connection_recovery__when_a_connection_is_successfully_recovered__Connection_id_will_be_identical_to_the_id_of_the_connection_that_was_recovered_and_Connection_key_will_always_be_updated_to_the_ConnectionDetails_connectionKey_provided_in_the_first_CONNECTED_ProtocolMessage() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let clientOriginal = ARTRealtime(options: options) + let clientOriginal = Realtime(options: options) defer { clientOriginal.close() } - expect(clientOriginal.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(clientOriginal.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedConnectionId = clientOriginal.connection.id @@ -3297,7 +3297,7 @@ class RealtimeClientConnectionTests: XCTestCase { func skipped__test__083__Connection__Connection_recovery__Connection_recoveryKey_should_become_becomes_null_when_a_connection_is_explicitly_CLOSED_or_CLOSED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in @@ -3492,7 +3492,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { stateChange in expect(client.connection.createRecoveryKey()).notTo(beNil()) - client.internal.onError(ARTProtocolMessage()) + client.internal.onError(ProtocolMessage()) } client.connection.once(.failed) { stateChange in expect(client.connection.createRecoveryKey()).to(beNil()) @@ -3656,7 +3656,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in recoverClient.connection.once(.failed) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) XCTAssertEqual(recoverClient.connection.errorReason?.code, ARTErrorCode.tokenRevoked.intValue) done() } @@ -3688,7 +3688,7 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) recoverClient.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) partialDone() } recoverClient.connection.once(.connected) { stateChange in @@ -3738,7 +3738,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let expectedConnectionId = client.connection.id @@ -3819,10 +3819,10 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17 // RTN17b - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__086__Connection__Host_Fallback__failing_connections_with_custom_endpoint_should_result_in_an_error_immediately() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "test" // do not use the default endpoint XCTAssertFalse(options.fallbackHostsUseDefault) XCTAssertNil(options.fallbackHosts) @@ -3846,8 +3846,8 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connection.once(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.disconnected) guard let reason = stateChange.reason else { fail("Reason is empty"); done(); return } @@ -3870,10 +3870,10 @@ class RealtimeClientConnectionTests: XCTestCase { } // RTN17b - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__087__Connection__Host_Fallback__failing_connections_with_custom_endpoint_should_result_in_time_outs() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "test" // do not use the default endpoint options.testOptions.realtimeRequestTimeout = 1.0 XCTAssertFalse(options.fallbackHostsUseDefault) @@ -3897,8 +3897,8 @@ class RealtimeClientConnectionTests: XCTestCase { waitUntil(timeout: testTimeout) { done in client.connection.on(.disconnected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.disconnected) guard let reason = stateChange.reason else { fail("Reason is empty"); done(); return } @@ -3914,12 +3914,12 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17b func test__088__Connection__Host_Fallback__applies_when_the_default_realtime_ably_io_endpoint_is_being_used() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -3958,13 +3958,13 @@ class RealtimeClientConnectionTests: XCTestCase { func test__089__Connection__Host_Fallback__applies_when_an_array_of_ClientOptions_fallbackHosts_is_provided() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.fallbackHosts = ["f.ably-realtime.com", "g.ably-realtime.com", "h.ably-realtime.com", "i.ably-realtime.com", "j.ably-realtime.com"] options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -4033,18 +4033,18 @@ class RealtimeClientConnectionTests: XCTestCase { } func test__090__Connection__Host_Fallback__should_not_use_an_alternative_host_when_the_client_receives_a_bad_request() throws { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.disconnectedRetryTimeout = 1.0 // so that the test doesn't have to wait a long time to observe a retry options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) transportFactory.fakeNetworkResponse = .host400BadRequest let dataGatherer = DataGatherer(description: "Observe emitted state changes and transport connection attempts") { submit in - var stateChanges: [ARTConnectionStateChange] = [] + var stateChanges: [ConnectionStateChange] = [] var urlConnections = [URL]() client.connection.on { stateChange in @@ -4077,12 +4077,12 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17a func test__091__Connection__Host_Fallback__every_connection_is_first_attempted_to_the_primary_host_realtime_ably_io() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -4131,13 +4131,13 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17c func test__092__Connection__Host_Fallback__should_retry_hosts_in_random_order_after_checkin_if_an_internet_connection_is_available() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.testOptions.realtimeRequestTimeout = 5.0 options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -4153,7 +4153,7 @@ class RealtimeClientConnectionTests: XCTestCase { } var urls = [URL]() - let expectedFallbackHosts = Array(expectedHostOrder.map { ARTDefault.fallbackHosts()[$0] }) + let expectedFallbackHosts = Array(expectedHostOrder.map { Default.fallbackHosts()[$0] }) let allFallbackHostsTriedOfFailedExp = XCTestExpectation(description: "TestProxyTransport should spit 5 fallback hosts on networkConnectEvent") transportFactory.networkConnectEvent = { transport, url in @@ -4207,12 +4207,12 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17c func test__093__Connection__Host_Fallback__doesn_t_try_fallback_host_if_Internet_connection_check_fails() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.testOptions.realtimeRequestTimeout = 1.0 let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -4256,14 +4256,14 @@ class RealtimeClientConnectionTests: XCTestCase { let hostPrefixes = Array("fghij") let expectedFallbackHosts = Array(expectedHostOrder.map { "\(hostPrefixes[$0]).ably-realtime.com" }) - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.fallbackHosts = expectedFallbackHosts.sorted() // will be picked "randomly" as of expectedHostOrder options.testOptions.realtimeRequestTimeout = 5.0 options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.channels.get(test.uniqueChannelName()) @@ -4329,12 +4329,12 @@ class RealtimeClientConnectionTests: XCTestCase { func test__095__Connection__Host_Fallback__won_t_use_fallback_hosts_feature_if_an_empty_array_is_provided() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false options.fallbackHosts = [] let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) let testHttpExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) @@ -4364,11 +4364,11 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN17e func test__096__Connection__Host_Fallback__client_is_connected_to_a_fallback_host_endpoint_should_do_HTTP_requests_to_the_same_data_centre() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.autoConnect = false let transportFactory = TestProxyTransportFactory() options.testOptions.transportFactory = transportFactory - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let testHttpExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.rest.httpExecutor = testHttpExecutor @@ -4614,7 +4614,7 @@ class RealtimeClientConnectionTests: XCTestCase { let client = AblyTests.newRealtime(options).client defer { client.dispose(); client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not setup"); return @@ -4636,7 +4636,7 @@ class RealtimeClientConnectionTests: XCTestCase { expect(transport).toNot(beIdenticalTo(newTransport)) done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) transport.ignoreSends = false AblyTests.queue.async { client.internal.onDisconnected() @@ -4653,7 +4653,7 @@ class RealtimeClientConnectionTests: XCTestCase { let channel = client.channels.get(test.uniqueChannelName()) let transport = client.internal.transport as! TestProxyTransport - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.attach { _ in done() } @@ -4673,7 +4673,7 @@ class RealtimeClientConnectionTests: XCTestCase { XCTAssertEqual(newTransport.protocolMessagesSent.filter { $0.action == .detach }.count, 1) done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detaching) + XCTAssertEqual(channel.state, RealtimeChannelState.detaching) transport.ignoreSends = false client.internal.onDisconnected() } @@ -4686,7 +4686,7 @@ class RealtimeClientConnectionTests: XCTestCase { func beforeEach__Connection__Operating_System_events_for_network_internet_connectivity_changes__should_immediately_change_the_state_to_DISCONNECTED_if_the_operating_system_indicates_that_the_underlying_internet_connection_is_no_longer_available(for test: Test) throws { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - internetConnectionNotAvailableTestsClient = ARTRealtime(options: options) + internetConnectionNotAvailableTestsClient = Realtime(options: options) internetConnectionNotAvailableTestsClient.internal.setReachabilityClass(TestReachability.self) } @@ -4762,13 +4762,13 @@ class RealtimeClientConnectionTests: XCTestCase { // RTN20b func test__106__Connection__Operating_System_events_for_network_internet_connectivity_changes__should_immediately_attempt_to_connect_if_the_operating_system_indicates_that_the_underlying_internet_connection_is_now_available_when_DISCONNECTED_or_SUSPENDED() throws { let test = Test() - var client: ARTRealtime! + var client: Realtime! let options = try AblyTests.commonAppSetup(for: test) // Ensure it won't reconnect because of timeouts. options.disconnectedRetryTimeout = testTimeout.incremented(by: 10).toTimeInterval() options.suspendedRetryTimeout = testTimeout.incremented(by: 10).toTimeInterval() options.autoConnect = false - client = ARTRealtime(options: options) + client = Realtime(options: options) client.internal.setReachabilityClass(TestReachability.self) defer { client.dispose(); client.close() } @@ -4806,7 +4806,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.realtimeHost = "10.255.255.1" // non-routable IP address options.autoConnect = false options.testOptions.reconnectionRealtimeHost = realtimeHost - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.internal.setReachabilityClass(TestReachability.self) defer { client.dispose(); client.close() } @@ -4825,11 +4825,11 @@ class RealtimeClientConnectionTests: XCTestCase { // a) address is non-routable // b) it will be called by the system once reachability callback is set (during transition to CONNECTING) reachability.simulate(false) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.disconnected) client.connect() - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) reachability.simulate(true) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) } client.connection.once(.connected) { stateChange in XCTAssertEqual(reconnectMethodCallCount, 1) @@ -4842,7 +4842,7 @@ class RealtimeClientConnectionTests: XCTestCase { let options2 = try AblyTests.commonAppSetup(for: test) options2.autoConnect = false - let client2 = ARTRealtime(options: options2) + let client2 = Realtime(options: options2) client2.internal.setReachabilityClass(TestReachability.self) defer { client2.dispose(); client2.close() } @@ -4858,7 +4858,7 @@ class RealtimeClientConnectionTests: XCTestCase { XCTFail("expected test reachability"); return } reachability.simulate(true) - XCTAssertEqual(client2.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client2.connection.state, RealtimeConnectionState.connecting) } client2.connection.once(.connected) { stateChange in XCTAssertEqual(reconnectMethodCallCount, 0) @@ -4875,7 +4875,7 @@ class RealtimeClientConnectionTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -4908,7 +4908,7 @@ class RealtimeClientConnectionTests: XCTestCase { done() } - let authMessage = ARTProtocolMessage() + let authMessage = ProtocolMessage() authMessage.action = .auth client.internal.transport?.receive(authMessage) } @@ -4931,11 +4931,11 @@ class RealtimeClientConnectionTests: XCTestCase { let restOptions = try AblyTests.clientOptions(for: test, key: options.key!) restOptions.testOptions.channelNamePrefix = options.testOptions.channelNamePrefix - let rest = ARTRest(options: restOptions) + let rest = Rest(options: restOptions) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) - let expectedMessage = ARTMessage(name: "ios", data: "message1") + let expectedMessage = Message(name: "ios", data: "message1") channel.subscribe { message in XCTAssertEqual(message.name, expectedMessage.name) @@ -4957,7 +4957,7 @@ class RealtimeClientConnectionTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, key: options.key!, ttl: 5.0) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -5011,11 +5011,11 @@ class RealtimeClientConnectionTests: XCTestCase { let restOptions = try AblyTests.clientOptions(for: test, key: options.key!) restOptions.testOptions.channelNamePrefix = options.testOptions.channelNamePrefix - let rest = ARTRest(options: restOptions) + let rest = Rest(options: restOptions) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) - let expectedMessage = ARTMessage(name: "ios", data: "message1") + let expectedMessage = Message(name: "ios", data: "message1") channel.subscribe { message in XCTAssertEqual(message.name, expectedMessage.name) @@ -5067,7 +5067,7 @@ class RealtimeClientConnectionTests: XCTestCase { client.connection.on(.disconnected) { stateChange in let now = Date() - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) guard let noActivityHasStartedAt = noActivityHasStartedAt else { fail("No activity date is missing"); partialDone(); return @@ -5100,7 +5100,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__012__Connection__the_client_may_receive_a_CONNECTED_ProtocolMessage_from_Ably_at_any_point_and_should_emit_an_UPDATE_event() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -5111,16 +5111,16 @@ class RealtimeClientConnectionTests: XCTestCase { } waitUntil(timeout: testTimeout) { done in - let authMessage = ARTProtocolMessage() - authMessage.action = ARTProtocolMessageAction.connected - authMessage.error = ARTErrorInfo.create(withCode: 1234, message: "fabricated error") + let authMessage = ProtocolMessage() + authMessage.action = ProtocolMessageAction.connected + authMessage.error = ErrorInfo.create(withCode: 1234, message: "fabricated error") let listener = client.connection.once(.connected) { _ in fail("shouldn't emit CONNECTED") } client.connection.once(.update) { stateChange in - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.connected) XCTAssertEqual(stateChange.current, stateChange.previous) XCTAssertTrue(stateChange.reason === authMessage.error) delay(0.5) { // Give some time for the other listener to be triggered. @@ -5166,14 +5166,14 @@ class RealtimeClientConnectionTests: XCTestCase { } XCTAssertEqual(error.code, 1234) XCTAssertEqual(client.connection.errorReason?.code, 1234) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) - XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) + XCTAssertEqual(stateChange.current, RealtimeConnectionState.connected) XCTAssertEqual(stateChange.current, stateChange.previous) done() } let connectedMessageWithError = originalConnectedMessage - connectedMessageWithError.error = ARTErrorInfo.create(withCode: 1234, message: "fabricated error") + connectedMessageWithError.error = ErrorInfo.create(withCode: 1234, message: "fabricated error") client.internal.transport?.receive(connectedMessageWithError) } } @@ -5182,20 +5182,20 @@ class RealtimeClientConnectionTests: XCTestCase { func test__014__Connection__should_not_move_to_FAILED_if_received_DISCONNECT_with_an_error() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose() client.close() } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) - let protoMsg = ARTProtocolMessage() + let protoMsg = ProtocolMessage() protoMsg.action = .disconnect - protoMsg.error = ARTErrorInfo.create(withCode: 123, message: "test error") + protoMsg.error = ErrorInfo.create(withCode: 123, message: "test error") client.internal.transport?.receive(protoMsg) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.disconnected) XCTAssertEqual(client.connection.errorReason, protoMsg.error) } @@ -5209,7 +5209,7 @@ class RealtimeClientConnectionTests: XCTestCase { let channel = client.channels.get(test.uniqueChannelName()) channel.attach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) if channel.state != .attached { return } @@ -5217,7 +5217,7 @@ class RealtimeClientConnectionTests: XCTestCase { let messages = fixtures["messages"] as! [[String: Any]] for fixtureMessage in messages { - var receivedMessage: ARTMessage? + var receivedMessage: Message? waitUntil(timeout: testTimeout) { done in channel.subscribe { message in @@ -5277,7 +5277,7 @@ class RealtimeClientConnectionTests: XCTestCase { func skipped__test__112__Connection__with_fixture_messages__should_send_messages_through_raw_JSON_POST_and_retrieve_equal_messages_through_MsgPack_and_JSON() throws { let test = Test() try setupDependencies(for: test) - let restPublishClient = ARTRest(options: jsonOptions) + let restPublishClient = Rest(options: jsonOptions) let realtimeSubscribeClientMsgPack = AblyTests.newRealtime(msgpackOptions).client let realtimeSubscribeClientJSON = AblyTests.newRealtime(jsonOptions).client defer { @@ -5331,9 +5331,9 @@ class RealtimeClientConnectionTests: XCTestCase { func skipped__test__113__Connection__with_fixture_messages__should_send_messages_through_MsgPack_and_JSON_and_retrieve_equal_messages_through_raw_JSON_GET() throws { let test = Test() try setupDependencies(for: test) - let restPublishClientMsgPack = ARTRest(options: msgpackOptions) - let restPublishClientJSON = ARTRest(options: jsonOptions) - let restRetrieveClient = ARTRest(options: jsonOptions) + let restPublishClientMsgPack = Rest(options: msgpackOptions) + let restPublishClientJSON = Rest(options: jsonOptions) + let restRetrieveClient = Rest(options: jsonOptions) let restPublishChannelMsgPack = restPublishClientMsgPack.channels.get(test.uniqueChannelName()) let restPublishChannelJSON = restPublishClientJSON.channels.get(restPublishChannelMsgPack.name) @@ -5385,7 +5385,7 @@ class RealtimeClientConnectionTests: XCTestCase { func test__015__Connection__should_abort_reconnection_with_new_token_if_the_server_has_requested_it_to_authorize_and_after_it_the_connection_has_been_closed() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -5408,7 +5408,7 @@ class RealtimeClientConnectionTests: XCTestCase { } } - let authMessage = ARTProtocolMessage() + let authMessage = ProtocolMessage() authMessage.action = .auth client.internal.transport?.receive(authMessage) diff --git a/Test/Tests/RealtimeClientPresenceTests.swift b/Test/Tests/RealtimeClientPresenceTests.swift index bbca9b79a..2aca33337 100644 --- a/Test/Tests/RealtimeClientPresenceTests.swift +++ b/Test/Tests/RealtimeClientPresenceTests.swift @@ -4,8 +4,8 @@ import Nimble import XCTest // RTP16c -private func testResultsInErrorWithConnectionState(_ connectionState: ARTRealtimeConnectionState, for test: Test, channelName: String, performMethod: @escaping (ARTRealtime) -> Void) throws { - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) +private func testResultsInErrorWithConnectionState(_ connectionState: RealtimeConnectionState, for test: Test, channelName: String, performMethod: @escaping (Realtime) -> Void) throws { + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) XCTAssertTrue(client.internal.options.queueMessages) @@ -29,10 +29,10 @@ private func testResultsInErrorWithConnectionState(_ connectionState: ARTRealtim } } -private func getSuspendedChannel(named: String, for test: Test) throws -> (ARTRealtimeChannel, ARTRealtime) { +private func getSuspendedChannel(named: String, for test: Test) throws -> (RealtimeChannel, Realtime) { let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(named) waitUntil(timeout: testTimeout) { done in @@ -45,7 +45,7 @@ private func getSuspendedChannel(named: String, for test: Test) throws -> (ARTRe return (channel, client) } -private func testSuspendedStateResultsInError(for test: Test, channelName: String, _ getPresence: (ARTRealtimeChannel, @escaping ([ARTPresenceMessage]?, ARTErrorInfo?) -> Void) -> Void) throws { +private func testSuspendedStateResultsInError(for test: Test, channelName: String, _ getPresence: (RealtimeChannel, @escaping ([PresenceMessage]?, ErrorInfo?) -> Void) -> Void) throws { let (channel, client) = try getSuspendedChannel(named: channelName, for: test) defer { client.dispose(); client.close() } @@ -59,8 +59,8 @@ private func testSuspendedStateResultsInError(for test: Test, channelName: Strin } } -private let getParams: ARTRealtimePresenceQuery = { - let getParams = ARTRealtimePresenceQuery() +private let getParams: RealtimePresenceQuery = { + let getParams = RealtimePresenceQuery() getParams.waitForSync = false return getParams }() @@ -72,7 +72,7 @@ private let getParams: ARTRealtimePresenceQuery = { // // The client must have been set up to use TestProxyTransport (e.g. using // AblyTests.newRealtime(:)). -private func attachAndWaitForInitialPresenceSyncToComplete(client: ARTRealtime, channel: ARTRealtimeChannel) { +private func attachAndWaitForInitialPresenceSyncToComplete(client: Realtime, channel: RealtimeChannel) { waitUntil(timeout: testTimeout) { done in channel.attach { error in XCTAssertNil(error) @@ -109,7 +109,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -122,14 +122,14 @@ class RealtimeClientPresenceTests: XCTestCase { options.autoConnect = false options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) client.connect() defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) channel.attach() XCTAssertFalse(channel.presence.syncComplete) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport let attached = transport.protocolMessagesReceived.filter { $0.action == .attached }[0] @@ -185,25 +185,25 @@ class RealtimeClientPresenceTests: XCTestCase { } // Inject a SYNC Presence message (first page) - let sync1Message = ARTProtocolMessage() + let sync1Message = ProtocolMessage() sync1Message.action = .sync sync1Message.channel = channel.name sync1Message.channelSerial = "sequenceid:cursor" sync1Message.timestamp = Date() sync1Message.presence = [ - ARTPresenceMessage(clientId: "a", action: .present, connectionId: "another", id: "another:0:0"), - ARTPresenceMessage(clientId: "b", action: .present, connectionId: "another", id: "another:0:1"), + PresenceMessage(clientId: "a", action: .present, connectionId: "another", id: "another:0:0"), + PresenceMessage(clientId: "b", action: .present, connectionId: "another", id: "another:0:1"), ] transport.receive(sync1Message) // Inject a SYNC Presence message (last page) - let sync2Message = ARTProtocolMessage() + let sync2Message = ProtocolMessage() sync2Message.action = .sync sync2Message.channel = channel.name sync2Message.channelSerial = "sequenceid:" // indicates SYNC is complete sync2Message.timestamp = Date() sync2Message.presence = [ - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "another", id: "another:1:0"), + PresenceMessage(clientId: "a", action: .leave, connectionId: "another", id: "another:1:0"), ] delay(0.5) { transport.receive(sync2Message) @@ -256,14 +256,14 @@ class RealtimeClientPresenceTests: XCTestCase { } // Inject a SYNC Presence message (entirely contained) - let syncMessage = ARTProtocolMessage() + let syncMessage = ProtocolMessage() syncMessage.action = .sync syncMessage.channel = channel.name syncMessage.timestamp = Date() syncMessage.presence = [ - ARTPresenceMessage(clientId: "a", action: .present, connectionId: "another", id: "another:0:0"), - ARTPresenceMessage(clientId: "b", action: .present, connectionId: "another", id: "another:0:1"), - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "another", id: "another:1:0"), + PresenceMessage(clientId: "a", action: .present, connectionId: "another", id: "another:0:0"), + PresenceMessage(clientId: "b", action: .present, connectionId: "another", id: "another:0:1"), + PresenceMessage(clientId: "a", action: .leave, connectionId: "another", id: "another:1:0"), ] transport.receive(syncMessage) } @@ -287,7 +287,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 2, options: options) @@ -308,7 +308,7 @@ class RealtimeClientPresenceTests: XCTestCase { XCTAssertEqual(channel.internal.presence.members.count, 2) // Inject a internal member - let internalMember = ARTPresenceMessage(clientId: "internal-member", action: .enter, connectionId: channel.internal.connectionId, id: "\(channel.internal.connectionId):0:0") + let internalMember = PresenceMessage(clientId: "internal-member", action: .enter, connectionId: channel.internal.connectionId, id: "\(channel.internal.connectionId):0:0") channel.internal.presence.processMember(internalMember) XCTAssertEqual(channel.internal.presence.members.count, 3) XCTAssertEqual(channel.internal.presence.internalMembers.count, 1) @@ -352,8 +352,8 @@ class RealtimeClientPresenceTests: XCTestCase { let channel = client.channels.get(channelName) // Inject local members - channel.internal.presence.processMember(ARTPresenceMessage(clientId: "tester1", action: .enter, connectionId: "another", id: "another:0:0")) - channel.internal.presence.processMember(ARTPresenceMessage(clientId: "tester2", action: .enter, connectionId: "another", id: "another:0:1")) + channel.internal.presence.processMember(PresenceMessage(clientId: "tester1", action: .enter, connectionId: "another", id: "another:0:0")) + channel.internal.presence.processMember(PresenceMessage(clientId: "tester2", action: .enter, connectionId: "another", id: "another:0:1")) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not set"); return @@ -374,7 +374,7 @@ class RealtimeClientPresenceTests: XCTestCase { } else { XCTFail("Expected leave.clientId to be non-nil") } - XCTAssertEqual(leave.action, ARTPresenceAction.leave) + XCTAssertEqual(leave.action, PresenceAction.leave) expect(leave.timestamp).to(beCloseTo(Date(), within: 0.5)) XCTAssertNil(leave.id) partialDone() // 2 times @@ -399,20 +399,20 @@ class RealtimeClientPresenceTests: XCTestCase { func test__002__Presence__should_receive_all_250_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var clientSource: ARTRealtime! + var clientSource: Realtime! defer { clientSource.dispose(); clientSource.close() } let channelName = test.uniqueChannelName() clientSource = AblyTests.addMembersSequentiallyToChannel(channelName, members: 250, options: options) - let clientTarget = ARTRealtime(options: options) + let clientTarget = Realtime(options: options) defer { clientTarget.dispose(); clientTarget.close() } let channel = clientTarget.channels.get(channelName) waitUntil(timeout: testTimeout) { done in var pending = 250 channel.presence.subscribe { member in - XCTAssertEqual(member.action, ARTPresenceAction.present) + XCTAssertEqual(member.action, PresenceAction.present) pending -= 1 if pending == 0 { done() @@ -451,11 +451,11 @@ class RealtimeClientPresenceTests: XCTestCase { // to complete before publishing any presence actions. attachAndWaitForInitialPresenceSyncToComplete(client: client1, channel: channel1) - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channel2 = client2.channels.get(channelName) - var receivedMembers = [ARTPresenceMessage]() + var receivedMembers = [PresenceMessage]() channel1.presence.subscribe { member in receivedMembers.append(member) } @@ -475,15 +475,15 @@ class RealtimeClientPresenceTests: XCTestCase { return } - XCTAssertEqual(receivedMembers[0].action, ARTPresenceAction.enter) + XCTAssertEqual(receivedMembers[0].action, PresenceAction.enter) XCTAssertEqual(receivedMembers[0].data as? NSObject, "online" as NSObject?) XCTAssertEqual(receivedMembers[0].clientId, "john") - XCTAssertEqual(receivedMembers[1].action, ARTPresenceAction.update) + XCTAssertEqual(receivedMembers[1].action, PresenceAction.update) XCTAssertEqual(receivedMembers[1].data as? NSObject, "away" as NSObject?) XCTAssertEqual(receivedMembers[1].clientId, "john") - XCTAssertEqual(receivedMembers[2].action, ARTPresenceAction.leave) + XCTAssertEqual(receivedMembers[2].action, PresenceAction.leave) XCTAssertEqual(receivedMembers[2].data as? NSObject, "away" as NSObject?) XCTAssertEqual(receivedMembers[2].clientId, "john") } @@ -493,7 +493,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP7a func test__016__Presence__unsubscribe__with_no_arguments_unsubscribes_the_listener_if_previously_subscribed_with_an_action_specific_subscription() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -509,7 +509,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__018__Presence__Channel_state_change_side_effects__if_the_channel_enters_the_FAILED_state__all_queued_presence_messages_should_fail_immediately() throws{ let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -529,7 +529,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__019__Presence__Channel_state_change_side_effects__if_the_channel_enters_the_FAILED_state__should_clear_the_PresenceMap_including_local_members_and_does_not_emit_any_presence_events() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -569,14 +569,14 @@ class RealtimeClientPresenceTests: XCTestCase { func test__020__Presence__Channel_state_change_side_effects__if_the_channel_enters_the_DETACHED_state__all_queued_presence_messages_should_fail_immediately() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.once(.attaching) { _ in AblyTests.queue.async { - channel.internal.detachChannel(ChannelStateChangeParams(state: .error, errorInfo: ARTErrorInfo.create(withCode: 0, message: "Fail test"))) + channel.internal.detachChannel(ChannelStateChangeParams(state: .error, errorInfo: ErrorInfo.create(withCode: 0, message: "Fail test"))) } } channel.presence.enterClient("user", data: nil) { error in @@ -590,7 +590,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__021__Presence__Channel_state_change_side_effects__if_the_channel_enters_the_DETACHED_state__should_clear_the_PresenceMap_including_local_members_and_does_not_emit_any_presence_events() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -650,7 +650,7 @@ class RealtimeClientPresenceTests: XCTestCase { channel2.presence.enterClient("Client 2", data: nil) { error in XCTAssertNil(error) XCTAssertEqual(client2.internal.queuedMessages.count, 0) - XCTAssertEqual(channel2.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel2.state, RealtimeChannelState.attached) partialDone() } channel2.presence.subscribe(.enter) { _ in @@ -688,7 +688,7 @@ class RealtimeClientPresenceTests: XCTestCase { XCTAssertNil(stateChange.reason) XCTAssertEqual(channel.presence.internal.pendingPresence.count, 1) channel.internalAsync { _internal in - _internal.setSuspended(.init(state: .error, errorInfo: ARTErrorInfo.create(withCode: 1234, message: "unknown error"))) + _internal.setSuspended(.init(state: .error, errorInfo: ErrorInfo.create(withCode: 1234, message: "unknown error"))) } partialDone() } @@ -745,11 +745,11 @@ class RealtimeClientPresenceTests: XCTestCase { let partialDone = AblyTests.splitDone(4, done: done) mainChannel.presence.subscribe { message in if message.clientId == "main" { - XCTAssertTrue(message.action == ARTPresenceAction.enter || message.action == ARTPresenceAction.present) + XCTAssertTrue(message.action == PresenceAction.enter || message.action == PresenceAction.present) partialDone() } else if message.clientId == "leaves" { - XCTAssertTrue(message.action == ARTPresenceAction.enter || message.action == ARTPresenceAction.present) + XCTAssertTrue(message.action == PresenceAction.enter || message.action == PresenceAction.present) partialDone() } } @@ -778,7 +778,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - var presenceEvents = [ARTPresenceMessage]() + var presenceEvents = [PresenceMessage]() waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(4, done: done) @@ -808,7 +808,7 @@ class RealtimeClientPresenceTests: XCTestCase { mainClient.simulateNoInternetConnection() } XCTAssertEqual(presenceEvents.count, 1) - XCTAssertEqual(presenceEvents[0].action, ARTPresenceAction.leave) + XCTAssertEqual(presenceEvents[0].action, PresenceAction.leave) XCTAssertEqual(presenceEvents[0].clientId, "leaves") mainChannel.presence.unsubscribe() @@ -828,7 +828,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Members is nil"); done(); return } XCTAssertEqual(members.count, 3) // "main", "user1", "user2" - expect(members).to(allPass { (member: ARTPresenceMessage?) in member!.action != .absent }) + expect(members).to(allPass { (member: PresenceMessage?) in member!.action != .absent }) done() } } @@ -847,13 +847,13 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.dispose(); client1.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.dispose(); client2.close() } let channel2 = client2.channels.get(channelName) @@ -875,7 +875,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP7b func test__025__Presence__unsubscribe__with_a_single_action_argument_unsubscribes_the_provided_listener_to_all_presence_messages_for_that_action() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -890,32 +890,32 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP6c func test__026__Presence__subscribe__should_implicitly_attach_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.presence.subscribe { _ in } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) channel.detach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) channel.presence.subscribe(.present) { _ in } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTP6c func test__027__Presence__subscribe__should_result_in_an_error_if_the_channel_is_in_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.internal.onError(AblyTests.newErrorProtocolMessage()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) waitUntil(timeout: testTimeout) { done in channel.presence.subscribe(attachCallback: { errorInfo in @@ -932,7 +932,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP6c func test__028__Presence__subscribe__should_result_in_an_error_if_the_channel_moves_to_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -959,19 +959,19 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channel2 = client2.channels.get(channelName) var count = 0 channel1.presence.subscribe(.update) { member in - XCTAssertEqual(member.action, ARTPresenceAction.update) + XCTAssertEqual(member.action, PresenceAction.update) XCTAssertEqual(member.clientId, "john") XCTAssertEqual(member.data as? NSObject, "away" as NSObject?) count += 1 @@ -1001,13 +1001,13 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.dispose(); client1.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.dispose(); client2.close() } let channel2 = client2.channels.get(channelName) @@ -1029,8 +1029,8 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" let channelName = test.uniqueChannelName() - let client1 = ARTRealtime(options: options) - let client2 = ARTRealtime(options: options) + let client1 = Realtime(options: options) + let client2 = Realtime(options: options) let channel1 = client1.channels.get(channelName) let channel2 = client2.channels.get(channelName) @@ -1085,11 +1085,11 @@ class RealtimeClientPresenceTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let sent = transport.protocolMessagesSent.filter { $0.action == .presence }[0].presence![0] - XCTAssertEqual(sent.action, ARTPresenceAction.enter) + XCTAssertEqual(sent.action, PresenceAction.enter) XCTAssertNil(sent.clientId) let received = transport.protocolMessagesReceived.filter { $0.action == .presence }[0].presence![0] - XCTAssertEqual(received.action, ARTPresenceAction.enter) + XCTAssertEqual(received.action, PresenceAction.enter) XCTAssertEqual(received.clientId, "john") } @@ -1098,15 +1098,15 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP8j (former RTP8f) func test__033__Presence__enter__should_result_in_an_error_immediately_if_the_connection_state_is_connected_and_the_client_is_anonymous() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected)) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected)) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in - XCTAssertEqual(error?.code, Int(ARTState.noClientId.rawValue)) + XCTAssertEqual(error?.code, Int(State.noClientId.rawValue)) done() } } @@ -1116,16 +1116,16 @@ class RealtimeClientPresenceTests: XCTestCase { func test__033__Presence__enter__should_result_in_an_error_immediately_if_the_connection_state_is_connected_and_the_client_is_wildcard() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) options.clientId = "*" defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected)) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected)) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in - XCTAssertEqual(error?.code, Int(ARTState.noClientId.rawValue)) + XCTAssertEqual(error?.code, Int(State.noClientId.rawValue)) done() } } @@ -1136,7 +1136,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1146,7 +1146,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -1161,7 +1161,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1172,7 +1172,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) waitUntil(timeout: testTimeout) { done in channel.presence.enter(nil) { error in @@ -1185,7 +1185,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP8i func test__036__Presence__enter__should_result_in_an_error_if_Ably_service_determines_that_the_client_is_unidentified() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1236,7 +1236,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1264,7 +1264,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1286,7 +1286,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1342,13 +1342,13 @@ class RealtimeClientPresenceTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let sent = transport.protocolMessagesSent.filter { $0.action == .presence }[1].presence![0] - XCTAssertEqual(sent.action, ARTPresenceAction.update) + XCTAssertEqual(sent.action, PresenceAction.update) XCTAssertNil(sent.clientId) let receivedPresenceProtocolMessages = transport.protocolMessagesReceived.filter { $0.action == .presence } let receivedPresenceMessages = receivedPresenceProtocolMessages.flatMap { $0.presence! } let received = receivedPresenceMessages.filter { $0.action == .update }[0] - XCTAssertEqual(received.action, ARTPresenceAction.update) + XCTAssertEqual(received.action, PresenceAction.update) XCTAssertEqual(received.clientId, "john") } @@ -1359,7 +1359,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1389,7 +1389,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1414,7 +1414,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__003__Presence__should_be_used_a_PresenceMap_to_maintain_a_list_of_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var clientSecondary: ARTRealtime! + var clientSecondary: Realtime! defer { clientSecondary.dispose(); clientSecondary.close() } let channelName = test.uniqueChannelName() @@ -1450,7 +1450,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__045__Presence__PresenceMap__all_incoming_presence_messages_must_be_compared_for_newness_with_the_matching_member_already_in_the_PresenceMap() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -1507,7 +1507,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -1515,13 +1515,13 @@ class RealtimeClientPresenceTests: XCTestCase { defer { clientSubscribed.dispose(); clientSubscribed.close() } let channelSubscribed = clientSubscribed.channels.get(channelName) - let presenceData: [ARTPresenceMessage] = [ - ARTPresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), - ARTPresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), - ARTPresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), - ARTPresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), - ARTPresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), + let presenceData: [PresenceMessage] = [ + PresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), + PresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), + PresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), + PresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), + PresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), + PresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), ] guard let transport = clientSubscribed.internal.transport as? TestProxyTransport else { @@ -1533,7 +1533,7 @@ class RealtimeClientPresenceTests: XCTestCase { // Receive the first Sync message from Ably service if protocolMessage.action == .sync { // Inject a fabricated Presence message - let presenceMessage = ARTProtocolMessage() + let presenceMessage = ProtocolMessage() presenceMessage.action = .presence presenceMessage.channel = protocolMessage.channel presenceMessage.timestamp = Date() @@ -1542,7 +1542,7 @@ class RealtimeClientPresenceTests: XCTestCase { transport.receive(presenceMessage) // Simulate an end to the sync - let endSyncMessage = ARTProtocolMessage() + let endSyncMessage = ProtocolMessage() endSyncMessage.action = .sync endSyncMessage.channel = protocolMessage.channel endSyncMessage.channelSerial = "validserialprefix:" // with no part after the `:` this indicates the end to the SYNC @@ -1568,7 +1568,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Members is nil"); done(); return } XCTAssertEqual(members.count, 102) // 100 initial members + "b" + "c", client "a" is discarded - expect(members).to(allPass { (member: ARTPresenceMessage?) in member!.action != .absent }) + expect(members).to(allPass { (member: PresenceMessage?) in member!.action != .absent }) expect(members.filter { $0.clientId == "a" }).to(beEmpty()) XCTAssertEqual(members.filter { $0.clientId == "b" }.count, 1) XCTAssertEqual(members.filter { $0.clientId! == "b" }.first?.timestamp, now as Date) @@ -1585,7 +1585,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -1593,13 +1593,13 @@ class RealtimeClientPresenceTests: XCTestCase { defer { clientSubscribed.dispose(); clientSubscribed.close() } let channelSubscribed = clientSubscribed.channels.get(channelName) - let presenceData: [ARTPresenceMessage] = [ - ARTPresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "one:1:0", timestamp: (now as Date) - 1), - ARTPresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:2:2", timestamp: now as Date), - ARTPresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "one:2:1", timestamp: (now as Date) + 1), - ARTPresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "one:4:4", timestamp: now as Date), - ARTPresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "one:3:5", timestamp: (now as Date) + 1), + let presenceData: [PresenceMessage] = [ + PresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), + PresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "one:1:0", timestamp: (now as Date) - 1), + PresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:2:2", timestamp: now as Date), + PresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "one:2:1", timestamp: (now as Date) + 1), + PresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "one:4:4", timestamp: now as Date), + PresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "one:3:5", timestamp: (now as Date) + 1), ] guard let transport = clientSubscribed.internal.transport as? TestProxyTransport else { @@ -1611,7 +1611,7 @@ class RealtimeClientPresenceTests: XCTestCase { // Receive the first Sync message from Ably service if protocolMessage.action == .sync { // Inject a fabricated Presence message - let presenceMessage = ARTProtocolMessage() + let presenceMessage = ProtocolMessage() presenceMessage.action = .presence presenceMessage.channel = protocolMessage.channel presenceMessage.timestamp = Date() @@ -1620,7 +1620,7 @@ class RealtimeClientPresenceTests: XCTestCase { transport.receive(presenceMessage) // Simulate an end to the sync - let endSyncMessage = ARTProtocolMessage() + let endSyncMessage = ProtocolMessage() endSyncMessage.action = .sync endSyncMessage.channel = protocolMessage.channel endSyncMessage.channelSerial = "validserialprefix:" // with no part after the `:` this indicates the end to the SYNC @@ -1646,7 +1646,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Members is nil"); done(); return } XCTAssertEqual(members.count, 102) // 100 initial members + "b" + "c", client "a" is discarded - expect(members).to(allPass { (member: ARTPresenceMessage?) in member!.action != .absent }) + expect(members).to(allPass { (member: PresenceMessage?) in member!.action != .absent }) expect(members.filter { $0.clientId == "a" }).to(beEmpty()) XCTAssertEqual(members.filter { $0.clientId == "b" }.count, 1) XCTAssertEqual(members.filter { $0.clientId! == "b" }.first?.timestamp, now as Date) @@ -1663,7 +1663,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let timeBeforeSync = Date() let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 20, options: options) @@ -1679,7 +1679,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("TestProxyTransport is not set"); return } - var leaveEvents = [ARTPresenceMessage]() + var leaveEvents = [PresenceMessage]() channel.presence.subscribe(.leave) { message in leaveEvents.append(message) } @@ -1689,8 +1689,8 @@ class RealtimeClientPresenceTests: XCTestCase { transport.setBeforeIncomingMessageModifier { protocolMessage in if protocolMessage.action == .sync { protocolMessage.presence?.append(contentsOf: [ - ARTPresenceMessage(clientId: "user10", action: .leave, connectionId: membersConnectionId, id: "synthesized:9:0", timestamp: timeBeforeSync), - ARTPresenceMessage(clientId: "user12", action: .leave, connectionId: membersConnectionId, id: "synthesized:11:0", timestamp: Date() + 1) + PresenceMessage(clientId: "user10", action: .leave, connectionId: membersConnectionId, id: "synthesized:9:0", timestamp: timeBeforeSync), + PresenceMessage(clientId: "user12", action: .leave, connectionId: membersConnectionId, id: "synthesized:11:0", timestamp: Date() + 1) ]) transport.setBeforeIncomingMessageModifier(nil) partialDone() @@ -1717,7 +1717,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__047__Presence__PresenceMap__if_action_of_UPDATE_arrives__it_should_be_added_to_the_presence_map_with_the_action_set_to_PRESENT() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -1746,11 +1746,11 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime! + var clientMembers: Realtime! defer { clientMembers.dispose(); clientMembers.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 1, options: options) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) @@ -1774,7 +1774,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } let channelName = test.uniqueChannelName() clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 20, options: options) @@ -1821,7 +1821,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 20, options: options) @@ -1852,12 +1852,12 @@ class RealtimeClientPresenceTests: XCTestCase { XCTAssertTrue(channel.internal.presence.syncInProgress) // Inject a fabricated Presence message - let leaveMessage = ARTProtocolMessage() + let leaveMessage = ProtocolMessage() leaveMessage.action = .presence leaveMessage.channel = channel.name leaveMessage.timestamp = Date() leaveMessage.presence = [ - ARTPresenceMessage(clientId: "user11", action: .leave, connectionId: "another", id: "another:123:0", timestamp: Date()), + PresenceMessage(clientId: "user11", action: .leave, connectionId: "another", id: "another:123:0", timestamp: Date()), ] channel.internalAsync { _ in transport.receive(leaveMessage) @@ -1879,7 +1879,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__051__Presence__PresenceMap__any_incoming_presence_message_that_passes_the_newness_check_should_be_emitted_on_the_Presence_object__with_an_event_name_set_to_its_original_action() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -1909,7 +1909,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, clientId: "john", capability: "{ \"cannotpresence:john\":[\"publish\"] }") options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1929,7 +1929,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP9e func test__057__Presence__update__should_result_in_an_error_immediately_if_the_client_is_anonymous() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1946,13 +1946,13 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) channel.attach() channel.detach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.presence.update(nil) { error in @@ -1967,7 +1967,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1989,7 +1989,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, clientId: "john", capability: "{ \"cannotpresence:john\":[\"publish\"] }") options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2007,7 +2007,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP9e func test__061__Presence__update__should_result_in_an_error_if_Ably_service_determines_that_the_client_is_unidentified() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2026,7 +2026,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2062,7 +2062,7 @@ class RealtimeClientPresenceTests: XCTestCase { } waitUntil(timeout: testTimeout) { done in - let sentError = ARTErrorInfo.create(withCode: 0, message: "test error") + let sentError = ErrorInfo.create(withCode: 0, message: "test error") let transport = client.internal.transport as! TestProxyTransport transport.enableReplaceAcksWithNacks(with: sentError) channel.presence.leave("offline") { error in @@ -2076,7 +2076,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__064__Presence__leave__should_raise_an_error_if_client_is_not_present() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -2108,13 +2108,13 @@ class RealtimeClientPresenceTests: XCTestCase { let transport = client.internal.transport as! TestProxyTransport let sent = transport.protocolMessagesSent.filter { $0.action == .presence }[1].presence![0] - XCTAssertEqual(sent.action, ARTPresenceAction.leave) + XCTAssertEqual(sent.action, PresenceAction.leave) XCTAssertNil(sent.clientId) let receivedPresenceProtocolMessages = transport.protocolMessagesReceived.filter { $0.action == .presence } let receivedPresenceMessages = receivedPresenceProtocolMessages.flatMap { $0.presence! } let received = receivedPresenceMessages.filter { $0.action == .leave }[0] - XCTAssertEqual(received.action, ARTPresenceAction.leave) + XCTAssertEqual(received.action, PresenceAction.leave) XCTAssertEqual(received.clientId, "john") } @@ -2124,7 +2124,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -2158,19 +2158,19 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in XCTAssertNil(error) done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) } // RTP8d @@ -2179,7 +2179,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2193,7 +2193,7 @@ class RealtimeClientPresenceTests: XCTestCase { done() } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } // RTP8d @@ -2202,7 +2202,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2217,7 +2217,7 @@ class RealtimeClientPresenceTests: XCTestCase { partialDone() } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) waitUntil(timeout: testTimeout) { done in channel.presence.enter("online") { error in @@ -2232,7 +2232,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP10e func test__070__Presence__leave__should_result_in_an_error_immediately_if_the_client_is_anonymous() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2249,7 +2249,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2275,7 +2275,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2304,7 +2304,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, clientId: "john", capability: "{ \"cannotpresence:other\":[\"publish\"] }") options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2319,7 +2319,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP10e func test__074__Presence__leave__should_result_in_an_error_if_Ably_service_determines_that_the_client_is_unidentified() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2336,27 +2336,27 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP6c func test__075__Presence__subscribe__should_implicitly_attach_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) channel.presence.subscribe { _ in } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) channel.detach() - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) channel.presence.subscribe(.present) { _ in } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) } // RTP6c func test__076__Presence__subscribe__should_result_in_an_error_if_the_channel_is_in_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2367,7 +2367,7 @@ class RealtimeClientPresenceTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.presence.subscribe(attachCallback: { error in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertNotNil(error) done() }, callback: { _ in @@ -2379,14 +2379,14 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP6c func test__077__Presence__subscribe__should_result_in_an_error_if_the_channel_moves_to_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let error = AblyTests.newErrorProtocolMessage() channel.presence.subscribe(attachCallback: { error in - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertNotNil(error) done() }, callback: { _ in @@ -2418,7 +2418,7 @@ class RealtimeClientPresenceTests: XCTestCase { attachAndWaitForInitialPresenceSyncToComplete(client: client1, channel: channel1) options.clientId = "mary" - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channel2 = client2.channels.get(channelName) @@ -2443,14 +2443,14 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client1 = ARTRealtime(options: options) + let client1 = Realtime(options: options) defer { client1.close() } let channelName = test.uniqueChannelName() let channel1 = client1.channels.get(channelName) options.clientId = "mary" - let client2 = ARTRealtime(options: options) + let client2 = Realtime(options: options) defer { client2.close() } let channel2 = client2.channels.get(channelName) @@ -2488,12 +2488,12 @@ class RealtimeClientPresenceTests: XCTestCase { let channelName = test.uniqueChannelName() options.clientId = "a" - let clientA = ARTRealtime(options: options) + let clientA = Realtime(options: options) defer { clientA.dispose(); clientA.close() } let channelA = clientA.channels.get(channelName) options.clientId = "b" - let clientB = ARTRealtime(options: options) + let clientB = Realtime(options: options) defer { clientB.dispose(); clientB.close() } let channelB = clientB.channels.get(channelName) @@ -2504,7 +2504,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientA.connection.id else { fail("ClientA should be connected"); partialDone(); return } - XCTAssertTrue(presence.action == ARTPresenceAction.enter || presence.action == ARTPresenceAction.present) + XCTAssertTrue(presence.action == PresenceAction.enter || presence.action == PresenceAction.present) XCTAssertEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelA.internal.presence.members.count, 1) XCTAssertEqual(channelA.internal.presence.internalMembers.count, 1) @@ -2515,7 +2515,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientB.connection.id else { fail("ClientB should be connected"); partialDone(); return } - XCTAssertTrue(presence.action == ARTPresenceAction.enter || presence.action == ARTPresenceAction.present) + XCTAssertTrue(presence.action == PresenceAction.enter || presence.action == PresenceAction.present) XCTAssertNotEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelB.internal.presence.members.count, 1) XCTAssertEqual(channelB.internal.presence.internalMembers.count, 0) @@ -2531,7 +2531,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientA.connection.id else { fail("ClientA should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.enter) + XCTAssertEqual(presence.action, PresenceAction.enter) XCTAssertNotEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelA.internal.presence.members.count, 2) XCTAssertEqual(channelA.internal.presence.internalMembers.count, 1) @@ -2542,7 +2542,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientB.connection.id else { fail("ClientB should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.enter) + XCTAssertEqual(presence.action, PresenceAction.enter) XCTAssertEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelB.internal.presence.members.count, 2) XCTAssertEqual(channelB.internal.presence.internalMembers.count, 1) @@ -2559,7 +2559,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientA.connection.id else { fail("ClientA should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.update) + XCTAssertEqual(presence.action, PresenceAction.update) XCTAssertEqual(presence.data as? String, "hello") XCTAssertNotEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelA.internal.presence.members.count, 2) @@ -2571,7 +2571,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientB.connection.id else { fail("ClientB should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.update) + XCTAssertEqual(presence.action, PresenceAction.update) XCTAssertEqual(presence.data as? String, "hello") XCTAssertEqual(presence.connectionId, currentConnectionId) XCTAssertEqual(channelB.internal.presence.members.count, 2) @@ -2589,7 +2589,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientA.connection.id else { fail("ClientA should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.leave) + XCTAssertEqual(presence.action, PresenceAction.leave) XCTAssertEqual(presence.data as? String, "bye") XCTAssertNotEqual(presence.connectionId, currentConnectionId) if channelA.internal.presence.syncInProgress { @@ -2606,7 +2606,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let currentConnectionId = clientB.connection.id else { fail("ClientB should be connected"); partialDone(); return } - XCTAssertEqual(presence.action, ARTPresenceAction.leave) + XCTAssertEqual(presence.action, PresenceAction.leave) XCTAssertEqual(presence.data as? String, "bye") XCTAssertEqual(presence.connectionId, currentConnectionId) if channelB.internal.presence.syncInProgress { @@ -2632,7 +2632,7 @@ class RealtimeClientPresenceTests: XCTestCase { options.tokenDetails = try getTestTokenDetails(for: test, clientId: clientId, capability: "{\"\(channelName)\":[\"presence\",\"publish\"]}") // Prevent channel name to be prefixed by test-* options.testOptions.channelNamePrefix = nil - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -2704,11 +2704,11 @@ class RealtimeClientPresenceTests: XCTestCase { client.waitForPendingMessages() client.simulateLostConnection() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) // RTP17i - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) expect(channel.internal.presence.internalMembers).to(haveCount(2)) let newTransport = client.internal.transport as! TestProxyTransport @@ -2723,7 +2723,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP17i - already attached with resume flag set - let attachedMessage = ARTProtocolMessage() + let attachedMessage = ProtocolMessage() attachedMessage.action = .attached attachedMessage.channel = channel.name attachedMessage.flags = 4 // resume flag @@ -2737,8 +2737,8 @@ class RealtimeClientPresenceTests: XCTestCase { expect(client1PresenceMessage.id).to(equal(firstMsgId)) expect(client2PresenceMessage.id).to(equal(secondMsgId)) - expect(client1PresenceMessage.action).to(equal(ARTPresenceAction.enter)) - expect(client2PresenceMessage.action).to(equal(ARTPresenceAction.enter)) + expect(client1PresenceMessage.action).to(equal(PresenceAction.enter)) + expect(client2PresenceMessage.action).to(equal(PresenceAction.enter)) expect(client1PresenceMessage.data as? String).to(equal(firstClientData)) expect(client2PresenceMessage.data as? String).to(equal(secondClientData)) @@ -2748,7 +2748,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__004__Presence__callback_can_be_provided_that_will_be_called_upon_success() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2765,7 +2765,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, capability: "{ \"room\":[\"subscribe\"] }") - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2786,7 +2786,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2815,24 +2815,24 @@ class RealtimeClientPresenceTests: XCTestCase { } // RTP15e - func reusableTestsTestPresencePerformMethod(for test: Test, testCase: TestCase_ReusableTestsTestPresencePerformMethod, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil, _ performMethod: @escaping (ARTRealtimePresence, ((ARTErrorInfo?) -> Void)?) -> Void) throws { + func reusableTestsTestPresencePerformMethod(for test: Test, testCase: TestCase_ReusableTestsTestPresencePerformMethod, beforeEach contextBeforeEach: (() -> Void)? = nil, afterEach contextAfterEach: (() -> Void)? = nil, _ performMethod: @escaping (RealtimePresence, ((ErrorInfo?) -> Void)?) -> Void) throws { func test__should_implicitly_attach_the_Channel() throws { contextBeforeEach?() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in // Call: enterClient, updateClient and leaveClient performMethod(channel.presence) { errorInfo in XCTAssertNil(errorInfo) done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) contextAfterEach?() } @@ -2840,7 +2840,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__should_result_in_an_error_if_the_channel_is_in_the_FAILED_state() throws { contextBeforeEach?() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2853,7 +2853,7 @@ class RealtimeClientPresenceTests: XCTestCase { // Call: enterClient, updateClient and leaveClient performMethod(channel.presence) { error in XCTAssertEqual(error?.code, ARTErrorCode.unableToEnterPresenceChannelInvalidState.intValue) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) guard let reason = channel.errorReason else { fail("Reason is empty"); done(); return } @@ -2956,7 +2956,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -2983,18 +2983,18 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP16a func test__093__Presence__Connection_state_conditions__all_presence_messages_are_published_immediately_if_the_connection_is_CONNECTED() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("user", data: nil) { error in XCTAssertNil(error) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertEqual(client.internal.queuedMessages.count, 0) done() } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) XCTAssertEqual(client.internal.queuedMessages.count, 1) } } @@ -3003,7 +3003,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__094__Presence__Connection_state_conditions__all_presence_messages_will_be_queued_and_delivered_as_soon_as_the_connection_state_returns_to_CONNECTED() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) XCTAssertTrue(client.internal.options.queueMessages) @@ -3018,11 +3018,11 @@ class RealtimeClientPresenceTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("user", data: nil) { error in XCTAssertNil(error) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertEqual(client.internal.queuedMessages.count, 0) done() } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.disconnected) XCTAssertEqual(client.internal.queuedMessages.count, 1) } } @@ -3032,12 +3032,12 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.queueMessages = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) XCTAssertFalse(client.internal.options.queueMessages) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in channel.attach { _ in @@ -3061,11 +3061,11 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.queueMessages = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.initialized) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.initialized) waitUntil(timeout: testTimeout) { done in channel.presence.enterClient("user", data: nil) { error in @@ -3105,7 +3105,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP11 func test__106__Presence__get__query__waitForSync_should_be_true_by_default() { - XCTAssertTrue(ARTRealtimePresenceQuery().waitForSync) + XCTAssertTrue(RealtimePresenceQuery().waitForSync) } // RTP11a @@ -3113,7 +3113,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -3126,11 +3126,11 @@ class RealtimeClientPresenceTests: XCTestCase { let channelName = test.uniqueChannelName() disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, data: expectedData as AnyObject?, options: options)] - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) - let hook = ARTRealtimePresenceQuery.testSuite_injectIntoClassMethod(#selector(ARTRealtimePresenceQuery.init as () -> ARTRealtimePresenceQuery)) { // Default initialiser: referring to the no-parameter variant of `init` as one of several overloaded methods requires an explicit `as ` cast + let hook = RealtimePresenceQuery.testSuite_injectIntoClassMethod(#selector(RealtimePresenceQuery.init as () -> RealtimePresenceQuery)) { // Default initialiser: referring to the no-parameter variant of `init` as one of several overloaded methods requires an explicit `as ` cast } defer { hook?.remove() } @@ -3142,7 +3142,7 @@ class RealtimeClientPresenceTests: XCTestCase { } else { XCTFail("Expected members to be non-nil") } - expect(members!.first).to(beAnInstanceOf(ARTPresenceMessage.self)) + expect(members!.first).to(beAnInstanceOf(PresenceMessage.self)) expect(members).to(allPass { member in NSRegularExpression.match(member.clientId, pattern: "^user(\\d+)$") && (member.data as? String) == expectedData @@ -3155,26 +3155,26 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP11b func test__101__Presence__get__should_implicitly_attach_the_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.initialized) + XCTAssertEqual(channel.state, RealtimeChannelState.initialized) waitUntil(timeout: testTimeout) { done in channel.presence.get { membersPage, error in XCTAssertNil(error) XCTAssertNotNil(membersPage) done() } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attaching) + XCTAssertEqual(channel.state, RealtimeChannelState.attaching) } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.attached) + XCTAssertEqual(channel.state, RealtimeChannelState.attached) } // RTP11b func test__102__Presence__get__should_result_in_an_error_if_the_channel_is_in_the_FAILED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3190,13 +3190,13 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Channel error is empty"); return } XCTAssertEqual(channelError.message, protocolError.message) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) waitUntil(timeout: testTimeout) { done in channel.presence.get { members, error in XCTAssertEqual(error?.code, ARTErrorCode.channelOperationFailedInvalidState.intValue) XCTAssertEqual(channel.errorReason, protocolError) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) XCTAssertNil(members) done() } @@ -3231,13 +3231,13 @@ class RealtimeClientPresenceTests: XCTestCase { } } - XCTAssertEqual(channel.state, ARTRealtimeChannelState.failed) + XCTAssertEqual(channel.state, RealtimeChannelState.failed) } // RTP11b func test__104__Presence__get__should_result_in_an_error_if_the_channel_is_in_the_DETACHED_state() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -3253,7 +3253,7 @@ class RealtimeClientPresenceTests: XCTestCase { channel.presence.get { members, error in XCTAssertEqual(error?.code, ARTErrorCode.channelOperationFailedInvalidState.intValue) XCTAssertNil(members) - XCTAssertEqual(channel.state, ARTRealtimeChannelState.detached) + XCTAssertEqual(channel.state, RealtimeChannelState.detached) done() } } @@ -3264,10 +3264,10 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } let channelName = test.uniqueChannelName() @@ -3290,7 +3290,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.detached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.detached), timeout: testTimeout) } // RTP11d @@ -3305,7 +3305,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__108__Presence__get__If_the_Channel_is_in_the_SUSPENDED_state_then__if_waitForSync_is_true__results_in_an_error() throws { let test = Test() try testSuspendedStateResultsInError(for: test, channelName: test.uniqueChannelName()) { channel, callback in - let params = ARTRealtimePresenceQuery() + let params = RealtimePresenceQuery() params.waitForSync = true channel.presence.get(params, callback: callback) } @@ -3316,9 +3316,9 @@ class RealtimeClientPresenceTests: XCTestCase { let (channel, client) = try getSuspendedChannel(named: test.uniqueChannelName(), for: test) defer { client.dispose(); client.close() } - var msgs = [String: ARTPresenceMessage]() + var msgs = [String: PresenceMessage]() for i in 0 ..< 3 { - let msg = ARTPresenceMessage(clientId: "client\(i)", action: .present, connectionId: "foo", id: "foo:0:0") + let msg = PresenceMessage(clientId: "client\(i)", action: .present, connectionId: "foo", id: "foo:0:0") msgs[msg.clientId!] = msg channel.internal.presence.processMember(msg) } @@ -3329,7 +3329,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let result = result else { return } - var resultByClient = [String: ARTPresenceMessage]() + var resultByClient = [String: PresenceMessage]() for msg in result { resultByClient[msg.clientId ?? "(no clientId)"] = msg } @@ -3356,7 +3356,7 @@ class RealtimeClientPresenceTests: XCTestCase { expect(channel.internal.presence.syncInProgress).toEventually(beTrue(), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() XCTAssertTrue(query.waitForSync) XCTAssertEqual(channel.internal.presence.syncInProgress, true) channel.presence.get(query) { members, error in @@ -3376,7 +3376,7 @@ class RealtimeClientPresenceTests: XCTestCase { func test__111__Presence__get__Query__set_of_params___waitForSync_is_false__should_return_immediately_the_known_set_of_presence_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var clientSecondary: ARTRealtime! + var clientSecondary: Realtime! defer { clientSecondary.dispose(); clientSecondary.close() } let channelName = test.uniqueChannelName() @@ -3386,7 +3386,7 @@ class RealtimeClientPresenceTests: XCTestCase { defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() query.waitForSync = false waitUntil(timeout: testTimeout) { done in @@ -3436,13 +3436,13 @@ class RealtimeClientPresenceTests: XCTestCase { let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - let presenceData: [ARTPresenceMessage] = [ - ARTPresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), - ARTPresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), - ARTPresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), - ARTPresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), - ARTPresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), + let presenceData: [PresenceMessage] = [ + PresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), + PresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), + PresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), + PresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), + PresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), + PresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), ] guard let transport = client.internal.transport as? TestProxyTransport else { @@ -3454,7 +3454,7 @@ class RealtimeClientPresenceTests: XCTestCase { XCTAssertNil(error) // Inject a fabricated Presence message - let presenceMessage = ARTProtocolMessage() + let presenceMessage = ProtocolMessage() presenceMessage.action = .presence presenceMessage.channel = channel.name presenceMessage.timestamp = Date() @@ -3466,7 +3466,7 @@ class RealtimeClientPresenceTests: XCTestCase { } } - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() query.clientId = "b" waitUntil(timeout: testTimeout) { done in @@ -3476,7 +3476,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Members is nil"); done(); return } XCTAssertEqual(members.count, 1) - expect(members).to(allPass { (member: ARTPresenceMessage?) in member!.action != .absent }) + expect(members).to(allPass { (member: PresenceMessage?) in member!.action != .absent }) expect(members.filter { $0.clientId == "a" }).to(beEmpty()) XCTAssertEqual(members.filter { $0.clientId == "b" }.count, 1) expect(members.filter { $0.clientId == "c" }).to(beEmpty()) @@ -3491,7 +3491,7 @@ class RealtimeClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let now = NSDate() let channelName = test.uniqueChannelName() - var clientMembers: ARTRealtime? + var clientMembers: Realtime? defer { clientMembers?.dispose(); clientMembers?.close() } clientMembers = AblyTests.addMembersSequentiallyToChannel(channelName, members: 101, options: options) @@ -3499,13 +3499,13 @@ class RealtimeClientPresenceTests: XCTestCase { defer { clientSubscribed.dispose(); clientSubscribed.close() } let channelSubscribed = clientSubscribed.channels.get(channelName) - let presenceData: [ARTPresenceMessage] = [ - ARTPresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), - ARTPresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), - ARTPresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), - ARTPresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), - ARTPresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), - ARTPresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), + let presenceData: [PresenceMessage] = [ + PresenceMessage(clientId: "a", action: .enter, connectionId: "one", id: "one:0:0", timestamp: now as Date), + PresenceMessage(clientId: "a", action: .leave, connectionId: "one", id: "fabricated:0:1", timestamp: (now as Date) + 1), + PresenceMessage(clientId: "b", action: .enter, connectionId: "one", id: "one:0:2", timestamp: now as Date), + PresenceMessage(clientId: "b", action: .leave, connectionId: "one", id: "fabricated:0:3", timestamp: (now as Date) - 1), + PresenceMessage(clientId: "c", action: .enter, connectionId: "one", id: "fabricated:0:4", timestamp: now as Date), + PresenceMessage(clientId: "c", action: .leave, connectionId: "one", id: "fabricated:0:5", timestamp: (now as Date) - 1), ] guard let transport = clientSubscribed.internal.transport as? TestProxyTransport else { @@ -3517,7 +3517,7 @@ class RealtimeClientPresenceTests: XCTestCase { // Receive the first Sync message from Ably service if protocolMessage.action == .sync { // Inject a fabricated Presence message - let presenceMessage = ARTProtocolMessage() + let presenceMessage = ProtocolMessage() presenceMessage.action = .presence presenceMessage.channel = protocolMessage.channel presenceMessage.timestamp = Date() @@ -3526,7 +3526,7 @@ class RealtimeClientPresenceTests: XCTestCase { transport.receive(presenceMessage) // Simulate an end to the sync - let endSyncMessage = ARTProtocolMessage() + let endSyncMessage = ProtocolMessage() endSyncMessage.action = .sync endSyncMessage.channel = protocolMessage.channel endSyncMessage.channelSerial = "validserialprefix:" // with no part after the `:` this indicates the end to the SYNC @@ -3545,7 +3545,7 @@ class RealtimeClientPresenceTests: XCTestCase { channelSubscribed.attach() } - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() query.connectionId = "one" waitUntil(timeout: testTimeout) { done in @@ -3555,7 +3555,7 @@ class RealtimeClientPresenceTests: XCTestCase { fail("Members is nil"); done(); return } XCTAssertEqual(members.count, 2) - expect(members).to(allPass { (member: ARTPresenceMessage?) in member!.action != .absent }) + expect(members).to(allPass { (member: PresenceMessage?) in member!.action != .absent }) expect(members.filter { $0.clientId == "a" }).to(beEmpty()) XCTAssertEqual(members.filter { $0.clientId == "b" }.count, 1) XCTAssertEqual(members.filter { $0.clientId == "c" }.count, 1) @@ -3571,9 +3571,9 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } let channelName = test.uniqueChannelName() @@ -3592,13 +3592,13 @@ class RealtimeClientPresenceTests: XCTestCase { } defer { hookRealtime.remove() } - let queryRealtime = ARTRealtimeHistoryQuery() + let queryRealtime = RealtimeHistoryQuery() queryRealtime.start = Date() queryRealtime.end = Date() queryRealtime.direction = .forwards queryRealtime.limit = 50 - let queryRest = queryRealtime as ARTDataQuery + let queryRest = queryRealtime as DataQuery waitUntil(timeout: testTimeout) { done in expect { @@ -3627,7 +3627,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var clientSecondary: ARTRealtime! + var clientSecondary: Realtime! defer { clientSecondary.dispose(); clientSecondary.close() } let expectedData = ["x", "y"] @@ -3636,7 +3636,7 @@ class RealtimeClientPresenceTests: XCTestCase { let channelName = test.uniqueChannelName() clientSecondary = AblyTests.addMembersSequentiallyToChannel(channelName, members: 150, data: expectedData as AnyObject?, options: options) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(channelName) @@ -3646,7 +3646,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let membersPage = membersPage else { fail("membersPage is empty"); done(); return } - expect(membersPage).to(beAnInstanceOf(ARTPaginatedResult.self)) + expect(membersPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(membersPage.items.count, 100) let members = membersPage.items @@ -3663,7 +3663,7 @@ class RealtimeClientPresenceTests: XCTestCase { guard let nextPage = nextPage else { fail("nextPage is empty"); done(); return } - expect(nextPage).to(beAnInstanceOf(ARTPaginatedResult.self)) + expect(nextPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(nextPage.items.count, 50) let members = nextPage.items @@ -3685,7 +3685,7 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -3702,7 +3702,7 @@ class RealtimeClientPresenceTests: XCTestCase { channel.attach() XCTAssertFalse(channel.presence.syncComplete) - expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout) + expect(channel.state).toEventually(equal(RealtimeChannelState.attached), timeout: testTimeout) let transport = client.internal.transport as! TestProxyTransport transport.setListenerBeforeProcessingIncomingMessage { protocolMessage in @@ -3720,7 +3720,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP14a, RTP14b, RTP14c, RTP14d func test__116__Presence__enterClient__enters_into_presence_on_a_channel_on_behalf_of_another_clientId() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) XCTAssertEqual(channel.internal.presence.members.count, 0) @@ -3728,13 +3728,13 @@ class RealtimeClientPresenceTests: XCTestCase { let expectedData = ["test": 1] var encodeWasCalled = false - let hookEncode = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(ARTDataEncoder.encode(_:))) { + let hookEncode = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(DataEncoder.encode(_:))) { encodeWasCalled = true } defer { hookEncode.remove() } var decodeWasCalled = false - let hookDecode = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(ARTDataEncoder.decode(_:encoding:))) { + let hookDecode = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(DataEncoder.decode(_:encoding:))) { decodeWasCalled = true } defer { hookDecode.remove() } @@ -3752,7 +3752,7 @@ class RealtimeClientPresenceTests: XCTestCase { waitUntil(timeout: testTimeout) { done in channel.presence.get { members, _ in - guard let members = members?.reduce([String: ARTPresenceMessage](), { dictionary, item in + guard let members = members?.reduce([String: PresenceMessage](), { dictionary, item in dictionary + [item.clientId ?? "": item] }) else { fail("No members"); done(); return } @@ -3770,7 +3770,7 @@ class RealtimeClientPresenceTests: XCTestCase { // RTP14d func test__117__Presence__enterClient__should_be_present_all_the_registered_members_on_a_presence_channel() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -3814,12 +3814,12 @@ class RealtimeClientPresenceTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } - let protocolMessage = ARTProtocolMessage() + let protocolMessage = ProtocolMessage() protocolMessage.id = "protocolId" - let presenceMessage = ARTPresenceMessage() + let presenceMessage = PresenceMessage() presenceMessage.clientId = "clientId" presenceMessage.action = .enter protocolMessage.presence = [presenceMessage] diff --git a/Test/Tests/RealtimeClientTests.swift b/Test/Tests/RealtimeClientTests.swift index 91cc43519..5499f9605 100644 --- a/Test/Tests/RealtimeClientTests.swift +++ b/Test/Tests/RealtimeClientTests.swift @@ -2,8 +2,8 @@ import Ably import Nimble import XCTest -private let query: ARTStatsQuery = { - let query = ARTStatsQuery() +private let query: StatsQuery = { + let query = StatsQuery() query.unit = .minute return query }() @@ -12,7 +12,7 @@ private let presenceData = buildStringThatExceedMaxMessageSize() private let clientId = "testMessageSizeClientId" class RealtimeClientTests: XCTestCase { - func checkError(_ errorInfo: ARTErrorInfo?, withAlternative message: String) { + func checkError(_ errorInfo: ErrorInfo?, withAlternative message: String) { if let error = errorInfo { XCTFail("\(error.code): \(error.message)") } else if !message.isEmpty { @@ -20,7 +20,7 @@ class RealtimeClientTests: XCTestCase { } } - func checkError(_ errorInfo: ARTErrorInfo?) { + func checkError(_ errorInfo: ErrorInfo?) { checkError(errorInfo, withAlternative: "") } @@ -34,7 +34,7 @@ class RealtimeClientTests: XCTestCase { } enum AblyManager { - static let sharedClient = ARTRealtime(options: { $0.autoConnect = false; return $0 }(ARTClientOptions(key: "xxxx:xxxx"))) + static let sharedClient = Realtime(options: { $0.autoConnect = false; return $0 }(ClientOptions(key: "xxxx:xxxx"))) } // G4 @@ -48,7 +48,7 @@ class RealtimeClientTests: XCTestCase { XCTAssertNil(error) let transport = client.internal.transport as! TestProxyTransport - // This test should not directly validate version against ARTDefault.version(), as + // This test should not directly validate version against Default.version(), as // ultimately the version header has been derived from that value. expect(transport.lastUrl!.query).to(haveParam("v", withValue: "2")) @@ -64,7 +64,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) // Same as Rest options.clientId = "client_string" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } waitUntil(timeout: testTimeout) { done in @@ -78,7 +78,7 @@ class RealtimeClientTests: XCTestCase { self.checkError(errorInfo, withAlternative: "Failed state") done() default: - XCTAssertEqual(state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(state, RealtimeConnectionState.connected) done() } } @@ -87,13 +87,13 @@ class RealtimeClientTests: XCTestCase { // RTC1a func test__014__RealtimeClient__options__should_echoMessages_option_be_true_by_default() { - let options = ARTClientOptions() + let options = ClientOptions() XCTAssertEqual(options.echoMessages, true) } // RTC1b func test__015__RealtimeClient__options__should_autoConnect_option_be_true_by_default() { - let options = ARTClientOptions() + let options = ClientOptions() XCTAssertEqual(options.autoConnect, true) } @@ -104,7 +104,7 @@ class RealtimeClientTests: XCTestCase { options.clientId = "client_string" // First connection - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } waitUntil(timeout: testTimeout) { done in @@ -130,7 +130,7 @@ class RealtimeClientTests: XCTestCase { client.connection.off() // New connection - let newClient = ARTRealtime(options: options) + let newClient = Realtime(options: options) defer { newClient.close() } waitUntil(timeout: testTimeout) { done in @@ -154,10 +154,10 @@ class RealtimeClientTests: XCTestCase { // RTC1d func test__017__RealtimeClient__options__should_modify_the_realtime_endpoint_host_if_realtimeHost_is_assigned() { - let options = ARTClientOptions(key: "secret:key") + let options = ClientOptions(key: "secret:key") options.realtimeHost = "fake.ably.io" options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout.multiplied(by: 3)) { done in @@ -209,7 +209,7 @@ class RealtimeClientTests: XCTestCase { "v": .init(string: "v12.34"), ] - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -226,7 +226,7 @@ class RealtimeClientTests: XCTestCase { XCTAssertTrue(absoluteString.contains("tpString=Lorem%20ipsum")) /** - Test that replacing query string default values in ARTClientOptions works properly + Test that replacing query string default values in ClientOptions works properly */ XCTAssertEqual(absoluteString.components(separatedBy: "v=").count, 2) } else { @@ -244,8 +244,8 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) - expect(client.connection).to(beAKindOf(ARTConnection.self)) + let client = Realtime(options: options) + expect(client.connection).to(beAKindOf(Connection.self)) } // RTC3 @@ -254,7 +254,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -270,7 +270,7 @@ class RealtimeClientTests: XCTestCase { func test__020__RealtimeClient__Auth_object__should_provide_access_to_the_Auth_object() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } XCTAssertEqual(client.auth.internal.options.key, options.key) } @@ -280,7 +280,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client_string" - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } waitUntil(timeout: testTimeout) { done in @@ -305,7 +305,7 @@ class RealtimeClientTests: XCTestCase { // RTC5a func test__022__RealtimeClient__stats__should_present_an_async_interface() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.close() } // Async waitUntil(timeout: testTimeout) { done in @@ -322,9 +322,9 @@ class RealtimeClientTests: XCTestCase { // RTC5b func skipped__test__023__RealtimeClient__stats__should_accept_all_the_same_params_as_RestClient() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.close() } - var paginatedResult: ARTPaginatedResult? + var paginatedResult: PaginatedResult? waitUntil(timeout: testTimeout) { done in client.connection.once(.connected) { _ in done() @@ -337,7 +337,7 @@ class RealtimeClientTests: XCTestCase { if let e = error { XCTFail(e.localizedDescription) } - paginatedResult = paginated as! ARTPaginatedResult? + paginatedResult = paginated as! PaginatedResult? }) }.toNot(throwError()) expect(paginatedResult).toEventuallyNot(beNil(), timeout: testTimeout) @@ -367,7 +367,7 @@ class RealtimeClientTests: XCTestCase { // RTC6a func test__024__RealtimeClient__time__should_present_an_async_interface() throws { let test = Test() - let client = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let client = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { client.close() } // Async waitUntil(timeout: testTimeout) { done in @@ -385,7 +385,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.suspendedRetryTimeout = 6.0 - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.close() } var start: NSDate? @@ -437,7 +437,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -495,7 +495,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -514,7 +514,7 @@ class RealtimeClientTests: XCTestCase { } client.connection.once(.update) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) XCTAssertNil(stateChange.reason) guard let transport = client.internal.transport as? TestProxyTransport else { @@ -556,7 +556,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test, capability: "{\"test\":[\"subscribe\"]}") options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -583,7 +583,7 @@ class RealtimeClientTests: XCTestCase { let partialDone = AblyTests.splitDone(2, done: done) client.connection.once(.update) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) XCTAssertNil(stateChange.reason) partialDone() } @@ -648,7 +648,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -710,7 +710,7 @@ class RealtimeClientTests: XCTestCase { options.clientId = "ios" options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -728,7 +728,7 @@ class RealtimeClientTests: XCTestCase { let partialDone = AblyTests.splitDone(2, done: done) client.connection.once(.failed) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connected) XCTAssertNotNil(stateChange.reason) connectionError = stateChange.reason partialDone() @@ -759,7 +759,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) let testToken = try getTestToken(for: test) options.token = testToken - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -792,7 +792,7 @@ class RealtimeClientTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertEqual(client.auth.tokenDetails?.token, testToken) } @@ -803,7 +803,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -838,7 +838,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } var connections = 0 @@ -870,7 +870,7 @@ class RealtimeClientTests: XCTestCase { fail("TokenDetails is nil"); done(); return } XCTAssertNotNil(tokenDetails.token) - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) guard let transport = client.internal.transport as? TestProxyTransport else { fail("TestProxyTransport is not set"); done(); return @@ -885,7 +885,7 @@ class RealtimeClientTests: XCTestCase { XCTAssertEqual(connections, 2) XCTAssertEqual(connectionsConnected, 1) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) } // RTC8b1 - part 1 @@ -895,7 +895,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false let testToken = try getTestToken(for: test) options.token = testToken - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -916,7 +916,7 @@ class RealtimeClientTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) } // RTC8b1 - part 2 @@ -926,7 +926,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -967,7 +967,7 @@ class RealtimeClientTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.failed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.failed) } // RTC8b1 - part 3 @@ -977,7 +977,7 @@ class RealtimeClientTests: XCTestCase { options.autoConnect = false options.useTokenAuth = true options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1010,7 +1010,7 @@ class RealtimeClientTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.suspended) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.suspended) } // RTC8b1 - part 4 @@ -1019,7 +1019,7 @@ class RealtimeClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false options.useTokenAuth = true - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1054,7 +1054,7 @@ class RealtimeClientTests: XCTestCase { } } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.closed) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.closed) } // RTC8c - part 1 @@ -1065,7 +1065,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1077,19 +1077,19 @@ class RealtimeClientTests: XCTestCase { } client.internal.onSuspended() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.suspended), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.suspended), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) client.connection.once(.connecting) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.suspended) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.suspended) XCTAssertNil(stateChange.reason) partialDone() } client.connection.once(.connected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) XCTAssertNil(stateChange.reason) partialDone() } @@ -1100,7 +1100,7 @@ class RealtimeClientTests: XCTestCase { fail("TokenDetails is nil"); partialDone(); return } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNotEqual(tokenDetails.token, testToken) guard let transport = client.internal.transport as? TestProxyTransport else { @@ -1121,7 +1121,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1133,19 +1133,19 @@ class RealtimeClientTests: XCTestCase { } client.close() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) client.connection.once(.connecting) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.closed) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.closed) XCTAssertNil(stateChange.reason) partialDone() } client.connection.once(.connected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) XCTAssertNil(stateChange.reason) partialDone() } @@ -1156,7 +1156,7 @@ class RealtimeClientTests: XCTestCase { fail("TokenDetails is nil"); partialDone(); return } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNotEqual(tokenDetails.token, testToken) guard let transport = client.internal.transport as? TestProxyTransport else { @@ -1177,7 +1177,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1189,19 +1189,19 @@ class RealtimeClientTests: XCTestCase { } client.internal.onDisconnected() - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) client.connection.once(.connecting) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.disconnected) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.disconnected) XCTAssertNil(stateChange.reason) partialDone() } client.connection.once(.connected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) XCTAssertNil(stateChange.reason) partialDone() } @@ -1212,7 +1212,7 @@ class RealtimeClientTests: XCTestCase { fail("TokenDetails is nil"); partialDone(); return } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNotEqual(tokenDetails.token, testToken) guard let transport = client.internal.transport as? TestProxyTransport else { @@ -1233,7 +1233,7 @@ class RealtimeClientTests: XCTestCase { let testToken = try getTestToken(for: test) options.token = testToken options.testOptions.transportFactory = TestProxyTransportFactory() - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } waitUntil(timeout: testTimeout) { done in @@ -1245,19 +1245,19 @@ class RealtimeClientTests: XCTestCase { } client.internal.onError(AblyTests.newErrorProtocolMessage()) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.failed), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.failed), timeout: testTimeout) waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(3, done: done) client.connection.once(.connecting) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.failed) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.failed) XCTAssertNil(stateChange.reason) partialDone() } client.connection.once(.connected) { stateChange in - XCTAssertEqual(stateChange.previous, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(stateChange.previous, RealtimeConnectionState.connecting) XCTAssertNil(stateChange.reason) partialDone() } @@ -1268,7 +1268,7 @@ class RealtimeClientTests: XCTestCase { fail("TokenDetails is nil"); partialDone(); return } - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connected) XCTAssertNotEqual(tokenDetails.token, testToken) guard let transport = client.internal.transport as? TestProxyTransport else { @@ -1287,7 +1287,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() waitUntil(timeout: testTimeout) { done in URLSession.shared.dataTask(with: URL(string: "https://ably.io")!) { _, _, _ in - let realtime: ARTRealtime + let realtime: Realtime do { realtime = .init(options: try AblyTests.commonAppSetup(for: test)) @@ -1358,7 +1358,7 @@ class RealtimeClientTests: XCTestCase { func test__007__RealtimeClient__transport_should_guarantee_the_incoming_message_order() throws { let test = Test() - let realtime = ARTRealtime(options: try AblyTests.commonAppSetup(for: test)) + let realtime = Realtime(options: try AblyTests.commonAppSetup(for: test)) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in realtime.connection.on(.connected) { _ in @@ -1376,7 +1376,7 @@ class RealtimeClientTests: XCTestCase { let partialDone = AblyTests.splitDone(expectedOrder.count, done: done) realtime.internal.testSuite_getArgument(from: NSSelectorFromString("ack:"), at: 0) { object in - guard let value = (object as? ARTProtocolMessage)?.msgSerial?.intValue else { + guard let value = (object as? ProtocolMessage)?.msgSerial?.intValue else { return } result.append(value) @@ -1384,7 +1384,7 @@ class RealtimeClientTests: XCTestCase { } for i in expectedOrder { - let message = ARTProtocolMessage() + let message = ProtocolMessage() message.action = .ack message.msgSerial = i as NSNumber webSocketTransport.webSocket(webSocketTransport.websocket!, didReceiveMessage: message) @@ -1397,8 +1397,8 @@ class RealtimeClientTests: XCTestCase { func test__008__RealtimeClient__subscriber_should_receive_messages_in_the_same_order_in_which_they_have_been_sent() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let realtime1 = ARTRealtime(options: options) - let realtime2 = ARTRealtime(options: options) + let realtime1 = Realtime(options: options) + let realtime2 = Realtime(options: options) defer { realtime1.dispose(); realtime1.close() realtime2.dispose(); realtime2.close() @@ -1464,25 +1464,25 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.autoConnect = false - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } client.connect() client.close() // Before it connects; this registers a listener on the internal event emitter. - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) client.connection.off() // If we didn't have a separate internal event emitter, the line above would unregister // the listener, and the next lines would fail, because we would never move to // CLOSED, because we do that on the internal event listener registered when // we called close(). - XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connecting) // Still connecting... - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.closed), timeout: testTimeout) + XCTAssertEqual(client.connection.state, RealtimeConnectionState.connecting) // Still connecting... + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.closed), timeout: testTimeout) } func test__011__RealtimeClient__should_never_register_any_message_and_channel_listeners_for_internal_use_with_the_public_EventEmitter() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channel = client.channels.get(test.uniqueChannelName()) @@ -1518,7 +1518,7 @@ class RealtimeClientTests: XCTestCase { func skipped__test__012__RealtimeClient__moves_to_DISCONNECTED_on_an_unexpected_normal_WebSocket_close() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) defer { client.dispose(); client.close() } let channelName = test.uniqueChannelName() @@ -1528,13 +1528,13 @@ class RealtimeClientTests: XCTestCase { received = true } - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) let ws = (client.internal.transport! as! ARTWebSocketTransport).websocket! ws.close(withCode: 1000, reason: "test") - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.disconnected), timeout: testTimeout) - expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.disconnected), timeout: testTimeout) + expect(client.connection.state).toEventually(equal(RealtimeConnectionState.connected), timeout: testTimeout) client.channels.get(channelName).publish(nil, data: "test") @@ -1546,7 +1546,7 @@ class RealtimeClientTests: XCTestCase { func test__041__If_the_total_size_of_message_s__exceeds_the_maxMessageSize__the_client_library_should_reject_the_publish_and_indicate_an_error() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) let messages = buildMessagesThatExceedMaxMessageSize() defer { client.dispose(); client.close() } @@ -1566,7 +1566,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } @@ -1584,7 +1584,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } @@ -1602,7 +1602,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } @@ -1620,7 +1620,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } @@ -1638,7 +1638,7 @@ class RealtimeClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = clientId - let client = ARTRealtime(options: options) + let client = Realtime(options: options) let channel = client.channels.get(test.uniqueChannelName()) defer { client.dispose(); client.close() } diff --git a/Test/Tests/RestClientChannelTests.swift b/Test/Tests/RestClientChannelTests.swift index 77229d742..0d2fa9748 100644 --- a/Test/Tests/RestClientChannelTests.swift +++ b/Test/Tests/RestClientChannelTests.swift @@ -36,17 +36,17 @@ private let binaryData = "123456".data(using: .utf8)! private func testSupportsAESEncryptionWithKeyLength(_ encryptionKeyLength: UInt, for test: Test, channelName: String, testHTTPExecutor: TestProxyHTTPExecutor) throws { let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) client.internal.httpExecutor = testHTTPExecutor - let params: ARTCipherParams = ARTCrypto.getDefaultParams([ - "key": ARTCrypto.generateRandomKey(encryptionKeyLength), + let params: CipherParams = Crypto.getDefaultParams([ + "key": Crypto.generateRandomKey(encryptionKeyLength), ]) XCTAssertEqual(params.algorithm, "AES") XCTAssertEqual(params.keyLength, encryptionKeyLength) XCTAssertEqual(params.mode, "CBC") - let channelOptions = ARTChannelOptions(cipher: params) + let channelOptions = ChannelOptions(cipher: params) let channel = client.channels.get(channelName, options: channelOptions) waitUntil(timeout: testTimeout) { done in @@ -130,12 +130,12 @@ class RestClientChannelTests: XCTestCase { } private struct TestEnvironment { - var client: ARTRest + var client: Rest var testHTTPExecutor: TestProxyHTTPExecutor init(test: Test) throws { let options = try AblyTests.commonAppSetup(for: test) - client = ARTRest(options: options) + client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) } } @@ -148,8 +148,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let testEnvironment = try TestEnvironment(test: test) - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) - var publishedMessage: ARTMessage? + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) + var publishedMessage: Message? let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) @@ -171,8 +171,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let testEnvironment = try TestEnvironment(test: test) - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "io.ably.XCTest", code: -1, userInfo: nil)) - var publishedMessage: ARTMessage? + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "io.ably.XCTest", code: -1, userInfo: nil)) + var publishedMessage: Message? let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) @@ -194,8 +194,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let testEnvironment = try TestEnvironment(test: test) - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) - var publishedMessage: ARTMessage? + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) + var publishedMessage: Message? let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) @@ -217,8 +217,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let testEnvironment = try TestEnvironment(test: test) - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) - var publishedMessage: ARTMessage? + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) + var publishedMessage: Message? let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) @@ -241,13 +241,13 @@ class RestClientChannelTests: XCTestCase { let test = Test() let testEnvironment = try TestEnvironment(test: test) - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) - var publishedMessage: ARTMessage? + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) + var publishedMessage: Message? let channel = testEnvironment.client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: PublishArgs.name, data: PublishArgs.data)]) { error in + channel.publish([Message(name: PublishArgs.name, data: PublishArgs.data)]) { error in publishError = error channel.history { result, _ in publishedMessage = result?.items.first @@ -273,12 +273,12 @@ class RestClientChannelTests: XCTestCase { defer { client.internal.httpExecutor = oldExecutor } client.internal.httpExecutor = testHTTPExecutor - var publishError: ARTErrorInfo? = ARTErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) - var publishedMessages: [ARTMessage] = [] + var publishError: ErrorInfo? = ErrorInfo.create(from: NSError(domain: "", code: -1, userInfo: nil)) + var publishedMessages: [Message] = [] let messages = [ - ARTMessage(name: "bar", data: "foo"), - ARTMessage(name: "bat", data: "baz"), + Message(name: "bar", data: "foo"), + Message(name: "bat", data: "baz"), ] let channel = client.channels.get(test.uniqueChannelName()) @@ -307,12 +307,12 @@ class RestClientChannelTests: XCTestCase { // RSL1f1 func test__011__publish__Unidentified_clients_using_Basic_Auth__should_publish_message_with_the_provided_clientId() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: nil, data: "message", clientId: "tester")]) { error in + channel.publish([Message(name: nil, data: "message", clientId: "tester")]) { error in XCTAssertNil(error) - XCTAssertEqual(client.auth.internal.method, ARTAuthMethod.basic) + XCTAssertEqual(client.auth.internal.method, AuthMethod.basic) channel.history { page, error in XCTAssertNil(error) guard let page = page else { @@ -356,7 +356,7 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john-doe" - let client = ARTRest(options: options) + let client = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in @@ -384,9 +384,9 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client-rest" let expectedClientId = options.clientId - let rest = ARTRest(options: options) + let rest = Rest(options: options) options.clientId = "client-realtime" - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let chanelName = test.uniqueChannelName(prefix: "ch1") @@ -416,9 +416,9 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client-rest" let expectedClientId = options.clientId! - let rest = ARTRest(options: options) + let rest = Rest(options: options) options.clientId = "client-realtime" - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let chanelName = test.uniqueChannelName(prefix: "ch1") @@ -447,8 +447,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let expectedClientId = "client-rest" let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) - let realtime = ARTRealtime(options: options) + let rest = Rest(options: options) + let realtime = Realtime(options: options) let chanelName = test.uniqueChannelName(prefix: "ch1") @@ -477,9 +477,9 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "client-rest" - let rest = ARTRest(options: options) + let rest = Rest(options: options) options.clientId = "client-realtime" - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) let chanelName = test.uniqueChannelName(prefix: "ch1") @@ -496,7 +496,7 @@ class RestClientChannelTests: XCTestCase { fail("Should not receive the message") } publisher.publish("check clientId", data: nil, clientId: "foo") { error in - XCTAssertEqual(error?.code, Int(ARTState.mismatchedClientId.rawValue)) + XCTAssertEqual(error?.code, Int(State.mismatchedClientId.rawValue)) done() } } @@ -517,7 +517,7 @@ class RestClientChannelTests: XCTestCase { } } - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName(prefix: "issue-1074")) waitUntil(timeout: testTimeout) { done in @@ -541,7 +541,7 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "john" - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("name", data: "some data", clientId: "tester") { error in @@ -557,9 +557,9 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) // Prevent channel name to be prefixed by test-* options.testOptions.channelNamePrefix = nil - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName(prefix: "pushenabled:test")) - let extras = ["push": ["notification": ["title": "Hello from Ably!"]]] as ARTJsonCompatible + let extras = ["push": ["notification": ["title": "Hello from Ably!"]]] as JsonCompatible XCTAssertTrue((client.internal.encoders["application/json"] as! ARTJsonLikeEncoder).message(from: [ "data": "foo", @@ -573,7 +573,7 @@ class RestClientChannelTests: XCTestCase { done(); return } - let query = ARTDataQuery() + let query = DataQuery() query.limit = 1 try! channel.history(query) { messages, error in @@ -597,7 +597,7 @@ class RestClientChannelTests: XCTestCase { func test__018__publish__If_the_total_size_of_message_s__exceeds_the_maxMessageSize__the_client_library_should_reject_the_publish_and_indicate_an_error() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) let messages = buildMessagesThatExceedMaxMessageSize() @@ -612,7 +612,7 @@ class RestClientChannelTests: XCTestCase { func test__019__publish__If_the_total_size_of_message_s__exceeds_the_maxMessageSize__also_when_using_publish_data_clientId_extras() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) let name = buildStringThatExceedMaxMessageSize() @@ -630,16 +630,16 @@ class RestClientChannelTests: XCTestCase { func test__020__publish__idempotent_publishing__idempotentRestPublishing_option() throws { let test = Test() - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "2"), true) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "2.0.0"), true) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.1"), false) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.1.2"), false) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.2"), true) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.2.2"), true) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.0"), false) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.0.5"), false) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "0.9"), false) - XCTAssertEqual(ARTClientOptions.getDefaultIdempotentRestPublishing(forVersion: "0.9.1"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "2"), true) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "2.0.0"), true) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.1"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.1.2"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.2"), true) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.2.2"), true) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.0"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "1.0.5"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "0.9"), false) + XCTAssertEqual(ClientOptions.getDefaultIdempotentRestPublishing(forVersion: "0.9.1"), false) // Current version let options = try AblyTests.clientOptions(for: test) @@ -650,10 +650,10 @@ class RestClientChannelTests: XCTestCase { func test__027__publish__idempotent_publishing__random_idempotent_publish_id__should_generate_for_one_message_with_empty_id() throws { let test = Test() - let message = ARTMessage(name: nil, data: "foo") + let message = Message(name: nil, data: "foo") XCTAssertNil(message.id) - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -679,12 +679,12 @@ class RestClientChannelTests: XCTestCase { func test__028__publish__idempotent_publishing__random_idempotent_publish_id__should_generate_for_multiple_messages_with_empty_id() throws { let test = Test() - let message1 = ARTMessage(name: nil, data: "foo1") + let message1 = Message(name: nil, data: "foo1") XCTAssertNil(message1.id) - let message2 = ARTMessage(name: "john", data: "foo2") + let message2 = Message(name: "john", data: "foo2") XCTAssertNil(message2.id) - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -714,10 +714,10 @@ class RestClientChannelTests: XCTestCase { // RSL1k2 func test__021__publish__idempotent_publishing__should_not_generate_for_message_with_a_non_empty_id() throws { let test = Test() - let message = ARTMessage(name: nil, data: "foo") + let message = Message(name: nil, data: "foo") message.id = "123" - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -742,7 +742,7 @@ class RestClientChannelTests: XCTestCase { func test__022__publish__idempotent_publishing__should_generate_for_internal_message_that_is_created_in_publish_name_data___method() throws { let test = Test() - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -767,12 +767,12 @@ class RestClientChannelTests: XCTestCase { // RSL1k3 func test__023__publish__idempotent_publishing__should_not_generate_for_multiple_messages_with_a_non_empty_id() throws { let test = Test() - let message1 = ARTMessage(name: nil, data: "foo1") + let message1 = Message(name: nil, data: "foo1") XCTAssertNil(message1.id) - let message2 = ARTMessage(name: "john", data: "foo2") + let message2 = Message(name: "john", data: "foo2") message2.id = "123" - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.options.idempotentRestPublishing = true let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -796,15 +796,15 @@ class RestClientChannelTests: XCTestCase { func test__024__publish__idempotent_publishing__should_not_generate_when_idempotentRestPublishing_flag_is_off() throws { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.idempotentRestPublishing = false - let message1 = ARTMessage(name: nil, data: "foo1") + let message1 = Message(name: nil, data: "foo1") XCTAssertNil(message1.id) - let message2 = ARTMessage(name: "john", data: "foo2") + let message2 = Message(name: "john", data: "foo2") XCTAssertNil(message2.id) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor let channel = rest.channels.get(test.uniqueChannelName()) @@ -826,7 +826,7 @@ class RestClientChannelTests: XCTestCase { } // RSL1k4 - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__025__publish__idempotent_publishing__should_have_only_one_published_message() throws { let test = Test() let testEnvironment = try TestEnvironment(test: test) @@ -848,9 +848,9 @@ class RestClientChannelTests: XCTestCase { testHTTPExecutor.simulateIncomingServerErrorOnNextRequest(forceRetryError) let messages = [ - ARTMessage(name: nil, data: "test1"), - ARTMessage(name: nil, data: "test2"), - ARTMessage(name: nil, data: "test3"), + Message(name: nil, data: "test1"), + Message(name: nil, data: "test2"), + Message(name: nil, data: "test3"), ] let channel = client.channels.get(test.uniqueChannelName()) @@ -880,11 +880,11 @@ class RestClientChannelTests: XCTestCase { func test__026__publish__idempotent_publishing__should_publish_a_message_with_implicit_Id_only_once() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.internal.options.idempotentRestPublishing = true let channel = rest.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: "unique", data: "foo") + let message = Message(name: "unique", data: "foo") message.id = "123" for _ in 1 ... 4 { @@ -913,12 +913,12 @@ class RestClientChannelTests: XCTestCase { func test__004__publish__should_include_attributes_supplied_by_the_caller_in_the_encoded_message() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let proxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = proxyHTTPExecutor let channel = client.channels.get(test.uniqueChannelName()) - let message = ARTMessage(name: nil, data: "") + let message = Message(name: nil, data: "") message.id = "123" message.name = "tester" @@ -949,7 +949,7 @@ class RestClientChannelTests: XCTestCase { // RSL2a func test__029__history__should_return_a_PaginatedResult_page_containing_the_first_page_of_messages() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -966,7 +966,7 @@ class RestClientChannelTests: XCTestCase { }) } - let query = ARTDataQuery() + let query = DataQuery() query.direction = .forwards query.limit = 2 @@ -1027,11 +1027,11 @@ class RestClientChannelTests: XCTestCase { // RSL2b1 func test__030__history__query_arguments__start_and_end_should_filter_messages_between_those_two_times() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() - XCTAssertEqual(query.direction, ARTQueryDirection.backwards) + let query = DataQuery() + XCTAssertEqual(query.direction, QueryDirection.backwards) XCTAssertEqual(query.limit, 100) waitUntil(timeout: testTimeout) { done in @@ -1042,8 +1042,8 @@ class RestClientChannelTests: XCTestCase { } let messages = [ - ARTMessage(name: nil, data: "message1"), - ARTMessage(name: nil, data: "message2"), + Message(name: nil, data: "message1"), + Message(name: nil, data: "message2"), ] waitUntil(timeout: testTimeout) { done in channel.publish(messages) { _ in @@ -1087,38 +1087,38 @@ class RestClientChannelTests: XCTestCase { // RSL2b1 func test__031__history__query_arguments__start_must_be_equal_to_or_less_than_end_and_is_unaffected_by_the_request_direction() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() + let query = DataQuery() query.direction = .backwards query.end = NSDate() as Date query.start = query.end!.addingTimeInterval(10.0) expect { try channel.history(query) { _, _ in } }.to(throwError { (error: Error) in - XCTAssertEqual(error._code, ARTDataQueryError.timestampRange.rawValue) + XCTAssertEqual(error._code, DataQueryError.timestampRange.rawValue) }) query.direction = .forwards expect { try channel.history(query) { _, _ in } }.to(throwError { (error: Error) in - XCTAssertEqual(error._code, ARTDataQueryError.timestampRange.rawValue) + XCTAssertEqual(error._code, DataQueryError.timestampRange.rawValue) }) } // RSL2b2 func test__032__history__query_arguments__direction_backwards_or_forwards() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() - XCTAssertEqual(query.direction, ARTQueryDirection.backwards) + let query = DataQuery() + XCTAssertEqual(query.direction, QueryDirection.backwards) query.direction = .forwards let messages = [ - ARTMessage(name: nil, data: "message1"), - ARTMessage(name: nil, data: "message2"), + Message(name: nil, data: "message1"), + Message(name: nil, data: "message2"), ] waitUntil(timeout: testTimeout) { done in channel.publish(messages) { _ in @@ -1151,14 +1151,14 @@ class RestClientChannelTests: XCTestCase { // RSL2b3 func test__033__history__query_arguments__limit_items_result() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() + let query = DataQuery() XCTAssertEqual(query.limit, 100) query.limit = 2 - let messages = (1 ... 10).compactMap { ARTMessage(name: nil, data: "message\($0)") } + let messages = (1 ... 10).compactMap { Message(name: nil, data: "message\($0)") } waitUntil(timeout: testTimeout) { done in channel.publish(messages) { _ in done() @@ -1190,10 +1190,10 @@ class RestClientChannelTests: XCTestCase { // RSL2b3 func test__034__history__query_arguments__limit_supports_up_to_1000_items() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() + let query = DataQuery() XCTAssertEqual(query.limit, 100) query.limit = 1001 @@ -1211,15 +1211,15 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.testOptions.channelNamePrefix = nil - let client = ARTRest(options: options) + let client = Rest(options: options) let key = appSetupModel.cipher.key - let cipherParams = ARTCipherParams( + let cipherParams = CipherParams( algorithm: appSetupModel.cipher.algorithm, - key: key as ARTCipherKeyCompatible, + key: key as CipherKeyCompatible, iv: Data(base64Encoded: appSetupModel.cipher.iv, options: Data.Base64DecodingOptions(rawValue: 0))! ) - let channel = client.channels.get("persisted:presence_fixtures", options: ARTChannelOptions(cipher: cipherParams)) - var presenceMessages: [ARTPresenceMessage] = [] + let channel = client.channels.get("persisted:presence_fixtures", options: ChannelOptions(cipher: cipherParams)) + var presenceMessages: [PresenceMessage] = [] channel.presence.get { result, _ in if let items = result?.items { @@ -1236,7 +1236,7 @@ class RestClientChannelTests: XCTestCase { }.first! XCTAssertNotNil(message.data) - XCTAssertEqual(message.action, ARTPresenceAction.present) + XCTAssertEqual(message.action, PresenceAction.present) let encodedFixture = channel.internal.dataEncoder.decode( fixtureMessage.data, @@ -1537,10 +1537,10 @@ class RestClientChannelTests: XCTestCase { func test__045__message_decoding__should_deliver_with_a_binary_payload_when_the_payload_was_successfully_decoded_but_it_could_not_be_decrypted() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let clientEncrypted = ARTRest(options: options) + let clientEncrypted = Rest(options: options) let channelName = test.uniqueChannelName() - let channelOptions = ARTChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) + let channelOptions = ChannelOptions(cipher: ["key": Crypto.generateRandomKey()] as CipherParamsCompatible) let channelEncrypted = clientEncrypted.channels.get(channelName, options: channelOptions) let expectedMessage = ["something": 1] @@ -1551,7 +1551,7 @@ class RestClientChannelTests: XCTestCase { } } - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(channelName) waitUntil(timeout: testTimeout) { done in @@ -1578,9 +1578,9 @@ class RestClientChannelTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.useBinaryProtocol = false - options.logHandler = ARTLog(capturingOutput: true) - let client = ARTRest(options: options) - let channelOptions = ARTChannelOptions(cipher: ["key": ARTCrypto.generateRandomKey()] as ARTCipherParamsCompatible) + options.logHandler = Log(capturingOutput: true) + let client = Rest(options: options) + let channelOptions = ChannelOptions(cipher: ["key": Crypto.generateRandomKey()] as CipherParamsCompatible) let channel = client.channels.get(test.uniqueChannelName(), options: channelOptions) client.internal.httpExecutor = testHTTPExecutor @@ -1623,8 +1623,8 @@ class RestClientChannelTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.clientId = "Client 1" - let rest = ARTRest(options: options) - let realtime = ARTRealtime(options: options) + let rest = Rest(options: options) + let realtime = Realtime(options: options) let channelName = test.uniqueChannelName() let realtimeChannel = realtime.channels.get(channelName) let restChannel = rest.channels.get(channelName) @@ -1636,7 +1636,7 @@ class RestClientChannelTests: XCTestCase { } } - func checkMetrics(completion: @escaping (ARTChannelDetails) -> ()) { + func checkMetrics(completion: @escaping (ChannelDetails) -> ()) { restChannel.status { details, error in XCTAssertNil(error) guard let details = details else { diff --git a/Test/Tests/RestClientChannelsTests.swift b/Test/Tests/RestClientChannelsTests.swift index fb24fd945..1b41b2ddd 100644 --- a/Test/Tests/RestClientChannelsTests.swift +++ b/Test/Tests/RestClientChannelsTests.swift @@ -3,7 +3,7 @@ import Nimble import XCTest // Swift isn't yet smart enough to do this automatically when bridging Objective-C APIs -extension ARTRestChannels: Sequence { +extension RestChannels: Sequence { public func makeIterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(iterate()) } @@ -17,10 +17,10 @@ private func beAChannel(named expectedValue: String) -> Nimble.Predicate.self)) + expect(membersPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(membersPage.items.count, 100) let members = membersPage.items @@ -47,7 +47,7 @@ class RestClientPresenceTests: XCTestCase { membersPage.next { nextPage, error in XCTAssertNil(error) let nextPage = nextPage! - expect(nextPage).to(beAnInstanceOf(ARTPaginatedResult.self)) + expect(nextPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(nextPage.items.count, 50) let members = nextPage.items @@ -67,10 +67,10 @@ class RestClientPresenceTests: XCTestCase { // RSP3a1 func test__003__Presence__get__limit_should_support_up_to_1000_items() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTPresenceQuery() + let query = PresenceQuery() XCTAssertEqual(query.limit, 100) query.limit = 1001 @@ -86,10 +86,10 @@ class RestClientPresenceTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) let channelName = test.uniqueChannelName() - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(channelName) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } let realtimeChannel = realtime.channels.get(channelName) @@ -99,7 +99,7 @@ class RestClientPresenceTests: XCTestCase { expect(realtimeChannel.internal.presence.members).toEventually(haveCount(3), timeout: testTimeout) - let query = ARTPresenceQuery() + let query = PresenceQuery() query.clientId = "john" waitUntil(timeout: testTimeout) { done in @@ -120,12 +120,12 @@ class RestClientPresenceTests: XCTestCase { func test__005__Presence__get__connectionId_should_filter_members_by_the_provided_connectionId() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -139,7 +139,7 @@ class RestClientPresenceTests: XCTestCase { // Another connection disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 3, startFrom: 7, options: options)] - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() // Return all members from last connection (connectionId from the last connection) query.connectionId = disposable.last!.connection.id! @@ -165,12 +165,12 @@ class RestClientPresenceTests: XCTestCase { func test__006__Presence__history__should_return_a_PaginatedResult_page_containing_the_first_page_of_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var realtime: ARTRealtime! + var realtime: Realtime! defer { realtime.dispose(); realtime.close() } let expectedData = "online" @@ -183,7 +183,7 @@ class RestClientPresenceTests: XCTestCase { guard let membersPage = membersPage else { fail("Page is empty"); done(); return } - expect(membersPage).to(beAnInstanceOf(ARTPaginatedResult.self)) + expect(membersPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(membersPage.items.count, 100) let members = membersPage.items @@ -200,7 +200,7 @@ class RestClientPresenceTests: XCTestCase { guard let nextPage = nextPage else { fail("nextPage is empty"); done(); return } - expect(nextPage).to(beAnInstanceOf(ARTPaginatedResult.self)) + expect(nextPage).to(beAnInstanceOf(PaginatedResult.self)) XCTAssertEqual(nextPage.items.count, 50) let members = nextPage.items @@ -227,12 +227,12 @@ class RestClientPresenceTests: XCTestCase { func skipped__test__007__Presence__history__query_argument__direction_should_change_the_order_of_the_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -242,8 +242,8 @@ class RestClientPresenceTests: XCTestCase { disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 10, data: nil, options: options)] - let query = ARTDataQuery() - XCTAssertEqual(query.direction, ARTQueryDirection.backwards) + let query = DataQuery() + XCTAssertEqual(query.direction, QueryDirection.backwards) waitUntil(timeout: testTimeout) { done in expect { @@ -282,16 +282,16 @@ class RestClientPresenceTests: XCTestCase { func test__009__Presence__history__query_argument__limit_supports_up_to_1000_members() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var realtime: ARTRealtime! + var realtime: Realtime! defer { realtime.dispose(); realtime.close() } realtime = AblyTests.addMembersSequentiallyToChannel(channelName, members: 1, options: options) - let query = ARTDataQuery() + let query = DataQuery() XCTAssertEqual(query.limit, 100) query.limit = 1 @@ -310,7 +310,7 @@ class RestClientPresenceTests: XCTestCase { query.limit = 1001 expect { try channel.presence.history(query) { _, _ in } }.to(throwError { (error: Error) in - XCTAssertEqual(error._code, ARTDataQueryError.limit.rawValue) + XCTAssertEqual(error._code, DataQueryError.limit.rawValue) }) } @@ -318,12 +318,12 @@ class RestClientPresenceTests: XCTestCase { func test__008__Presence__history__connectionId_should_filter_members_by_the_provided_connectionId() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -337,7 +337,7 @@ class RestClientPresenceTests: XCTestCase { // Another connection disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 3, startFrom: 7, options: options)] - let query = ARTRealtimePresenceQuery() + let query = RealtimePresenceQuery() // Return all members from last connection (connectionId from the last connection) query.connectionId = disposable.last!.connection.id! @@ -365,12 +365,12 @@ class RestClientPresenceTests: XCTestCase { func test__010__Presence__history__query_argument__start_and_end_should_filter_members_between_those_two_times() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) - var disposable = [ARTRealtime]() + var disposable = [Realtime]() defer { for clientItem in disposable { clientItem.dispose() @@ -378,7 +378,7 @@ class RestClientPresenceTests: XCTestCase { } } - let query = ARTDataQuery() + let query = DataQuery() disposable += [AblyTests.addMembersSequentiallyToChannel(channelName, members: 25, options: options)] @@ -420,22 +420,22 @@ class RestClientPresenceTests: XCTestCase { // RSP4b1 func test__011__Presence__history__query_argument__start_must_be_equal_to_or_less_than_end_and_is_unaffected_by_the_request_direction() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let channel = client.channels.get(test.uniqueChannelName()) - let query = ARTDataQuery() + let query = DataQuery() query.direction = .backwards query.end = NSDate() as Date query.start = query.end!.addingTimeInterval(10.0) expect { try channel.presence.history(query) { _, _ in } }.to(throwError { (error: Error) in - XCTAssertEqual(error._code, ARTDataQueryError.timestampRange.rawValue) + XCTAssertEqual(error._code, DataQueryError.timestampRange.rawValue) }) query.direction = .forwards expect { try channel.presence.history(query) { _, _ in } }.to(throwError { (error: Error) in - XCTAssertEqual(error._code, ARTDataQueryError.timestampRange.rawValue) + XCTAssertEqual(error._code, DataQueryError.timestampRange.rawValue) }) } @@ -443,7 +443,7 @@ class RestClientPresenceTests: XCTestCase { func test__001__Presence__presence_messages_retrieved_are_decoded_in_the_same_way_that_messages_are_decoded() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let channelName = test.uniqueChannelName() let channel = client.channels.get(channelName) @@ -454,7 +454,7 @@ class RestClientPresenceTests: XCTestCase { channel.publish(nil, data: expectedData) { _ in done() } } - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.dispose(); realtime.close() } waitUntil(timeout: testTimeout) { done in let partialDone = AblyTests.splitDone(2, done: done) @@ -469,7 +469,7 @@ class RestClientPresenceTests: XCTestCase { } typealias Done = () -> Void - func checkReceivedMessage(_ done: @escaping Done) -> (ARTPaginatedResult?, ARTErrorInfo?) -> Void { + func checkReceivedMessage(_ done: @escaping Done) -> (PaginatedResult?, ErrorInfo?) -> Void { return { membersPage, error in XCTAssertNil(error) let member = membersPage!.items[0] @@ -479,7 +479,7 @@ class RestClientPresenceTests: XCTestCase { } var decodeNumberOfCalls = 0 - let hook = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(ARTDataEncoder.decode(_:encoding:))) { + let hook = channel.internal.dataEncoder.testSuite_injectIntoMethod(after: #selector(DataEncoder.decode(_:encoding:))) { decodeNumberOfCalls += 1 } defer { hook.remove() } diff --git a/Test/Tests/RestClientStatsTests.swift b/Test/Tests/RestClientStatsTests.swift index ff67d4d64..5a908fef9 100644 --- a/Test/Tests/RestClientStatsTests.swift +++ b/Test/Tests/RestClientStatsTests.swift @@ -3,7 +3,7 @@ import Foundation import Nimble import XCTest -private func postTestStats(_ stats: [[String: Any]], for test: Test) throws -> ARTClientOptions { +private func postTestStats(_ stats: [[String: Any]], for test: Test) throws -> ClientOptions { let options = try AblyTests.commonAppSetup(for: test, forceNewApp: true) let keyBase64 = encodeBase64(options.key ?? "") @@ -20,7 +20,7 @@ private func postTestStats(_ stats: [[String: Any]], for test: Test) throws -> A return options } -private func queryStats(_ client: ARTRest, _ query: ARTStatsQuery, file: FileString = #file, line: UInt = #line) throws -> ARTPaginatedResult { +private func queryStats(_ client: Rest, _ query: StatsQuery, file: FileString = #file, line: UInt = #line) throws -> PaginatedResult { let (stats, error) = try AblyTests.waitFor(timeout: testTimeout, file: file, line: line) { value in expect { try client.stats(query, callback: { result, err in @@ -76,7 +76,7 @@ private let statsFixtures: [[String: Any]] = [ ], ] -private var statsOptions = ARTClientOptions() +private var statsOptions = ClientOptions() class RestClientStatsTests: XCTestCase { // XCTest invokes this method before executing the first test in the test suite. We use it to ensure that the global variables are initialized at the same moment, and in the same order, as they would have been when we used the Quick testing framework. @@ -103,8 +103,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.start = date query.direction = .forwards @@ -126,8 +126,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.start = date query.direction = .forwards query.unit = .hour @@ -149,8 +149,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = calendar.date(byAdding: .day, value: 1, to: date, options: NSCalendar.Options(rawValue: 0)) query.direction = .forwards query.unit = .month @@ -168,8 +168,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = calendar.date(byAdding: .month, value: 1, to: date, options: NSCalendar.Options(rawValue: 0)) query.direction = .forwards query.unit = .month @@ -187,8 +187,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = date.addingTimeInterval(60) // 20XX-02-03:16:04 query.limit = 1 @@ -205,8 +205,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = date.addingTimeInterval(60) // 20XX-02-03:16:04 query.limit = 1 query.direction = .forwards @@ -224,8 +224,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = date.addingTimeInterval(120) // 20XX-02-03:16:05 query.limit = 1 @@ -235,7 +235,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertTrue(firstPage.hasNext) XCTAssertFalse(firstPage.isLast) - let secondPage: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let secondPage: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in firstPage.next { page, err in XCTAssertNil(err) value(page) @@ -247,7 +247,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertTrue(secondPage.hasNext) XCTAssertFalse(secondPage.isLast) - let thirdPage: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let thirdPage: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in secondPage.next { page, err in XCTAssertNil(err) value(page) @@ -258,7 +258,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertEqual((thirdPage.items)[0].inbound.all.messages.data, 5000) XCTAssertTrue(thirdPage.isLast) - let firstPageAgain: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let firstPageAgain: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in thirdPage.first { page, err in XCTAssertNil(err) value(page) @@ -273,8 +273,8 @@ class RestClientStatsTests: XCTestCase { let test = Test() try beforeEach__RestClient__stats__result(for: test) - let client = ARTRest(options: statsOptions) - let query = ARTStatsQuery() + let client = Rest(options: statsOptions) + let query = StatsQuery() query.end = date.addingTimeInterval(120) // 20XX-02-03:16:05 query.limit = 1 query.direction = .forwards @@ -285,7 +285,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertTrue(firstPage.hasNext) XCTAssertFalse(firstPage.isLast) - let secondPage: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let secondPage: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in firstPage.next { page, err in XCTAssertNil(err) value(page) @@ -297,7 +297,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertTrue(secondPage.hasNext) XCTAssertFalse(secondPage.isLast) - let thirdPage: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let thirdPage: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in secondPage.next { page, err in XCTAssertNil(err) value(page) @@ -308,7 +308,7 @@ class RestClientStatsTests: XCTestCase { XCTAssertEqual((thirdPage.items)[0].inbound.all.messages.data, 7000) XCTAssertTrue(thirdPage.isLast) - let firstPageAgain: ARTPaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in + let firstPageAgain: PaginatedResult = try AblyTests.waitFor(timeout: testTimeout) { value in thirdPage.first { page, err in XCTAssertNil(err) value(page) @@ -324,8 +324,8 @@ class RestClientStatsTests: XCTestCase { // RSC6b1 func test__009__RestClient__stats__query__start__should_return_an_error_when_later_than_end() { - let client = ARTRest(key: "fake:key") - let query = ARTStatsQuery() + let client = Rest(key: "fake:key") + let query = StatsQuery() query.start = NSDate.distantFuture query.end = NSDate.distantPast @@ -336,22 +336,22 @@ class RestClientStatsTests: XCTestCase { // RSC6b2 func test__010__RestClient__stats__query__direction__should_be_backwards_by_default() { - let query = ARTStatsQuery() + let query = StatsQuery() - XCTAssertEqual(query.direction, ARTQueryDirection.backwards) + XCTAssertEqual(query.direction, QueryDirection.backwards) } // RSC6b3 func test__011__RestClient__stats__query__limit__should_have_a_default_value_of_100() { - let query = ARTStatsQuery() + let query = StatsQuery() XCTAssertEqual(query.limit, 100) } func test__012__RestClient__stats__query__limit__should_return_an_error_when_greater_than_1000() { - let client = ARTRest(key: "fake:key") - let query = ARTStatsQuery() + let client = Rest(key: "fake:key") + let query = StatsQuery() query.limit = 1001 @@ -361,8 +361,8 @@ class RestClientStatsTests: XCTestCase { // RSC6b4 func test__013__RestClient__stats__query__unit__should_default_to_minute() { - let query = ARTStatsQuery() + let query = StatsQuery() - XCTAssertEqual(query.unit, ARTStatsGranularity.minute) + XCTAssertEqual(query.unit, StatsGranularity.minute) } } diff --git a/Test/Tests/RestClientTests.swift b/Test/Tests/RestClientTests.swift index 4a197aba3..81b90431c 100644 --- a/Test/Tests/RestClientTests.swift +++ b/Test/Tests/RestClientTests.swift @@ -5,10 +5,10 @@ import XCTest private var testHTTPExecutor: TestProxyHTTPExecutor! private func testOptionsGiveBasicAuthFalse(_ caseSetter: (ARTAuthOptions) -> Void) { - let options = ARTClientOptions() + let options = ClientOptions() caseSetter(options) - let client = ARTRest(options: options) + let client = Rest(options: options) XCTAssertFalse(client.auth.internal.options.isBasicAuth()) } @@ -24,8 +24,8 @@ private let shuffleArrayInExpectedHostOrder = { (array: NSMutableArray) in private let _fallbackHosts = ["f.ably-realtime.com", "g.ably-realtime.com", "h.ably-realtime.com", "i.ably-realtime.com", "j.ably-realtime.com"] private func testUsesAlternativeHost(_ caseTest: FakeNetworkResponse, channelName: String) { - let options = ARTClientOptions(key: "xxxx:xxxx") - let client = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -48,8 +48,8 @@ private func testUsesAlternativeHost(_ caseTest: FakeNetworkResponse, channelNam } private func testStoresSuccessfulFallbackHostAsDefaultHost(_ caseTest: FakeNetworkResponse, channelName: String) { - let options = ARTClientOptions(key: "xxxx:xxxx") - let client = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -84,10 +84,10 @@ private func testStoresSuccessfulFallbackHostAsDefaultHost(_ caseTest: FakeNetwo } private func testRestoresDefaultPrimaryHostAfterTimeoutExpires(_ caseTest: FakeNetworkResponse, channelName: String) { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.logLevel = .debug options.fallbackRetryTimeout = 1 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -114,10 +114,10 @@ private func testRestoresDefaultPrimaryHostAfterTimeoutExpires(_ caseTest: FakeN } private func testUsesAnotherFallbackHost(_ caseTest: FakeNetworkResponse, channelName: String) { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackRetryTimeout = 10 options.logLevel = .debug - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -151,7 +151,7 @@ class RestClientTests: XCTestCase { func test__001__RestClient__All_REST_requests_should_include_the_current_API_version() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor let channel = client.channels.get(test.uniqueChannelName()) @@ -160,7 +160,7 @@ class RestClientTests: XCTestCase { XCTAssertNil(error) let version = testHTTPExecutor.requests.first!.allHTTPHeaderFields?["X-Ably-Version"] - // This test should not directly validate version against ARTDefault.version(), as + // This test should not directly validate version against Default.version(), as // ultimately the version header has been derived from that value. XCTAssertEqual(version, "2") @@ -175,7 +175,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(key: options.key!) + let client = Rest(key: options.key!) client.internal.prioritizedHost = options.restHost let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) @@ -184,12 +184,12 @@ class RestClientTests: XCTestCase { } func test__016__RestClient__initializer__should_throw_when_provided_an_invalid_key() { - expect { ARTRest(key: "invalid_key") }.to(raiseException()) + expect { Rest(key: "invalid_key") }.to(raiseException()) } func test__017__RestClient__initializer__should_result_in_error_status_when_provided_a_bad_key() { let test = Test() - let client = ARTRest(key: "fake:key") + let client = Rest(key: "fake:key") let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) @@ -198,10 +198,10 @@ class RestClientTests: XCTestCase { func test__018__RestClient__initializer__should_accept_a_token() throws { let test = Test() - ARTClientOptions.setDefaultEnvironment(getEnvironment()) - defer { ARTClientOptions.setDefaultEnvironment(nil) } + ClientOptions.setDefaultEnvironment(getEnvironment()) + defer { ClientOptions.setDefaultEnvironment(nil) } - let client = ARTRest(token: try getTestToken(for: test)) + let client = Rest(token: try getTestToken(for: test)) let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) expect(publishTask.error).toEventually(beNil(), timeout: testTimeout) } @@ -209,7 +209,7 @@ class RestClientTests: XCTestCase { func test__019__RestClient__initializer__should_accept_an_options_object() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) @@ -219,7 +219,7 @@ class RestClientTests: XCTestCase { func test__020__RestClient__initializer__should_accept_an_options_object_with_token_authentication() throws { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) - let client = ARTRest(options: options) + let client = Rest(options: options) let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName()) @@ -230,7 +230,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = "invalid_token" - let client = ARTRest(options: options) + let client = Rest(options: options) let publishTask = publishTestMessage(client, channelName: test.uniqueChannelName(), failOnError: false) @@ -239,23 +239,23 @@ class RestClientTests: XCTestCase { // RSC2 func test__022__RestClient__logging__should_output_to_the_system_log_and_the_log_level_should_be_Warn() { - ARTClientOptions.setDefaultEnvironment(getEnvironment()) + ClientOptions.setDefaultEnvironment(getEnvironment()) defer { - ARTClientOptions.setDefaultEnvironment(nil) + ClientOptions.setDefaultEnvironment(nil) } - let options = ARTClientOptions(key: "xxxx:xxxx") - options.logHandler = ARTLog(capturingOutput: true) - let client = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + options.logHandler = Log(capturingOutput: true) + let client = Rest(options: options) client.internal.logger_onlyForUseInClassMethodsAndTests.log("This is a warning", with: .warn, file: "foo.m", line: 10) - XCTAssertEqual(client.internal.logger_onlyForUseInClassMethodsAndTests.logLevel, ARTLogLevel.warn) + XCTAssertEqual(client.internal.logger_onlyForUseInClassMethodsAndTests.logLevel, LogLevel.warn) guard let line = options.logHandler.captured.last else { fail("didn't log line.") return } - XCTAssertEqual(line.level, ARTLogLevel.warn) + XCTAssertEqual(line.level, LogLevel.warn) XCTAssertEqual(line.toString(), "WARN: (foo.m:10) This is a warning") } @@ -263,8 +263,8 @@ class RestClientTests: XCTestCase { func test__023__RestClient__logging__should_have_a_mutable_log_level() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - options.logHandler = ARTLog(capturingOutput: true) - let client = ARTRest(options: options) + options.logHandler = Log(capturingOutput: true) + let client = Rest(options: options) client.internal.logger_onlyForUseInClassMethodsAndTests.logLevel = .error let logTime = NSDate() @@ -278,25 +278,31 @@ class RestClientTests: XCTestCase { func test__024__RestClient__logging__should_accept_a_custom_logger() throws { let test = Test() - enum Log { - static var interceptedLog: (String, ARTLogLevel) = ("", .none) + enum InterceptedLogger { + static var interceptedLog: (String, LogLevel) = ("", .none) } - class MyLogger: ARTLog { - override func log(_ message: String, with level: ARTLogLevel) { - Log.interceptedLog = (message, level) + + class MyLogger: Log { + + override func log(_ message: String, with level: LogLevel) { + // Default implementation or can be abstract + InterceptedLogger.interceptedLog = (message, level) } - } + + static var interceptedLog: (String, LogLevel) = ("", .none) + } + let options = try AblyTests.commonAppSetup(for: test) let customLogger = MyLogger() options.logHandler = customLogger options.logLevel = .verbose - let client = ARTRest(options: options) + let client = Rest(options: options) client.internal.logger_onlyForUseInClassMethodsAndTests.log("This is a warning", with: .warn, file: "foo.m", line: 10) - XCTAssertEqual(Log.interceptedLog.0, "(foo.m:10) This is a warning") - XCTAssertEqual(Log.interceptedLog.1, ARTLogLevel.warn) + XCTAssertEqual(MyLogger.interceptedLog.0, "(foo.m:10) This is a warning") + XCTAssertEqual(MyLogger.interceptedLog.1, LogLevel.warn) XCTAssertEqual(client.internal.logger_onlyForUseInClassMethodsAndTests.logLevel, customLogger.logLevel) } @@ -306,9 +312,9 @@ class RestClientTests: XCTestCase { // RSC11a func test__025__RestClient__endpoint__should_accept_a_custom_host_and_send_requests_to_the_specified_host() { let test = Test() - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.restHost = "fake.ably.io" - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -319,10 +325,10 @@ class RestClientTests: XCTestCase { func test__026__RestClient__endpoint__should_ignore_an_environment_when_restHost_is_customized() { let test = Test() - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.environment = "test" options.restHost = "fake.ably.io" - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -334,9 +340,9 @@ class RestClientTests: XCTestCase { // RSC11b func test__027__RestClient__endpoint__should_accept_an_environment_when_restHost_is_left_unchanged() { let test = Test() - let options = ARTClientOptions(key: "fake:key") + let options = ClientOptions(key: "fake:key") options.environment = "myEnvironment" - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -347,8 +353,8 @@ class RestClientTests: XCTestCase { func test__028__RestClient__endpoint__should_default_to_https___rest_ably_io() { let test = Test() - let options = ARTClientOptions(key: "fake:key") - let client = ARTRest(options: options) + let options = ClientOptions(key: "fake:key") + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -361,7 +367,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test, requestToken: true) options.tls = false - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -372,22 +378,22 @@ class RestClientTests: XCTestCase { // RSC11b func test__030__RestClient__endpoint__should_not_prepend_the_environment_if_environment_is_configured_as__production_() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "production" - let client = ARTRest(options: options) - XCTAssertEqual(client.internal.options.restHost, ARTDefault.restHost()) - XCTAssertEqual(client.internal.options.realtimeHost, ARTDefault.realtimeHost()) + let client = Rest(options: options) + XCTAssertEqual(client.internal.options.restHost, Default.restHost()) + XCTAssertEqual(client.internal.options.realtimeHost, Default.realtimeHost()) } // RSC13 func test__031__RestClient__should_use_the_the_connection_and_request_timeouts_specified__timeout_for_any_single_HTTP_request_and_response() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.restHost = "10.255.255.1" // non-routable IP address XCTAssertEqual(options.httpRequestTimeout, 10.0) // Seconds options.httpRequestTimeout = 1.0 - let client = ARTRest(options: options) + let client = Rest(options: options) let channel = client.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in let start = NSDate() @@ -405,10 +411,10 @@ class RestClientTests: XCTestCase { func test__032__RestClient__should_use_the_the_connection_and_request_timeouts_specified__max_number_of_fallback_hosts() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") XCTAssertEqual(options.httpMaxRetryCount, 3) options.httpMaxRetryCount = 1 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -433,10 +439,10 @@ class RestClientTests: XCTestCase { func test__033__RestClient__should_use_the_the_connection_and_request_timeouts_specified__max_elapsed_time_in_which_fallback_host_retries_for_HTTP_requests_will_be_attempted() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") XCTAssertEqual(options.httpMaxRetryDuration, 15.0) // Seconds options.httpMaxRetryDuration = 1.0 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -457,7 +463,7 @@ class RestClientTests: XCTestCase { func test__002__RestClient__should_provide_access_to_the_AuthOptions_object_passed_in_ClientOptions() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) let authOptions = client.auth.internal.options @@ -467,11 +473,11 @@ class RestClientTests: XCTestCase { // RSC12 func test__003__RestClient__REST_endpoint_host_should_be_configurable_in_the_Client_constructor_with_the_option_restHost() throws { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") XCTAssertEqual(options.restHost, "rest.ably.io") options.restHost = "rest.ably.test" XCTAssertEqual(options.restHost, "rest.ably.test") - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in @@ -491,7 +497,7 @@ class RestClientTests: XCTestCase { func test__034__RestClient__time__should_return_server_time() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) var time: NSDate? @@ -507,7 +513,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let clientHttps = ARTRest(options: options) + let clientHttps = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) clientHttps.internal.httpExecutor = testHTTPExecutor @@ -526,7 +532,7 @@ class RestClientTests: XCTestCase { options.clientId = "client_http" options.useTokenAuth = true options.tls = false - let clientHttp = ARTRest(options: options) + let clientHttp = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) clientHttp.internal.httpExecutor = testHTTPExecutor @@ -550,8 +556,8 @@ class RestClientTests: XCTestCase { completion(testTokenDetails, nil) } - let client = ARTRest(options: options) - expect(client.auth).to(beAnInstanceOf(ARTAuth.self)) + let client = Rest(options: options) + expect(client.auth).to(beAnInstanceOf(Auth.self)) waitUntil(timeout: testTimeout) { done in client.auth.authorize(nil, options: nil) { tokenDetails, error in @@ -576,7 +582,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.token = try getTestToken(for: test, ttl: 0.5) - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor let auth = client.auth @@ -606,7 +612,7 @@ class RestClientTests: XCTestCase { let test = Test() let options = try AblyTests.clientOptions(for: test) options.token = try getTestToken(for: test, capability: "{ \"main\":[\"subscribe\"] }") - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor @@ -638,11 +644,11 @@ class RestClientTests: XCTestCase { guard let components = options.key?.components(separatedBy: ":"), let keyName = components.first, let keySecret = components.last else { fail("Invalid API key: \(options.key ?? "nil")"); return } - ARTClientOptions.setDefaultEnvironment(getEnvironment()) + ClientOptions.setDefaultEnvironment(getEnvironment()) defer { - ARTClientOptions.setDefaultEnvironment(nil) + ClientOptions.setDefaultEnvironment(nil) } - let rest = ARTRest(key: "\(keyName):\(keySecret)") + let rest = Rest(key: "\(keyName):\(keySecret)") waitUntil(timeout: testTimeout) { done in rest.channels.get(test.uniqueChannelName()).publish(nil, data: "testing") { error in XCTAssertNil(error) @@ -654,7 +660,7 @@ class RestClientTests: XCTestCase { // RSC14b func test__038__RestClient__Authentication__basic_authentication_flag__should_be_true_when_initialized_with_a_key() { - let client = ARTRest(key: "key:secret") + let client = Rest(key: "key:secret") XCTAssertTrue(client.auth.internal.options.isBasicAuth()) } @@ -685,14 +691,14 @@ class RestClientTests: XCTestCase { // RSC14c func test__036__RestClient__Authentication__should_error_when_expired_token_and_no_means_to_renew() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let auth = client.auth let tokenParams = ARTTokenParams() let tokenTtl = 3.0 tokenParams.ttl = NSNumber(value: tokenTtl) // Seconds - let options: ARTClientOptions = try AblyTests.waitFor(timeout: testTimeout) { value in + let options: ClientOptions = try AblyTests.waitFor(timeout: testTimeout) { value in auth.requestToken(tokenParams, with: nil) { tokenDetails, error in if let e = error { XCTFail(e.localizedDescription) @@ -706,7 +712,7 @@ class RestClientTests: XCTestCase { return } - let options: ARTClientOptions + let options: ClientOptions do { options = try AblyTests.clientOptions(for: test) } catch { @@ -730,7 +736,7 @@ class RestClientTests: XCTestCase { } } - let rest = ARTRest(options: options) + let rest = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -755,7 +761,7 @@ class RestClientTests: XCTestCase { // RSC14d func test__037__RestClient__Authentication__should_renew_the_token_when_it_has_expired() throws { let test = Test() - let client = ARTRest(options: try AblyTests.commonAppSetup(for: test)) + let client = Rest(options: try AblyTests.commonAppSetup(for: test)) let auth = client.auth let tokenParams = ARTTokenParams() @@ -776,7 +782,7 @@ class RestClientTests: XCTestCase { return } - let options: ARTClientOptions + let options: ClientOptions do { options = try AblyTests.clientOptions(for: test) } catch { @@ -795,7 +801,7 @@ class RestClientTests: XCTestCase { clientId: currentTokenDetails.clientId ) - let rest = ARTRest(options: options) + let rest = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor @@ -822,13 +828,13 @@ class RestClientTests: XCTestCase { // TO3k7 - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__051__RestClient__Host_Fallback__fallbackHostsUseDefault_option__allows_the_default_fallback_hosts_to_be_used_when__environment__is_not_production() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "not-production" options.fallbackHostsUseDefault = true - let client = ARTRest(options: options) + let client = Rest(options: options) XCTAssertTrue(client.internal.options.fallbackHostsUseDefault) // Not production XCTAssertNotNil(client.internal.options.environment) @@ -836,44 +842,44 @@ class RestClientTests: XCTestCase { let hosts = ARTFallbackHosts.hosts(from: client.internal.options) let fallback = ARTFallback(fallbackHosts: hosts, shuffleArray: ARTFallback_shuffleArray) - XCTAssertEqual(fallback.hosts.count, ARTDefault.fallbackHosts().count) + XCTAssertEqual(fallback.hosts.count, Default.fallbackHosts().count) - ARTDefault.fallbackHosts().forEach { + Default.fallbackHosts().forEach { expect(fallback.hosts).to(contain($0)) } } - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__052__RestClient__Host_Fallback__fallbackHostsUseDefault_option__allows_the_default_fallback_hosts_to_be_used_when_a_custom_Realtime_or_REST_host_endpoint_is_being_used() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.restHost = "fake1.ably.io" options.realtimeHost = "fake2.ably.io" options.fallbackHostsUseDefault = true - let client = ARTRest(options: options) + let client = Rest(options: options) XCTAssertTrue(client.internal.options.fallbackHostsUseDefault) // Custom - XCTAssertNotEqual(client.internal.options.restHost, ARTDefault.restHost()) - XCTAssertNotEqual(client.internal.options.realtimeHost, ARTDefault.realtimeHost()) + XCTAssertNotEqual(client.internal.options.restHost, Default.restHost()) + XCTAssertNotEqual(client.internal.options.realtimeHost, Default.realtimeHost()) let hosts = ARTFallbackHosts.hosts(from: client.internal.options) let fallback = ARTFallback(fallbackHosts: hosts, shuffleArray: ARTFallback_shuffleArray) - XCTAssertEqual(fallback.hosts.count, ARTDefault.fallbackHosts().count) + XCTAssertEqual(fallback.hosts.count, Default.fallbackHosts().count) - ARTDefault.fallbackHosts().forEach { + Default.fallbackHosts().forEach { expect(fallback.hosts).to(contain($0)) } } - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__053__RestClient__Host_Fallback__fallbackHostsUseDefault_option__should_be_inactive_by_default() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") XCTAssertFalse(options.fallbackHostsUseDefault) } - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__054__RestClient__Host_Fallback__fallbackHostsUseDefault_option__should_never_accept_to_configure__fallbackHost__and_set__fallbackHostsUseDefault__to__true_() { - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") XCTAssertNil(options.fallbackHosts) XCTAssertFalse(options.fallbackHostsUseDefault) @@ -893,8 +899,8 @@ class RestClientTests: XCTestCase { // RSC15b1 func test__055__RestClient__Host_Fallback__Fallback_behavior__should_be_applied_when_restHost__port_and_tlsPort_has_not_been_set_to_an_explicit_value() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") - let client = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -920,9 +926,9 @@ class RestClientTests: XCTestCase { // RSC15b1 func test__056__RestClient__Host_Fallback__Fallback_behavior__should_NOT_be_applied_when_ClientOptions_restHost_has_been_set() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.restHost = "fake.ably.io" - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -946,10 +952,10 @@ class RestClientTests: XCTestCase { // RSC15b1 func test__057__RestClient__Host_Fallback__Fallback_behavior__should_NOT_be_applied_when_ClientOptions_port_has_been_set() { let test = Test() - let options = ARTClientOptions(token: "xxxx") + let options = ClientOptions(token: "xxxx") options.tls = false options.port = 999 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -973,9 +979,9 @@ class RestClientTests: XCTestCase { // RSC15b1 func test__058__RestClient__Host_Fallback__Fallback_behavior__should_NOT_be_applied_when_ClientOptions_tlsPort_has_been_set() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.tlsPort = 999 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -999,9 +1005,9 @@ class RestClientTests: XCTestCase { // RSC15b2 func test__059__RestClient__Host_Fallback__Fallback_behavior__should_be_applied_when_ClientOptions_fallbackHosts_is_provided() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackHosts = ["a.cocoa.ably", "b.cocoa.ably"] - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1024,12 +1030,12 @@ class RestClientTests: XCTestCase { } // RSC15b3, RSC15g4 - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__060__RestClient__Host_Fallback__Fallback_behavior__should_be_applied_when_ClientOptions_fallbackHosts_is_not_provided_and_deprecated_fallbackHostsUseDefault_is_on() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackHostsUseDefault = true - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1054,9 +1060,9 @@ class RestClientTests: XCTestCase { // RSC15k func test__045__RestClient__Host_Fallback__failing_HTTP_requests_with_custom_endpoint_should_result_in_an_error_immediately() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.restHost = "fake.ably.io" - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1077,9 +1083,9 @@ class RestClientTests: XCTestCase { // RSC15g1 func test__061__RestClient__Host_Fallback__fallback_hosts_list_and_priorities__should_use_ClientOptions_fallbackHosts_when_list_is_provided() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackHosts = ["f.ably-realtime.com"] - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1103,9 +1109,9 @@ class RestClientTests: XCTestCase { // RSC15g2 func test__062__RestClient__Host_Fallback__fallback_hosts_list_and_priorities__should_use_environment_fallback_hosts_when_ClientOptions_environment_is_set_to_a_value_other_than__production__and_ClientOptions_fallbackHosts_is_not_set() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "test" - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1130,9 +1136,9 @@ class RestClientTests: XCTestCase { // RSC15g2 func test__063__RestClient__Host_Fallback__fallback_hosts_list_and_priorities__should_NOT_use_environment_fallback_hosts_when_ClientOptions_environment_is_set_to__production_() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "production" - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1158,9 +1164,9 @@ class RestClientTests: XCTestCase { // RSC15g3 func test__064__RestClient__Host_Fallback__fallback_hosts_list_and_priorities__should_use_default_fallback_hosts_when_both_ClientOptions_fallbackHosts_and_ClientOptions_environment_are_not_set() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "" - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1184,13 +1190,13 @@ class RestClientTests: XCTestCase { } // RSC15g4 - @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ARTClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") + @available(*, deprecated, message: "This test is marked as deprecated so as to not trigger a compiler warning for using the -ClientOptions.fallbackHostsUseDefault property. Remove this deprecation when removing the property.") func test__046__RestClient__Host_Fallback__applies_when_ClientOptions_fallbackHostsUseDefault_is_true() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.environment = "test" options.fallbackHostsUseDefault = true - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1213,9 +1219,9 @@ class RestClientTests: XCTestCase { // RSC15g1 func test__047__RestClient__Host_Fallback__won_t_apply_fallback_hosts_if_ClientOptions_fallbackHosts_array_is_empty() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackHosts = [] // to test TO3k6 - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1237,9 +1243,9 @@ class RestClientTests: XCTestCase { // RSC15g3 func test__048__RestClient__Host_Fallback__won_t_apply_custom_fallback_hosts_if_ClientOptions_fallbackHosts_and_ClientOptions_environment_are_not_set__use_defaults_instead() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.fallbackHosts = nil - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1265,10 +1271,10 @@ class RestClientTests: XCTestCase { // RSC15e func test__049__RestClient__Host_Fallback__every_new_HTTP_request_is_first_attempted_to_the_default_primary_host_rest_ably_io() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 1 options.fallbackRetryTimeout = 1 // RSC15j exception - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1292,16 +1298,16 @@ class RestClientTests: XCTestCase { } XCTAssertEqual(testHTTPExecutor.requests.count, 3) - XCTAssertTrue(NSRegularExpression.match(testHTTPExecutor.requests.at(0)?.url?.absoluteString, pattern: "//\(ARTDefault.restHost())")) + XCTAssertTrue(NSRegularExpression.match(testHTTPExecutor.requests.at(0)?.url?.absoluteString, pattern: "//\(Default.restHost())")) XCTAssertTrue(NSRegularExpression.match(testHTTPExecutor.requests.at(1)?.url?.absoluteString, pattern: "//[a-e].ably-realtime.com")) - XCTAssertTrue(NSRegularExpression.match(testHTTPExecutor.requests.at(2)?.url?.absoluteString, pattern: "//\(ARTDefault.restHost())")) + XCTAssertTrue(NSRegularExpression.match(testHTTPExecutor.requests.at(2)?.url?.absoluteString, pattern: "//\(Default.restHost())")) } // RSC15a // RSC15h func test__065__RestClient__Host_Fallback__retry_hosts_in_random_order__default_fallback_hosts_should_match__a_e__ably_realtime_com() { - let defaultFallbackHosts = ARTDefault.fallbackHosts() + let defaultFallbackHosts = Default.fallbackHosts() defaultFallbackHosts.forEach { host in expect(host).to(match("[a-e].ably-realtime.com")) } @@ -1310,7 +1316,7 @@ class RestClientTests: XCTestCase { // RSC15i func test__066__RestClient__Host_Fallback__retry_hosts_in_random_order__environment_fallback_hosts_have_the_format__environment___a_e__fallback_ably_realtime_com() { - let environmentFallbackHosts = ARTDefault.fallbackHosts(withEnvironment: "sandbox") + let environmentFallbackHosts = Default.fallbackHosts(withEnvironment: "sandbox") environmentFallbackHosts.forEach { host in expect(host).to(match("sandbox-[a-e]-fallback.ably-realtime.com")) } @@ -1319,9 +1325,9 @@ class RestClientTests: XCTestCase { func test__067__RestClient__Host_Fallback__retry_hosts_in_random_order__until_httpMaxRetryCount_has_been_reached() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder - let client = ARTRest(options: options) + let client = Rest(options: options) options.httpMaxRetryCount = 3 let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) @@ -1342,14 +1348,14 @@ class RestClientTests: XCTestCase { NSRegularExpression.extract(request.url!.absoluteString, pattern: "[a-e].ably-realtime.com") } let resultFallbackHosts = testHTTPExecutor.requests.compactMap(extractHostname) - let expectedFallbackHosts = Array(expectedHostOrder.map { ARTDefault.fallbackHosts()[$0] }[0 ..< Int(options.httpMaxRetryCount)]) + let expectedFallbackHosts = Array(expectedHostOrder.map { Default.fallbackHosts()[$0] }[0 ..< Int(options.httpMaxRetryCount)]) XCTAssertEqual(resultFallbackHosts, expectedFallbackHosts) } func test__068__RestClient__Host_Fallback__retry_hosts_in_random_order__use_custom_fallback_hosts_if_set() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 10 let customFallbackHosts = ["j.ably-realtime.com", "i.ably-realtime.com", @@ -1358,7 +1364,7 @@ class RestClientTests: XCTestCase { "f.ably-realtime.com"] options.fallbackHosts = customFallbackHosts options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1385,10 +1391,10 @@ class RestClientTests: XCTestCase { func test__069__RestClient__Host_Fallback__retry_hosts_in_random_order__until_all_fallback_hosts_have_been_tried() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 10 options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1402,25 +1408,25 @@ class RestClientTests: XCTestCase { } } - XCTAssertEqual(testHTTPExecutor.requests.count, ARTDefault.fallbackHosts().count + 1) + XCTAssertEqual(testHTTPExecutor.requests.count, Default.fallbackHosts().count + 1) let extractHostname = { (request: URLRequest) in NSRegularExpression.extract(request.url!.absoluteString, pattern: "[a-e].ably-realtime.com") } let resultFallbackHosts = testHTTPExecutor.requests.compactMap(extractHostname) - let expectedFallbackHosts = expectedHostOrder.map { ARTDefault.fallbackHosts()[$0] } + let expectedFallbackHosts = expectedHostOrder.map { Default.fallbackHosts()[$0] } XCTAssertEqual(resultFallbackHosts, expectedFallbackHosts) } func test__070__RestClient__Host_Fallback__retry_hosts_in_random_order__until_httpMaxRetryCount_has_been_reached__if_custom_fallback_hosts_are_provided_in_ClientOptions_fallbackHosts__then_they_will_be_used_instead() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 4 options.fallbackHosts = _fallbackHosts options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1448,12 +1454,12 @@ class RestClientTests: XCTestCase { func test__071__RestClient__Host_Fallback__retry_hosts_in_random_order__until_all_fallback_hosts_have_been_tried__if_custom_fallback_hosts_are_provided_in_ClientOptions_fallbackHosts__then_they_will_be_used_instead() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 10 options.fallbackHosts = _fallbackHosts options.testOptions.shuffleArray = shuffleArrayInExpectedHostOrder - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1467,7 +1473,7 @@ class RestClientTests: XCTestCase { } } - XCTAssertEqual(testHTTPExecutor.requests.count, ARTDefault.fallbackHosts().count + 1) + XCTAssertEqual(testHTTPExecutor.requests.count, Default.fallbackHosts().count + 1) let extractHostname = { (request: URLRequest) in NSRegularExpression.extract(request.url!.absoluteString, pattern: "[f-j].ably-realtime.com") @@ -1481,11 +1487,11 @@ class RestClientTests: XCTestCase { func test__072__RestClient__Host_Fallback__retry_hosts_in_random_order__all_fallback_requests_headers_should_contain__Host__header_with_fallback_host_address() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 10 options.fallbackHosts = _fallbackHosts - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1499,7 +1505,7 @@ class RestClientTests: XCTestCase { } } - XCTAssertEqual(testHTTPExecutor.requests.count, ARTDefault.fallbackHosts().count + 1) + XCTAssertEqual(testHTTPExecutor.requests.count, Default.fallbackHosts().count + 1) let fallbackRequests = testHTTPExecutor.requests.filter { NSRegularExpression.match($0.url!.absoluteString, pattern: "[f-j].ably-realtime.com") @@ -1514,11 +1520,11 @@ class RestClientTests: XCTestCase { func test__073__RestClient__Host_Fallback__retry_hosts_in_random_order__if_an_empty_array_of_fallback_hosts_is_provided__then_fallback_host_functionality_is_disabled() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 5 options.fallbackHosts = [] - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1556,8 +1562,8 @@ class RestClientTests: XCTestCase { // RSC15d func test__050__RestClient__Host_Fallback__should_not_use_an_alternative_host_when_the_client_receives_an_bad_request() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") - let client = ARTRest(options: options) + let options = ClientOptions(key: "xxxx:xxxx") + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -1628,7 +1634,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) XCTAssertTrue(options.useBinaryProtocol) - let rest = ARTRest(options: options) + let rest = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in @@ -1666,7 +1672,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) options.useBinaryProtocol = false - let rest = ARTRest(options: options) + let rest = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in @@ -1700,7 +1706,7 @@ class RestClientTests: XCTestCase { func test__010__RestClient__X_Ably_Version_must_be_included_in_all_REST_requests() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor waitUntil(timeout: testTimeout) { done in @@ -1711,7 +1717,7 @@ class RestClientTests: XCTestCase { return } - // This test should not directly validate version against ARTDefault.version(), as + // This test should not directly validate version against Default.version(), as // ultimately the version header has been derived from that value. XCTAssertEqual(headerAblyVersion, "2") @@ -1726,7 +1732,7 @@ class RestClientTests: XCTestCase { func test__011__RestClient__The_Agent_library_identifier_is_composed_of_a_series_of_key__value__entries_joined_by_spaces() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let client = ARTRest(options: options) + let client = Rest(options: options) testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) client.internal.httpExecutor = testHTTPExecutor let channel = client.channels.get(test.uniqueChannelName()) @@ -1748,7 +1754,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.clientOptions(for: test) let tokenTtl = 0.1 options.token = try getTestToken(for: test, ttl: tokenTtl) - let client = ARTRest(options: options) + let client = Rest(options: options) waitUntil(timeout: testTimeout) { done in delay(tokenTtl + AblyTests.tokenExpiryTolerance) { client.channels.get(test.uniqueChannelName()).publish(nil, data: "message") { error in @@ -1756,7 +1762,7 @@ class RestClientTests: XCTestCase { fail("Error is empty"); done() return } - XCTAssertEqual(error.code, Int(ARTState.requestTokenFailed.rawValue)) + XCTAssertEqual(error.code, Int(State.requestTokenFailed.rawValue)) expect(error.message).to(contain("no means to renew the token is provided")) done() } @@ -1770,7 +1776,7 @@ class RestClientTests: XCTestCase { let options = try AblyTests.commonAppSetup(for: test) waitUntil(timeout: testTimeout) { done in URLSession.shared.dataTask(with: URL(string: "https://ably.io")!) { _, _, _ in - let rest = ARTRest(options: options) + let rest = Rest(options: options) rest.channels.get(test.uniqueChannelName()).history { _, _ in done() } @@ -1782,13 +1788,13 @@ class RestClientTests: XCTestCase { func test__014__RestClient__client_should_handle_error_messages_in_plaintext_and_HTML_format() { let request = URLRequest(url: URL(string: "https://www.example.com")!) waitUntil(timeout: testTimeout) { done in - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") rest.internal.execute(request, completion: { response, _, error in guard let contentType = response?.allHeaderFields["Content-Type"] as? String else { fail("Response should have a Content-Type"); done(); return } expect(contentType).to(contain("text/html")) - guard let error = error as? ARTErrorInfo else { + guard let error = error as? ErrorInfo else { fail("Error is nil"); done(); return } XCTAssertEqual(error.statusCode, 200) @@ -1803,7 +1809,7 @@ class RestClientTests: XCTestCase { // RSC19a func test__086__RestClient__request__method_signature_and_arguments__should_add_query_parameters() throws { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let params = ["foo": "1"] @@ -1831,7 +1837,7 @@ class RestClientTests: XCTestCase { } func test__087__RestClient__request__method_signature_and_arguments__should_add_a_HTTP_body() throws { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let bodyDict = ["blockchain": true] @@ -1858,7 +1864,7 @@ class RestClientTests: XCTestCase { } func test__088__RestClient__request__method_signature_and_arguments__should_add_a_HTTP_header() throws { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor let headers = ["X-foo": "ok"] @@ -1883,7 +1889,7 @@ class RestClientTests: XCTestCase { } func test__089__RestClient__request__method_signature_and_arguments__should_error_if_method_is_invalid() { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -1892,7 +1898,7 @@ class RestClientTests: XCTestCase { fail("Completion closure should not be called") } } catch let error as NSError { - XCTAssertEqual(error.code, ARTCustomRequestError.invalidMethod.rawValue) + XCTAssertEqual(error.code, CustomRequestError.invalidMethod.rawValue) expect(error.localizedDescription).to(contain("Method isn't valid")) } @@ -1901,13 +1907,13 @@ class RestClientTests: XCTestCase { fail("Completion closure should not be called") } } catch let error as NSError { - XCTAssertEqual(error.code, ARTCustomRequestError.invalidMethod.rawValue) + XCTAssertEqual(error.code, CustomRequestError.invalidMethod.rawValue) expect(error.localizedDescription).to(contain("Method isn't valid")) } } func test__090__RestClient__request__method_signature_and_arguments__should_error_if_path_is_invalid() { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHTTPExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHTTPExecutor @@ -1916,13 +1922,13 @@ class RestClientTests: XCTestCase { fail("Completion closure should not be called") } } catch let error as NSError { - XCTAssertEqual(error.code, ARTCustomRequestError.invalidPath.rawValue) + XCTAssertEqual(error.code, CustomRequestError.invalidPath.rawValue) expect(error.localizedDescription).to(contain("Path cannot be empty")) } } func test__091__RestClient__request__method_signature_and_arguments__should_error_if_body_is_not_a_Dictionary_or_an_Array() { - let rest = ARTRest(key: "xxxx:xxxx") + let rest = Rest(key: "xxxx:xxxx") let mockHttpExecutor = MockHTTPExecutor() rest.internal.httpExecutor = mockHttpExecutor @@ -1931,7 +1937,7 @@ class RestClientTests: XCTestCase { fail("Completion closure should not be called") } } catch let error as NSError { - XCTAssertEqual(error.code, ARTCustomRequestError.invalidBody.rawValue) + XCTAssertEqual(error.code, CustomRequestError.invalidBody.rawValue) expect(error.localizedDescription).to(contain("should be a Dictionary or an Array")) } } @@ -1939,7 +1945,7 @@ class RestClientTests: XCTestCase { func test__092__RestClient__request__method_signature_and_arguments__should_do_a_request_and_receive_a_valid_response() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("a", data: nil) { error in @@ -1951,7 +1957,7 @@ class RestClientTests: XCTestCase { let proxyHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = proxyHTTPExecutor - var httpPaginatedResponse: ARTHTTPPaginatedResponse! + var httpPaginatedResponse: HTTPPaginatedResponse! waitUntil(timeout: testTimeout) { done in do { try rest.request("get", path: "/channels/\(channel.name)", params: nil, body: nil, headers: nil) { paginatedResponse, error in @@ -1989,7 +1995,7 @@ class RestClientTests: XCTestCase { func test__093__RestClient__request__method_signature_and_arguments__should_handle_response_failures() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("a", data: nil) { error in @@ -2042,7 +2048,7 @@ class RestClientTests: XCTestCase { options.authParams?.append(URLQueryItem(name: "type", value: "text")) options.authParams?.append(URLQueryItem(name: "body", value: token)) - let client = ARTRest(options: options) + let client = Rest(options: options) waitUntil(timeout: testTimeout) { done in let channel = client.channels.get(test.uniqueChannelName()) channel.publish("test", data: "test-data") { error in @@ -2063,10 +2069,10 @@ class RestClientTests: XCTestCase { func test__095__RestClient__request_IDs__should_add__request_id__query_parameter() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.addRequestIds = true - let restA = ARTRest(options: options) + let restA = Rest(options: options) let mockHttpExecutor = MockHTTPExecutor() restA.internal.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in @@ -2084,7 +2090,7 @@ class RestClientTests: XCTestCase { mockHttpExecutor.reset() options.addRequestIds = false - let restB = ARTRest(options: options) + let restB = Rest(options: options) restB.internal.httpExecutor = mockHttpExecutor waitUntil(timeout: testTimeout) { done in restB.channels.get(test.uniqueChannelName()).publish(nil, data: "something") { error in @@ -2102,12 +2108,12 @@ class RestClientTests: XCTestCase { func test__096__RestClient__request_IDs__should_remain_the_same_if_a_request_is_retried_to_a_fallback_host() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.httpMaxRetryCount = 5 options.addRequestIds = true options.logLevel = .debug - let client = ARTRest(options: options) + let client = Rest(options: options) let internalLog = InternalLog(clientOptions: options) let mockHTTP = MockHTTP(logger: internalLog) testHTTPExecutor = TestProxyHTTPExecutor(http: mockHTTP, logger: internalLog) @@ -2143,10 +2149,10 @@ class RestClientTests: XCTestCase { func test__097__RestClient__request_IDs__ErrorInfo_should_have__requestId__property() { let test = Test() - let options = ARTClientOptions(key: "xxxx:xxxx") + let options = ClientOptions(key: "xxxx:xxxx") options.addRequestIds = true - let rest = ARTRest(options: options) + let rest = Rest(options: options) let mockHttpExecutor = MockHTTPExecutor() mockHttpExecutor.simulateIncomingErrorOnNextRequest(NSError(domain: "ably-test", code: ARTErrorCode.invalidMessageDataOrEncoding.intValue, userInfo: ["Message": "Ably test message"])) rest.internal.httpExecutor = mockHttpExecutor diff --git a/Test/Tests/StatsTests.swift b/Test/Tests/StatsTests.swift index af0709101..4ff0de60d 100644 --- a/Test/Tests/StatsTests.swift +++ b/Test/Tests/StatsTests.swift @@ -4,25 +4,25 @@ import Nimble import XCTest private let encoder = ARTJsonLikeEncoder() -private let subject: ARTStatsConnectionTypes? = { +private let subject: StatsConnectionTypes? = { let data: [[String: Any]] = [ ["connections": ["tls": ["opened": 5], "all": ["peak": 10]]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats + let stats = try! encoder.decodeStats(rawData)[0] as? Stats return stats?.connections }() -private let channelsTestsSubject: ARTStatsResourceCount? = { +private let channelsTestsSubject: StatsResourceCount? = { let data: [[String: Any]] = [ ["channels": ["opened": 5, "peak": 10]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats + let stats = try! encoder.decodeStats(rawData)[0] as? Stats return stats?.channels }() -private let pushTestsSubject: ARTStatsPushCount? = { +private let pushTestsSubject: StatsPushCount? = { let data: [[String: Any]] = [ ["push": [ @@ -37,24 +37,24 @@ private let pushTestsSubject: ARTStatsPushCount? = { ] as [String : Any]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats + let stats = try! encoder.decodeStats(rawData)[0] as? Stats return stats?.pushes }() -private let inProgressTestsStats: ARTStats? = { +private let inProgressTestsStats: Stats? = { let data: [[String: Any]] = [ ["inProgress": "2004-02-01:05:06"], ] let rawData = try! JSONUtility.serialize(data) - return try! encoder.decodeStats(rawData)[0] as? ARTStats + return try! encoder.decodeStats(rawData)[0] as? Stats }() -private let countTestStats: ARTStats? = { +private let countTestStats: Stats? = { let data: [[String: Any]] = [ ["count": 55], ] let rawData = try! JSONUtility.serialize(data) - return try! encoder.decodeStats(rawData)[0] as? ARTStats + return try! encoder.decodeStats(rawData)[0] as? Stats }() class StatsTests: XCTestCase { @@ -83,13 +83,13 @@ class StatsTests: XCTestCase { [attribute: ["messages": ["count": 5], "all": ["data": 10]]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats - let subject = stats?.value(forKey: attribute) as? ARTStatsMessageTypes + let stats = try! encoder.decodeStats(rawData)[0] as? Stats + let subject = stats?.value(forKey: attribute) as? StatsMessageTypes func test__should_return_a_MessagesTypes_object() { contextBeforeEach?() - expect(subject).to(beAnInstanceOf(ARTStatsMessageTypes.self)) + expect(subject).to(beAnInstanceOf(StatsMessageTypes.self)) contextAfterEach?() } @@ -188,13 +188,13 @@ class StatsTests: XCTestCase { ]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats - let subject = stats?.value(forKey: direction) as? ARTStatsMessageTraffic + let stats = try! encoder.decodeStats(rawData)[0] as? Stats + let subject = stats?.value(forKey: direction) as? StatsMessageTraffic func test__should_return_a_MessageTraffic_object() { contextBeforeEach?() - expect(subject).to(beAnInstanceOf(ARTStatsMessageTraffic.self)) + expect(subject).to(beAnInstanceOf(StatsMessageTraffic.self)) contextAfterEach?() } @@ -262,7 +262,7 @@ class StatsTests: XCTestCase { // TS4 func test__015__Stats__connections__should_return_a_ConnectionTypes_object() { - expect(subject).to(beAnInstanceOf(ARTStatsConnectionTypes.self)) + expect(subject).to(beAnInstanceOf(StatsConnectionTypes.self)) } func test__016__Stats__connections__should_return_value_for_tls_opened_counts() { @@ -281,7 +281,7 @@ class StatsTests: XCTestCase { // TS9 func test__019__Stats__channels__should_return_a_ResourceCount_object() { - expect(channelsTestsSubject).to(beAnInstanceOf(ARTStatsResourceCount.self)) + expect(channelsTestsSubject).to(beAnInstanceOf(StatsResourceCount.self)) } func test__020__Stats__channels__should_return_value_for_opened_counts() { @@ -309,13 +309,13 @@ class StatsTests: XCTestCase { [requestType: ["succeeded": 5, "failed": 10]], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats - let subject = stats?.value(forKey: requestType) as? ARTStatsRequestCount + let stats = try! encoder.decodeStats(rawData)[0] as? Stats + let subject = stats?.value(forKey: requestType) as? StatsRequestCount func test__should_return_a_RequestCount_object() { contextBeforeEach?() - expect(subject).to(beAnInstanceOf(ARTStatsRequestCount.self)) + expect(subject).to(beAnInstanceOf(StatsRequestCount.self)) contextAfterEach?() } @@ -383,7 +383,7 @@ class StatsTests: XCTestCase { ["intervalId": "2004-02-01:05:06"], ] let rawData = try! JSONUtility.serialize(data) - let stats = try! encoder.decodeStats(rawData)[0] as? ARTStats + let stats = try! encoder.decodeStats(rawData)[0] as? Stats let dateComponents = NSDateComponents() dateComponents.year = 2004 @@ -399,7 +399,7 @@ class StatsTests: XCTestCase { } func test__030__Stats__push__should_return_a_ARTStatsPushCount_object() { - expect(pushTestsSubject).to(beAnInstanceOf(ARTStatsPushCount.self)) + expect(pushTestsSubject).to(beAnInstanceOf(StatsPushCount.self)) } func test__031__Stats__push__should_return_value_for_messages_count() { diff --git a/Test/Tests/StringifiableTests.swift b/Test/Tests/StringifiableTests.swift index 917358047..b511dfa19 100644 --- a/Test/Tests/StringifiableTests.swift +++ b/Test/Tests/StringifiableTests.swift @@ -5,7 +5,7 @@ import XCTest class StringifiableTests: XCTestCase { func test__001__Stringifiable__type_conversion__as_string() { expect( - ARTStringifiable(string: "Lorem Ipsum").stringValue + Stringifiable(string: "Lorem Ipsum").stringValue ) .to( equal("Lorem Ipsum") @@ -14,7 +14,7 @@ class StringifiableTests: XCTestCase { func test__002__Stringifiable__type_conversion__as_bool__true_() { expect { - ARTStringifiable(bool: true).stringValue + Stringifiable(bool: true).stringValue } .to( equal("true") @@ -23,7 +23,7 @@ class StringifiableTests: XCTestCase { func test__003__Stringifiable__type_conversion__as_bool__false_() { expect { - ARTStringifiable(bool: false).stringValue + Stringifiable(bool: false).stringValue } .to( equal("false") @@ -32,7 +32,7 @@ class StringifiableTests: XCTestCase { func test__004__Stringifiable__type_conversion__as_integer_that_is_not_treated_as_bool__false_() { expect { - ARTStringifiable(number: NSNumber(value: 0)).stringValue + Stringifiable(number: NSNumber(value: 0)).stringValue } .to( equal("0") @@ -41,7 +41,7 @@ class StringifiableTests: XCTestCase { func test__005__Stringifiable__type_conversion__as_integer_that_is_not_treated_as_bool__true_() { expect { - ARTStringifiable(number: NSNumber(value: 1)).stringValue + Stringifiable(number: NSNumber(value: 1)).stringValue } .to( equal("1") @@ -50,7 +50,7 @@ class StringifiableTests: XCTestCase { func test__006__Stringifiable__type_conversion__as_number__Int_() { expect { - ARTStringifiable(number: NSNumber(value: 12)).stringValue + Stringifiable(number: NSNumber(value: 12)).stringValue } .to( equal("12") @@ -59,7 +59,7 @@ class StringifiableTests: XCTestCase { func test__007__Stringifiable__type_conversion__as_number__Float_1_decimal_digit_() { expect { - ARTStringifiable(number: NSNumber(value: 0.1)).stringValue + Stringifiable(number: NSNumber(value: 0.1)).stringValue } .to( equal("0.1") @@ -68,7 +68,7 @@ class StringifiableTests: XCTestCase { func test__008__Stringifiable__type_conversion__as_number__Float_2_decimal_digits_() { expect { - ARTStringifiable(number: NSNumber(value: 0.12)).stringValue + Stringifiable(number: NSNumber(value: 0.12)).stringValue } .to( equal("0.12") @@ -77,7 +77,7 @@ class StringifiableTests: XCTestCase { func test__009__Stringifiable__type_conversion__as_number__Float_4_decimal_digits_() { expect { - ARTStringifiable(number: NSNumber(value: 0.1234)).stringValue + Stringifiable(number: NSNumber(value: 0.1234)).stringValue } .to( equal("0.1234") diff --git a/Test/Tests/UtilitiesTests.swift b/Test/Tests/UtilitiesTests.swift index ba9955c00..6798d25b9 100644 --- a/Test/Tests/UtilitiesTests.swift +++ b/Test/Tests/UtilitiesTests.swift @@ -12,8 +12,8 @@ private var receivedBar: Int? private var receivedBarOnce: Int? private var receivedAll: Int? private var receivedAllOnce: Int? -private weak var listenerFoo1: ARTEventListener? -private weak var listenerAll: ARTEventListener? +private weak var listenerFoo1: EventListener? +private weak var listenerAll: EventListener? private let data = ["test": "test"] private let extras = ["push": ["key": "value"]] private let clientId = "clientId" @@ -66,15 +66,15 @@ class UtilitiesTests: XCTestCase { func test__002__Utilities__JSON_Encoder__should_encode_a_protocol_message_that_has_invalid_data() { beforeEach__Utilities__JSON_Encoder() - let pm = ARTProtocolMessage() + let pm = ProtocolMessage() pm.action = .message pm.channel = "foo" - pm.messages = [ARTMessage(name: "status", data: NSDate(), clientId: "user")] + pm.messages = [Message(name: "status", data: NSDate(), clientId: "user")] var result: Data? expect { result = try jsonEncoder.encode(pm) }.to(throwError { error in let e = error as NSError XCTAssertEqual(e.domain, ARTAblyErrorDomain) - XCTAssertEqual(e.code, Int(ARTClientCodeError.invalidType.rawValue)) + XCTAssertEqual(e.code, Int(ClientCodeError.invalidType.rawValue)) expect(e.localizedDescription).to(contain("Invalid type in JSON write")) }) XCTAssertNil(result) @@ -109,7 +109,7 @@ class UtilitiesTests: XCTestCase { beforeEach__Utilities__JSON_Encoder() let options = try AblyTests.commonAppSetup(for: test) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } let channel = realtime.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in @@ -123,7 +123,7 @@ class UtilitiesTests: XCTestCase { } } waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: nil, data: NSDate()), ARTMessage(name: nil, data: NSDate())]) { error in + channel.publish([Message(name: nil, data: NSDate()), Message(name: nil, data: NSDate())]) { error in guard let error = error else { fail("Error shouldn't be nil"); done(); return } @@ -139,7 +139,7 @@ class UtilitiesTests: XCTestCase { beforeEach__Utilities__JSON_Encoder() let options = try AblyTests.commonAppSetup(for: test) - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } let channel = realtime.channels.get(test.uniqueChannelName()) @@ -177,7 +177,7 @@ class UtilitiesTests: XCTestCase { beforeEach__Utilities__JSON_Encoder() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let channel = rest.channels.get(test.uniqueChannelName()) waitUntil(timeout: testTimeout) { done in channel.publish("test", data: NSDate()) { error in @@ -190,7 +190,7 @@ class UtilitiesTests: XCTestCase { } } waitUntil(timeout: testTimeout) { done in - channel.publish([ARTMessage(name: nil, data: NSDate()), ARTMessage(name: nil, data: NSDate())]) { error in + channel.publish([Message(name: nil, data: NSDate()), Message(name: nil, data: NSDate())]) { error in guard let error = error else { fail("Error shouldn't be nil"); done(); return } @@ -206,7 +206,7 @@ class UtilitiesTests: XCTestCase { beforeEach__Utilities__JSON_Encoder() let options = try AblyTests.commonAppSetup(for: test) - let rest = ARTRest(options: options) + let rest = Rest(options: options) let testHTTPExecutor = TestProxyHTTPExecutor(logger: .init(clientOptions: options)) rest.internal.httpExecutor = testHTTPExecutor let channel = rest.channels.get(test.uniqueChannelName()) @@ -446,7 +446,7 @@ class UtilitiesTests: XCTestCase { let test = Test() let options = try AblyTests.commonAppSetup(for: test) options.logLevel = .verbose - let realtime = ARTRealtime(options: options) + let realtime = Realtime(options: options) defer { realtime.close() } let channel = realtime.channels.get(test.uniqueChannelName()) @@ -465,22 +465,22 @@ class UtilitiesTests: XCTestCase { } func test__022__Utilities__maxMessageSize__calculates_maxMessageSize_of_a_Message_with_name_and_data() { - let message = ARTMessage(name: "this is name", data: data) + let message = Message(name: "this is name", data: data) let expectedSize = "{\"test\":\"test\"}".count + message.name!.count XCTAssertEqual(message.messageSize(), expectedSize) } func test__023__Utilities__maxMessageSize__calculates_maxMessageSize_of_a_Message_with_name__data_and_extras() { - let message = ARTMessage(name: "this is name", data: data) - message.extras = extras as ARTJsonCompatible + let message = Message(name: "this is name", data: data) + message.extras = extras as JsonCompatible let expectedSize = "{\"test\":\"test\"}".count + "{\"push\":{\"key\":\"value\"}}".count + message.name!.count XCTAssertEqual(message.messageSize(), expectedSize) } func test__024__Utilities__maxMessageSize__calculates_maxMessageSize_of_a_Message_with_name__data__clientId_and_extras() { - let message = ARTMessage(name: "this is name", data: data) + let message = Message(name: "this is name", data: data) message.clientId = clientId - message.extras = extras as ARTJsonCompatible + message.extras = extras as JsonCompatible let expectedSize = "{\"test\":\"test\"}".count + "{\"push\":{\"key\":\"value\"}}".count + clientId.count + message.name!.count XCTAssertEqual(message.messageSize(), expectedSize) }