mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
Simple NSConnection client/server test tools
This commit is contained in:
parent
c54a673f79
commit
802c82cf33
3 changed files with 97 additions and 0 deletions
42
Tests/base/NSConnection/Resources/Client.m
Normal file
42
Tests/base/NSConnection/Resources/Client.m
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <GNUstepBase/GSTLS.h>
|
||||||
|
|
||||||
|
@interface TestServer : NSObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (int) doIt;
|
||||||
|
@end
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
ENTER_POOL
|
||||||
|
NSSocketPortNameServer *ns = [NSSocketPortNameServer sharedInstance];
|
||||||
|
NSString *name = @"TestServer";
|
||||||
|
NSConnection *conn;
|
||||||
|
NSDistantObject *proxy;
|
||||||
|
TestServer *test;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
[NSSocketPort setOptionsForTLS: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@"9", GSTLSDebug,
|
||||||
|
nil]];
|
||||||
|
|
||||||
|
conn = [NSConnection connectionWithRegisteredName: name
|
||||||
|
host: @""
|
||||||
|
usingNameServer: ns];
|
||||||
|
proxy = [conn rootProxy];
|
||||||
|
test = (TestServer*)proxy;
|
||||||
|
result = [test doIt];
|
||||||
|
printf("Result is %d\n", result);
|
||||||
|
LEAVE_POOL
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation TestServer
|
||||||
|
- (int) doIt
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
|
@ -2,6 +2,13 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
BUNDLE_NAME=TestConnection
|
BUNDLE_NAME=TestConnection
|
||||||
TestConnection_NEEDS_GUI = NO
|
TestConnection_NEEDS_GUI = NO
|
||||||
TestConnection_OBJC_FILES=Connection.m
|
TestConnection_OBJC_FILES=Connection.m
|
||||||
|
|
||||||
|
TEST_TOOL_NAME=Client Server
|
||||||
|
Client_NEEDS_GUI = NO
|
||||||
|
Client_OBJC_FILES=Client.m
|
||||||
|
Server_NEEDS_GUI = NO
|
||||||
|
Server_OBJC_FILES=Server.m
|
||||||
|
|
||||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||||
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||||
|
|
||||||
|
|
48
Tests/base/NSConnection/Resources/Server.m
Normal file
48
Tests/base/NSConnection/Resources/Server.m
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <GNUstepBase/GSTLS.h>
|
||||||
|
|
||||||
|
@interface TestServer : NSObject
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (int) doIt;
|
||||||
|
@end
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
ENTER_POOL
|
||||||
|
NSSocketPortNameServer *ns = [NSSocketPortNameServer sharedInstance];
|
||||||
|
NSString *name = @"TestServer";
|
||||||
|
NSConnection *conn;
|
||||||
|
NSPort *port;
|
||||||
|
TestServer *test = AUTORELEASE([TestServer new]);
|
||||||
|
|
||||||
|
port = [NSSocketPort port];
|
||||||
|
[(NSSocketPort*)port setOptionsForTLS:
|
||||||
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@"9", GSTLSDebug,
|
||||||
|
nil]];
|
||||||
|
conn = [[NSConnection alloc] initWithReceivePort: port
|
||||||
|
sendPort: nil];
|
||||||
|
[conn setRootObject: test];
|
||||||
|
if ([conn registerName: name withNameServer: ns] == NO)
|
||||||
|
{
|
||||||
|
NSPort *p = [ns portForName: name onHost: @""];
|
||||||
|
|
||||||
|
DESTROY(conn);
|
||||||
|
NSLog(@"There is already a process: %@, on %@", name, p);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[NSRunLoop currentRunLoop] run];
|
||||||
|
LEAVE_POOL
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation TestServer
|
||||||
|
- (int) doIt
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in a new issue