Added trivial test

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@21739 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-09-23 11:44:33 +00:00
parent d4f8c6d2a7
commit 4ba19049b3
2 changed files with 81 additions and 0 deletions

View file

@ -145,6 +145,11 @@ Oracle_libs_BUNDLE_LIBS += -lclntsh \
Oracle_libs_PRINCIPAL_CLASS = SQLClientOracle_libs
endif
TEST_TOOL_NAME+=testWebServer
testWebServer_OBJC_FILES = testWebServer.m
testWebServer_TOOL_LIBS += -lSQLClient
testWebServer_LIB_DIRS += -L./obj
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/library.make

76
testWebServer.m Normal file
View file

@ -0,0 +1,76 @@
/**
Copyright (C) 2005 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
Date: September 2005
This file is part of the SQLClient Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Date$ $Revision$
*/
#include <Foundation/Foundation.h>
#include <GNUstepBase/GSMime.h>
#include "WebServer.h"
@interface Handler: NSObject
- (BOOL) processRequest: (GSMimeDocument*)request
response: (GSMimeDocument*)response
for: (WebServer*)http;
@end
@implementation Handler
- (BOOL) processRequest: (GSMimeDocument*)request
response: (GSMimeDocument*)response
for: (WebServer*)http
{
NSString *s;
s = [[NSString alloc] initWithData: [request rawMimeData]
encoding: NSISOLatin1StringEncoding];
[response setContent: s type: @"text/plain" name: nil];
RELEASE(s);
return YES;
}
@end
int
main()
{
CREATE_AUTORELEASE_POOL(pool);
WebServer *server;
Handler *handler;
NSUserDefaults *defs;
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
@"80", @"Port",
nil]
];
server = [WebServer new];
handler = [Handler new];
[server setDelegate: handler];
[server setPort: [defs stringForKey: @"Port"] secure: nil];
[[NSRunLoop currentRunLoop] run];
RELEASE(pool);
return 0;
}