summaryrefslogtreecommitdiffstats
path: root/servercomm/test/test_servercomm.cc
blob: 0be461089e311f7f44d4e5e84f2b91cc243551da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* This file is part of rasdaman community.
*
* Rasdaman community 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 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community 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 rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/
/**
 * SOURCE: test_servercomm.cc
 *
 * MODULE: servercomm
 *
 * COMMENTS:
 *			None
*/



#include <iostream.h>

#define __EXECUTABLE__
#define EARLY_TEMPLATE
#define DEBUG_MAIN
#define DEBUG
#include "debug.hh"
#include "template_inst.hh"

#include "raslib/rmdebug.hh"
#include "qlparser/qtscalardata.hh"

#include "servercomm/servercomm.hh"


extern char* myExecArgv0 = "";
extern int   tiling = 1;
extern unsigned long maxTransferBufferSize = 4000000;
extern int           globalOptimizationLevel = 4;
extern char*         dbSchema = 0;
extern int           noTimeOut = 0;
char	     globalConnectId[255] = {0};
bool udfEnabled = true;

RMINITGLOBALS('C');

#include <signal.h>


int checkArguments( int argc, char** argv, const char* searchText, int& optionValueIndex )
{
  int found = 0;
  int i=1;

  while( !found && i<argc )
    found = !strcmp( searchText, argv[i++] );   

  if( found && i<argc && !strchr(argv[i],'-') )
    optionValueIndex = i;
  else
    optionValueIndex = 0;
  
  return found;
}


int main( int argc, char** argv ) 
{
  strcpy(globalConnectId, "tcp:postgresql://localhost:5432/RASBASE");
  
  ServerComm server(300, 120, 7013, "rasmgr", 7001, "N1");
  ExecuteQueryRes result;

  DatabaseIf database;
  TransactionIf ta;
  AdminIf* myAdmin = AdminIf::instance();
  database.open( "RASSERVICE");
  ta.begin( &database );

  ServerComm::ClientTblElt *r = new ServerComm::ClientTblElt("testclient", 2);
    
  server.addClientTblEntry (r);

  accessControl.setServerName("NT1");
  accessControl.crunchCapability("$I1$ER.$BRASBASE$T1:3:2008:23:39:24$NNT1$D983893f406445a922cba0301bc5a85ec$K");  
  server.openDB(2, "RASBASE", "costea");
  SET_OUTPUT(TRUE);

  char *buff = new char[1000];  
  unsigned int size;
  
  QtScalarData* t;
  
  try
  {
    server.executeQuery(2, "SELECT a from RAS_COLLECTIONNAMES as a", result );
    vector<QtData*>::iterator i;
    /*    for (i=r->transferData->begin(); i!=r->transferData->end(); ++i) {
      // t = (QtScalarData*)(*i);
      // t->printStatus();
      }*/
  }
  catch ( r_Error& errorObj )
  {
    cerr << errorObj.what() << endl;
    return -1;
  }
  catch ( ... )
  {
    cerr << "Unknown exception caught in main." << endl;
    return -1;
  }  
  
  return 0;
}