/*!
  @header FTCreateDBTEST
  @abstract FT
 
  @availability OS X, GNUstep
  @copyright 2004, 2005 Free Software Foundation, Inc.
  
  Author: Oliver Langer

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  09.02.2005 ola     initial version
  -------------------------------------------------------------------------
  </pre>
*/
#include <FTCreateDBTEST.h>
#include <FT/FT.h>

@implementation FTCreateDBTEST

- testCreation {
  
  FTBootstrap *bootstrap;
  id <FTServer> server;
  id <FTSessionManager> sessionManager;
  id <FTSession> session;
  
  NSLog( @"FTCreateDBTEST:: Beginning...." );
  
  bootstrap = [FTBootstrap bootstrap];
  NSLog( @"Starting and initializing server process...." );
  //[bootstrap setBaseDataDir: @"." ];
  server = [[bootstrap initializeServer] retain];

  ECAssertTrue( nil != server, @"Could not start server!" );
  NSLog( @"Server started." );
  
  sessionManager = [[server sessionManager] retain];
  ECAssertTrue( nil != sessionManager, @"Could not get session manager!" );
  
  session = [[sessionManager loginAs: @"altum" withPassword: @"silentium"]
    retain ];
  ECAssertTrue( nil != session, @"Unable to log in as altum!" );
  NSLog( @"Got a valid session." );
  
  ECAssertTrue( [session conformsToProtocol:@protocol(FTAdministrationSession)],
    @"Session is NOT an administrative session!" );
  
  NSLog( @"Shutting down the server..." );
  [((id <FTAdministrationSession>) session) shutdownServer];
  
  [session close];
  
  [sessionManager release];
  [server release];
  [bootstrap release];
  NSLog( @"FTCreateDBTEST:: FINISHED!" );  
  return self;
}

@end
