Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions KMSCloseCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ @implementation KMSCloseCommand

+ (KMSCloseCommand*)closeCommand
{
KMSCloseCommand* result = [[KMSCloseCommand alloc] init];

return [result autorelease];
return [[KMSCloseCommand alloc] init];
}

- (NSTimeInterval)performOnConnection:(KMSConnection*)connection server:(KMSServer*)server
Expand Down
22 changes: 3 additions & 19 deletions KMSConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ + (KMSConnection*)connectionWithSocket:(int)socket responder:(KMSResponder*)resp
{
KMSConnection* connection = [[KMSConnection alloc] initWithSocket:socket responder:responder server:server];

return [connection autorelease];
return connection;
}

- (id)initWithSocket:(int)socket responder:(KMSResponder*)responder server:(KMSServer*)server
Expand All @@ -62,8 +62,8 @@ - (id)initWithSocket:(int)socket responder:(KMSResponder*)responder server:(KMSS
CFStreamCreatePairWithSocket(NULL, socket, &readStream, &writeStream);

self.socket = socket;
self.input = [self setupStream:(NSStream*)readStream mode:InputRunMode];
self.output = [self setupStream:(NSStream*)writeStream mode:OutputRunMode];
self.input = [self setupStream:(__bridge NSInputStream*)readStream mode:InputRunMode];
self.output = [self setupStream:(__bridge NSOutputStream*)writeStream mode:OutputRunMode];

CFRelease(readStream);
CFRelease(writeStream);
Expand All @@ -75,17 +75,6 @@ - (id)initWithSocket:(int)socket responder:(KMSResponder*)responder server:(KMSS
- (void)dealloc
{
KMSAssert((_input == nil) && (_output == nil));

[_input release];
[_output release];
[_outputData release];
[_server release];

#if DEBUG
[_lastDisconnectReason release];
#endif

[super dealloc];
}

#pragma mark - Public API
Expand Down Expand Up @@ -146,8 +135,6 @@ - (void)processInput
}

[self queueCommands:commands];

[request release];
}
}

Expand Down Expand Up @@ -183,7 +170,6 @@ - (void)processNextCommand
if (count)
{
KMSCommand* command = self.commands[0];
[command retain];
[self.commands removeObjectAtIndex:0];

NSTimeInterval delay = [command performOnConnection:self server:self.server];
Expand All @@ -194,8 +180,6 @@ - (void)processNextCommand
[self processNextCommand];
});
}

[command release];
}
}

Expand Down
8 changes: 3 additions & 5 deletions KMSListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ + (KMSListener*)listenerWithPort:(NSUInteger)port connectionBlock:(ConnectionBlo
{
KMSListener* listener = [[KMSListener alloc] initWithPort:port connectionBlock:block];

return [listener autorelease];
return listener;
}

- (id)initWithPort:(NSUInteger)port connectionBlock:(ConnectionBlock)block
Expand All @@ -51,8 +51,6 @@ - (id)initWithPort:(NSUInteger)port connectionBlock:(ConnectionBlock)block
- (void)dealloc
{
KMSAssert(_listener == nil);

[super dealloc];
}

#pragma mark - Public API
Expand Down Expand Up @@ -149,7 +147,7 @@ - (void)acceptConnectionOnSocket:(int)socket

static void callbackAcceptConnection(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
KMSListener* obj = (KMSListener*)info;
KMSListener* obj = (__bridge KMSListener*)info;
KMSAssert(type == kCFSocketAcceptCallBack);
KMSAssert(obj && (obj->_listener == s));
KMSAssert(data);
Expand Down Expand Up @@ -240,7 +238,7 @@ - (BOOL)retrievePortForSocket:(int)socket

- (BOOL)makeCFSocketForSocket:(int)socket
{
CFSocketContext context = { 0, (void *) self, NULL, NULL, NULL };
CFSocketContext context = { 0, (__bridge void *) self, NULL, NULL, NULL };

KMSAssert(_listener == NULL);
_listener = CFSocketCreateWithNative(NULL, socket, kCFSocketAcceptCallBack, callbackAcceptConnection, &context);
Expand Down
2 changes: 1 addition & 1 deletion KMSPauseCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ + (KMSPauseCommand*)pauseFor:(NSTimeInterval)delay
KMSPauseCommand* result = [[KMSPauseCommand alloc] init];
result.delay = delay;

return [result autorelease];
return result;
}

- (NSTimeInterval)performOnConnection:(KMSConnection*)connection server:(KMSServer*)server
Expand Down
11 changes: 1 addition & 10 deletions KMSRegExResponder.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ + (KMSRegExResponder*)responderWithResponses:(NSArray *)responses
{
KMSRegExResponder* server = [[KMSRegExResponder alloc] initWithResponses:responses];

return [server autorelease];
return server;
}

- (id)initWithResponses:(NSArray *)responses
Expand Down Expand Up @@ -69,15 +69,6 @@ - (id)initWithResponses:(NSArray *)responses
return self;
}

- (void)dealloc
{
[_initialResponse release];
[_responses release];
[_requests release];

[super dealloc];
}

#pragma mark - Public API

- (NSArray*)responseForRequest:(NSString*)request substitutions:(NSDictionary*)substitutions
Expand Down
11 changes: 1 addition & 10 deletions KMSResponseCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ + (KMSResponseCollection*)collectionWithURL:(NSURL *)url
{
KMSResponseCollection* collection = [[KMSResponseCollection alloc] initWithURL:url];

return [collection autorelease];
return collection;
}

- (id)initWithURL:(NSURL*)url
Expand All @@ -48,22 +48,13 @@ - (id)initWithURL:(NSURL*)url
else
{
KMSLog(@"failed to load response collection with error: %@", error);
[self release];
self = nil;
}
}

return self;
}

- (void)dealloc
{
[_sets release];
[_responses release];

[super dealloc];
}

- (NSArray*)responsesWithName:(NSString*)name
{
NSMutableArray* responses = [NSMutableArray array];
Expand Down
9 changes: 1 addition & 8 deletions KMSSendDataCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ + (KMSSendDataCommand*)sendData:(NSData *)data
KMSSendDataCommand* result = [[KMSSendDataCommand alloc] init];
result.data = data;

return [result autorelease];
}

- (void)dealloc
{
[_data release];

[super dealloc];
return result;
}

- (NSTimeInterval)performOnConnection:(KMSConnection*)connection server:(KMSServer*)server
Expand Down
2 changes: 1 addition & 1 deletion KMSSendServerDataCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ + (KMSSendServerDataCommand*)sendServerData
{
KMSSendServerDataCommand* result = [[KMSSendServerDataCommand alloc] init];

return [result autorelease];
return result;
}

- (NSTimeInterval)performOnConnection:(KMSConnection*)connection server:(KMSServer*)server
Expand Down
2 changes: 1 addition & 1 deletion KMSSendStringCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2013 Karelia Software. All rights reserved.
//

#import "KMSCommand.h"
#import <MockServer/MockServer.h>

/**
Command which sends a string down the connection.
Expand Down
9 changes: 1 addition & 8 deletions KMSSendStringCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ + (KMSSendStringCommand*)sendString:(NSString *)string
KMSSendStringCommand* result = [[KMSSendStringCommand alloc] init];
result.string = string;

return [result autorelease];
}

- (void)dealloc
{
[_string release];

[super dealloc];
return result;
}

- (NSTimeInterval)performOnConnection:(KMSConnection*)connection server:(KMSServer*)server
Expand Down
2 changes: 1 addition & 1 deletion KMSServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef NS_ENUM(NSUInteger, KMSLogLevel)

@property (readonly, nonatomic) NSUInteger port;

@property (assign, nonatomic) dispatch_queue_t queue;
@property (retain, nonatomic) dispatch_queue_t queue;

/**
YES if the server is running. NO if the stop method has been called.
Expand Down
22 changes: 7 additions & 15 deletions KMSServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ + (KMSServer*)serverWithResponder:(KMSResponder*)responder
{
KMSServer* server = [[KMSServer alloc] initWithPort:0 responder:responder];

return [server autorelease];
return server;
}

+ (KMSServer*)serverWithPort:(NSUInteger)port responder:(KMSResponder*)responder
{
KMSServer* server = [[KMSServer alloc] initWithPort:port responder:responder];

return [server autorelease];
return server;
}

- (id)initWithPort:(NSUInteger)port responder:(KMSResponder*)responder
Expand All @@ -72,14 +72,15 @@ - (id)initWithPort:(NSUInteger)port responder:(KMSResponder*)responder
{
dispatch_queue_t queue = dispatch_queue_create("com.karelia.mockserver", 0);
self.queue = queue;
dispatch_queue_set_specific(queue, &queueIdentifierKey, self, NULL);
dispatch_queue_set_specific(queue, &queueIdentifierKey, (void *)CFBridgingRetain(self), NULL);

self.responder = responder;
self.connections = [NSMutableArray array];
self.transcript = [NSMutableArray array];

NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
[formatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss zzz"];
self.rfc1123DateFormatter = formatter;
Expand Down Expand Up @@ -107,16 +108,7 @@ - (id)initWithPort:(NSUInteger)port responder:(KMSResponder*)responder
- (void)dealloc
{
KMSAssert([self.connections count] == 0);
dispatch_release(_queue);
_queue = nil;

[_connections release];
[_data release];
[_dataListener release];
[_responder release];
[_transcript release];

[super dealloc];
}

#pragma mark - Public API
Expand Down Expand Up @@ -282,7 +274,7 @@ + (void)setLoggingLevel:(KMSLogLevel)level
#pragma mark - Debugging

- (BOOL)currentQueueTargetsServerQueue {
return dispatch_get_specific(&queueIdentifierKey) == self;
return dispatch_get_specific(&queueIdentifierKey) == (__bridge void *)(self);
}

@end
13 changes: 1 addition & 12 deletions KMSTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@

@implementation KMSTestCase

- (void)dealloc
{
[_password release];
[_responses release];
[_server release];
[_url release];
[_user release];

[super dealloc];
}

- (void)tearDown
{
[self cleanupServer];
Expand Down Expand Up @@ -104,7 +93,7 @@ - (NSString*)stringForRequest:(NSURLRequest*)request

[self runUntilPaused];

return [string autorelease];
return string;
}

- (void)runUntilPaused
Expand Down
9 changes: 1 addition & 8 deletions KMSTranscriptEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ + (KMSTranscriptEntry*)entryWithType:(KMSTranscriptEntryType)type value:(id)valu
entry.type = type;
entry.value = value;

return [entry autorelease];
}

- (void)dealloc
{
[_value release];

[super dealloc];
return entry;
}

- (NSString*)description
Expand Down
Loading