diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/test/Freeze/cursor/.depend | 0 | ||||
-rw-r--r-- | cpp/test/Freeze/cursor/Client.cpp | 386 | ||||
-rw-r--r-- | cpp/test/Freeze/cursor/Makefile | 33 | ||||
-rw-r--r-- | cpp/test/Freeze/cursor/cursor.dsp | 106 | ||||
-rw-r--r-- | cpp/test/Freeze/cursor/db/.dummy | 1 | ||||
-rwxr-xr-x | cpp/test/Freeze/cursor/run.py | 47 |
6 files changed, 0 insertions, 573 deletions
diff --git a/cpp/test/Freeze/cursor/.depend b/cpp/test/Freeze/cursor/.depend deleted file mode 100644 index e69de29bb2d..00000000000 --- a/cpp/test/Freeze/cursor/.depend +++ /dev/null diff --git a/cpp/test/Freeze/cursor/Client.cpp b/cpp/test/Freeze/cursor/Client.cpp deleted file mode 100644 index 39b81098b11..00000000000 --- a/cpp/test/Freeze/cursor/Client.cpp +++ /dev/null @@ -1,386 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003 -// ZeroC, Inc. -// Billerica, MA, USA -// -// All Rights Reserved. -// -// Ice is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License version 2 as published by -// the Free Software Foundation. -// -// ********************************************************************** - -#include <Freeze/Freeze.h> -#include <Ice/BasicStream.h> -#include <TestCommon.h> - -#include <algorithm> - -using namespace std; -using namespace Ice; -using namespace Freeze; - -class KeyCodec -{ -public: - - typedef char value_type; - - static Freeze::Key - write(const unsigned char& key, const IceInternal::InstancePtr& instance) - { - IceInternal::BasicStream keyStream(instance.get()); - keyStream.write(key); - return keyStream.b; - } - - static void - read(unsigned char& key, const Freeze::Key& bytes, const IceInternal::InstancePtr& instance) - { - IceInternal::BasicStream valueStream(instance.get()); - valueStream.b = bytes; - valueStream.i = valueStream.b.begin(); - valueStream.read(key); - } -}; - -class ValueCodec -{ -public: - - typedef Ice::Int value_type; - - static Freeze::Value - write(const Ice::Int& value, const IceInternal::InstancePtr& instance) - { - IceInternal::BasicStream valueStream(instance.get()); - valueStream.write(value); - return valueStream.b; - } - - static void - read(Ice::Int& value, const Freeze::Value& bytes, const IceInternal::InstancePtr& instance) - { - IceInternal::BasicStream valueStream(instance.get()); - valueStream.b = bytes; - valueStream.i = valueStream.b.begin(); - valueStream.read(value); - } -}; - -static void -addValue(const DBPtr& db, char key, int value) -{ - IceInternal::InstancePtr instance = IceInternal::getInstance(db->getCommunicator()); - - Freeze::Key k; - Freeze::Value v; - - k = KeyCodec::write(key, instance); - v = ValueCodec::write(value, instance); - - db->put(k, v); -} - -static char alphabetChars[] = "abcdefghijklmnopqrstuvwxyz"; -vector<char> alphabet(alphabetChars, alphabetChars + sizeof(alphabetChars)-1); - -static void -populateDB(const DBPtr& db) -{ - for(vector<char>::const_iterator j = alphabet.begin() ; j != alphabet.end(); ++j) - { - addValue(db, *j, static_cast<int>(j - alphabet.begin())); - } -} - -static void -readValue(const DBPtr& db, const Freeze::Key& k, const Freeze::Value& v, unsigned char& key, int& value) -{ - IceInternal::InstancePtr instance = IceInternal::getInstance(db->getCommunicator()); - - KeyCodec::read(key, k, instance); - ValueCodec::read(value, v, instance); -} - -static int -run(int argc, char* argv[], const DBEnvironmentPtr& dbEnv) -{ - DBPtr db = dbEnv->openDB("test", true); - IceInternal::InstancePtr instance = IceInternal::getInstance(db->getCommunicator()); - - // - // Populate the database with the alphabet - // - populateDB(db); - - Freeze::Key k; - Freeze::Value v; - - unsigned char key; - int value; - - DBCursorPtr cursor, clone; - vector<char>::const_iterator j; - - cout << "testing populate... "; - cursor = db->getCursor(); - j = alphabet.begin(); - try - { - do - { - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == *j && value == j - alphabet.begin()); - ++j; - } - while(cursor->next()); - } - catch(const DBNotFoundException&) - { - test(false); - } - cursor->close(); - cout << "ok" << endl; - - cout << "testing contains... "; - try - { - for(j = alphabet.begin(); j != alphabet.end(); ++j) - { - k = KeyCodec::write(*j, instance); - test(db->contains(k)); - } - } - catch(const DBException&) - { - test(false); - } - k = KeyCodec::write('0', instance); - test(!db->contains(k)); - cout << "ok" << endl; - - cout << "testing DB::getCursorAtKey... "; - k = KeyCodec::write('n', instance); - j = find(alphabet.begin(), alphabet.end(), 'n'); - cursor = db->getCursorAtKey(k); - try - { - do - { - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == *j && value == j - alphabet.begin()); - ++j; - } - while(cursor->next()); - } - catch(const DBNotFoundException&) - { - test(false); - } - cursor->close(); - cout << "ok" << endl; - - cout << "testing remove... "; - cursor = db->getCursor(); - j = alphabet.begin(); - - try - { - do - { - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == *j && value == j - alphabet.begin()); - cursor->del(); - ++j; - if(key == 'c') - break; - } - while(cursor->next()); - } - catch(const DBNotFoundException&) - { - test(false); - } - cursor->close(); - - cursor = db->getCursor(); - j = find(alphabet.begin(), alphabet.end(), 'd'); - try - { - do - { - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == *j && value == j - alphabet.begin()); - ++j; - } - while(cursor->next()); - } - catch(const DBNotFoundException&) - { - } - cursor->close(); - cout << "ok" << endl; - - // - // Get a cursor for the deleted element - this should fail. - // - cout << "testing DB::getCursorAtKey (again)... "; - try - { - k = KeyCodec::write('a', instance); - cursor = db->getCursorAtKey(k); - test(false); - } - catch(const DBNotFoundException&) - { - // Ignore - } - cout << "ok" << endl; - - cout << "testing clone... "; - cursor = db->getCursor(); - clone = cursor->clone(); - - // - // Verify both cursors point at 'd' - // - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == 'd' && value == 3); - - clone->curr(k, v); - readValue(db, k, v, key, value); - test(key == 'd' && value == 3); - - cursor->close(); - clone->close(); - - // - // Create cursor that points at 'n' - // - k = KeyCodec::write('n', instance); - cursor = db->getCursorAtKey(k); - clone = cursor->clone(); - - // - // Verify both cursors point at 'n' - // - cursor->curr(k, v); - readValue(db, k, v, key, value); - test(key == 'n' && value == 13); - - clone->curr(k, v); - readValue(db, k, v, key, value); - test(key == 'n' && value == 13); - - cursor->close(); - clone->close(); - - // - // Create cursor that points at 'n' - // - k = KeyCodec::write('n', instance); - cursor = db->getCursorAtKey(k); - cursor->curr(k, v); - cursor->next(); - readValue(db, k, v, key, value); - test(key == 'n' && value == 13); - - clone = cursor->clone(); - - // - // Verify cloned cursors are independent - // - cursor->curr(k, v); - cursor->next(); - readValue(db, k, v, key, value); - test(key == 'o' && value == 14); - - cursor->curr(k, v); - cursor->next(); - readValue(db, k, v, key, value); - test(key == 'p' && value == 15); - - clone->curr(k, v); - clone->next(); - readValue(db, k, v, key, value); - test(key == 'o' && value == 14); - - cursor->close(); - clone->close(); - - cout << "ok" << endl; - - db->close(); - return EXIT_SUCCESS; -} - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - DBEnvironmentPtr dbEnv; - string dbEnvDir = "db"; - - try - { - communicator = Ice::initialize(argc, argv); - if(argc != 1) - { - dbEnvDir = argv[1]; - dbEnvDir += "/"; - dbEnvDir += "db"; - } - dbEnv = Freeze::initialize(communicator, dbEnvDir); - status = run(argc, argv, dbEnv); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(dbEnv) - { - try - { - dbEnv->close(); - } - catch(const DBException& ex) - { - cerr << argv[0] << ": " << ex << ": " << ex.message << endl; - status = EXIT_FAILURE; - } - catch(const Exception& ex) - { - cerr << argv[0] << ": " << ex << endl; - status = EXIT_FAILURE; - } - catch(...) - { - cerr << argv[0] << ": unknown exception" << endl; - status = EXIT_FAILURE; - } - dbEnv = 0; - } - - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - return status; -} diff --git a/cpp/test/Freeze/cursor/Makefile b/cpp/test/Freeze/cursor/Makefile deleted file mode 100644 index a9f3b0b6f4b..00000000000 --- a/cpp/test/Freeze/cursor/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# ********************************************************************** -# -# Copyright (c) 2003 -# ZeroC, Inc. -# Billerica, MA, USA -# -# All Rights Reserved. -# -# Ice is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# ********************************************************************** - -top_srcdir = ../../.. - -CLIENT = client - -TARGETS = $(CLIENT) - -OBJS = Client.o - -SRCS = $(OBJS:.o=.cpp) - -include $(top_srcdir)/config/Make.rules - -CPPFLAGS := -I. -I../../include $(DB_FLAGS) $(CPPFLAGS) - -$(CLIENT): $(OBJS) - rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(OBJS) -lFreeze $(LIBS) - -include .depend diff --git a/cpp/test/Freeze/cursor/cursor.dsp b/cpp/test/Freeze/cursor/cursor.dsp deleted file mode 100644 index 0dd6f1d770f..00000000000 --- a/cpp/test/Freeze/cursor/cursor.dsp +++ /dev/null @@ -1,106 +0,0 @@ -# Microsoft Developer Studio Project File - Name="cursor" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=cursor - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "cursor.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "cursor.mak" CFG="cursor - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "cursor - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "cursor - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "cursor - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I "." /I "../../../include" /I "../../include" /D "NDEBUG" /D "_CONSOLE" /FD /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386 /out:"client.exe" /libpath:"../../../lib"
-# SUBTRACT LINK32 /debug /nodefaultlib
-
-!ELSEIF "$(CFG)" == "cursor - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../include" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /out:"client.exe" /pdbtype:sept /libpath:"../../../lib"
-# SUBTRACT LINK32 /nodefaultlib
-
-!ENDIF
-
-# Begin Target
-
-# Name "cursor - Win32 Release"
-# Name "cursor - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\Client.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/cpp/test/Freeze/cursor/db/.dummy b/cpp/test/Freeze/cursor/db/.dummy deleted file mode 100644 index 029d4b7cff2..00000000000 --- a/cpp/test/Freeze/cursor/db/.dummy +++ /dev/null @@ -1 +0,0 @@ -Dummy file, so that `cvs export' creates this otherwise empty directory. diff --git a/cpp/test/Freeze/cursor/run.py b/cpp/test/Freeze/cursor/run.py deleted file mode 100755 index eb4c6067002..00000000000 --- a/cpp/test/Freeze/cursor/run.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003 -# ZeroC, Inc. -# Billerica, MA, USA -# -# All Rights Reserved. -# -# Ice is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# ********************************************************************** - -import os, sys - -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" - -sys.path.append(os.path.join(toplevel, "config")) -import TestUtil - -name = os.path.join("Freeze", "cursor") -testdir = os.path.join(toplevel, "test", name) - -dbdir = os.path.join(testdir, "db") -TestUtil.cleanDbDir(dbdir) - -client = os.path.join(testdir, "client") - -print "starting client...", -clientPipe = os.popen(client + TestUtil.clientOptions + " " + testdir) -print "ok" - -TestUtil.printOutputFromPipe(clientPipe) - -clientStatus = clientPipe.close() - -if clientStatus: - sys.exit(1) - -sys.exit(0) |