int main( int argc, char * argv[] ) { Process process; Session session; Folder * folder; string name = "/cpp_folder_create"; string subname = "test"; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); session.CreateFolder( name ); folder = new Folder( session, name ); } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // Invalid arguments to tested function. try { folder->CreateFolder( "" ); cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { folder->CreateFolder( subname ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; // Internal process object not initialized try { session.Init(); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_PROCESS_NOT_INITIALIZED ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } return 0; }
int main(int argc, char* argv[]) { Process process; char* pos = NULL; pos = strrchr(argv[0],'/'); if( pos != NULL ) { pos++; log.Init(pos); } else log.Init(argv[0]); if(process.Init() == false) { cout<<"Init Process error"<<endl; return 0; } if( openDB() == false ) return 1; ////// //// LibVirtEventHandle handle; if( handle.init() == false ) { cout<<"Init LibVirtEventHandle error"<<endl; return 0; } if( handle.begin() == false ) return 0; ///////// NCHeartBeat nh; if( nh.init() == false) return 0; if( nh.begin() == false) return 0; process.Do(); return 0; }
int main() { Process process; Session session; int i, rc; psoObjectDefinition folderDef; memset( &folderDef, 0, sizeof folderDef ); folderDef.type = PSO_FOLDER; try { process.Init( "10701", "InjectErrors" ); session.Init(); session.CreateFolder( foldername ); } catch( pso::Exception exc ) { rc = exc.ErrorCode(); if ( rc == PSO_OBJECT_ALREADY_PRESENT ) { CleanupPreviousRun( session ); } else { cerr << "Init Photon failed, error = " << exc.Message() << endl; if ( rc == PSO_CONNECT_ERROR ) cerr << "Is the server running?" << endl; return 1; } } cout << " ------- Photon defects injector ------- " << endl << endl; cout << " This program will inject pseudo-random defects in a shared memory." << endl << endl; vector<myQueue> q( NUM_QUEUES, myQueue() ); vector<myMap> h( NUM_MAPS, myMap() ); vector<myLifo> l( NUM_LIFOS, myLifo() ); for ( i = 0; i < NUM_QUEUES; ++ i ) { q[i].name += ('0' + i/10 ); q[i].name += ('0' + (i%10) ); } for ( i = 0; i < NUM_MAPS; ++i ) { h[i].name += ('0' + i/10 ); h[i].name += ('0' + (i%10) ); } for ( i = 0; i < NUM_LIFOS; ++i ) { l[i].name += ('0' + i/10 ); l[i].name += ('0' + (i%10) ); } try { PopulateQueues( session, q ); PopulateHashMaps( session, h ); PopulateLifos( session, l ); } catch( pso::Exception exc ) { cerr << "Creating and populating the objects failed, error = " << exc.Message() << endl; return 1; } cout << "Queues, maps, etc. are created and populated." << endl << endl; rc = AddDefectsQueues( q ); if ( rc != 0 ) { cerr << "Adding defect to queues failed!" << endl; return 1; } cout << "All defects were added to queues." << endl << endl; rc = AddDefectsHashMaps( h ); if ( rc != 0 ) { cerr << "Adding defect to hash maps failed!" << endl; return 1; } cout << "All defects were added to hash maps." << endl << endl; rc = AddDefectsLifos( l ); if ( rc != 0 ) { cerr << "Adding defect to LIFO queues failed!" << endl; return 1; } cout << "All defects were added to LIFO queues." << endl << endl; return 0; }
int main( int argc, char * argv[] ) { Process process; Session session1, session2; FastMapEditor * editor; FastMap * hashmap; string fname = "/cpp_fastmap_get"; string hname = fname + "/test"; const char * key = "My Key"; const char * data = "My Data"; uint32_t length; char buffer[50]; psoObjectDefinition mapDef = { PSO_FAST_MAP, 0, 0, 0 }; psoKeyFieldDefinition keys = { "MyKey", PSO_KEY_VARBINARY, 20 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session1.Init(); session2.Init(); session2.CreateFolder( fname ); DataDefinition dataDefObj( session2, "cpp_fastmap_get", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); KeyDefinition keyDefObj( session2, "cpp_fastmap_get", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)&keys, sizeof(psoKeyFieldDefinition) ); session2.CreateMap( hname, mapDef, dataDefObj, keyDefObj ); session2.Commit(); hashmap = new FastMap( session1, hname ); editor = new FastMapEditor( session2, hname ); editor->Insert( key, strlen(key), data, strlen(data) ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { // No commit yet. hashmap->Get( key, strlen(key), buffer, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { editor->Close(); session2.Commit(); // Commit the editions session1.Commit(); // Refresh session1 (and hashmap) } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { hashmap->Get( NULL, strlen(key), buffer, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap->Get( key, 0, buffer, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap->Get( key, strlen(key), NULL, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap->Get( key, strlen(key), buffer, 2, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { hashmap->Get( key, strlen(key), buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( memcmp( buffer, data, 7 ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; DataDefinition * pDataDef = NULL; string name = "/cpp_datadefinition_create"; unsigned char byteData[50]; unsigned int dataLength = 50; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // Session is not initialized try { pDataDef = new DataDefinition( session, name, PSO_DEF_USER_DEFINED, byteData, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session.Init(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Wrong arguments to tested function try { pDataDef = new DataDefinition( session, "", PSO_DEF_USER_DEFINED, byteData, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { pDataDef = new DataDefinition( session, "Default", PSO_DEF_USER_DEFINED, byteData, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_ITEM_ALREADY_PRESENT ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { pDataDef = new DataDefinition( session, name, (psoDefinitionType)0, byteData, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_WRONG_OBJECT_TYPE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { pDataDef = new DataDefinition( session, name, PSO_DEF_USER_DEFINED, NULL, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { pDataDef = new DataDefinition( session, name, PSO_DEF_USER_DEFINED, byteData, 0 ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // This call should work try { pDataDef = new DataDefinition( session, name, PSO_DEF_USER_DEFINED, byteData, dataLength ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } delete pDataDef; return 0; }
int main( int argc, char * argv[] ) { Process process; Session session1, session2; Folder folder1, folder2; Queue queue1, queue2; string name = "/cpp_session_destroy"; psoObjectDefinition queueDef = { PSO_QUEUE, 0, 0, 0 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session1.Init(); session2.Init(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Non-existing object try { session1.DestroyObject( name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_OBJECT ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session1.CreateFolder( name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Destroy without a commit - should fail try { session1.DestroyObject( name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_OBJECT_IS_IN_USE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session1.Commit(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { session1.DestroyObject( "" ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { session1.DestroyObject( name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Open on the same session - should fail. try { folder1.Open( session1, name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_OBJECT_IS_DELETED ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // Open with a different session - should work. try { folder2.Open( session2, name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } /* * Commit with session 2 having the object open. The object should * still be in shared memory but we should be able to create a new one. * Of a different type even! */ try { session1.Commit(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { session1.DestroyObject( name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_OBJECT ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { DataDefinition dataDefObj( session1, "cpp_session_destroy", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); session1.CreateQueue( name, queueDef, dataDefObj ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { queue1.Open( session1, name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { queue2.Open( session2, name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_OBJECT_IS_IN_USE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; HashMap * hashmap; string fname = "/cpp_hashmap_definition"; string hname = fname + "/test"; psoObjectDefinition mapDef = { PSO_HASH_MAP, 0, 0, 0 }; psoFieldDefinition fields[5] = { { "field1", PSO_TINYINT, {0} }, { "field2", PSO_INTEGER, {0} }, { "field3", PSO_CHAR, {30} }, { "field4", PSO_SMALLINT, {0} }, { "field5", PSO_LONGVARBINARY, {0} } }; psoKeyFieldDefinition keys[2] = { { "LastName", PSO_KEY_CHAR, 30 }, { "FirstName", PSO_KEY_VARCHAR, 30 } }; DataDefinition * retDataDef = NULL; KeyDefinition * retKeyDef = NULL; unsigned char * retFields = NULL; unsigned char * retKeys = NULL; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); session.CreateFolder( fname ); DataDefinition dataDefObj( session, "cpp_hashmap_definition", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, 5*sizeof(psoFieldDefinition) ); KeyDefinition keyDefObj( session, "cpp_hashmap_definition", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)keys, 2*sizeof(psoKeyFieldDefinition) ); session.CreateMap( hname, mapDef, dataDefObj, keyDefObj ); hashmap = new HashMap( session, hname ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { retDataDef = hashmap->GetDataDefinition(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { if ( retDataDef->GetType() != PSO_DEF_PHOTON_ODBC_SIMPLE ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } if ( retDataDef->GetLength() != 5*sizeof(psoFieldDefinition) ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } retFields = new unsigned char [5*sizeof(psoFieldDefinition)]; retDataDef->GetDefinition( retFields, 5*sizeof(psoFieldDefinition) ); if ( memcmp( retFields, fields, 5*sizeof(psoFieldDefinition) ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { retKeyDef = hashmap->GetKeyDefinition(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { if ( retKeyDef->GetType() != PSO_DEF_PHOTON_ODBC_SIMPLE ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } if ( retKeyDef->GetLength() != 2*sizeof(psoKeyFieldDefinition) ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } retKeys = new unsigned char [2*sizeof(psoKeyFieldDefinition)]; retKeyDef->GetDefinition( retKeys, 2*sizeof(psoKeyFieldDefinition) ); if ( memcmp( retKeys, keys, 2*sizeof(psoKeyFieldDefinition) ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session1, session2; FastMapEditor * map1; FastMap * map2; string fname = "/cpp_fastmap_delete"; string hname = fname + "/test"; const char * key = "My Key"; const char * data = "My Data"; uint32_t length, keyLength; char buffer[20], keyBuff[20]; int rc; psoObjectDefinition mapDef = { PSO_FAST_MAP, 0, 0, 0 }; psoKeyFieldDefinition keys = { "MyKey", PSO_KEY_VARBINARY, 20 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session1.Init(); session2.Init(); session1.CreateFolder( fname ); DataDefinition dataDefObj( session1, "cpp_fastmap_delete", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); KeyDefinition keyDefObj( session1, "cpp_fastmap_delete", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)&keys, sizeof(psoKeyFieldDefinition) ); session1.CreateMap( hname, mapDef, dataDefObj, keyDefObj ); map1 = new FastMapEditor( session1, hname ); map1->Insert( key, 6, data, 7 ); delete (map1); session1.Commit(); map1 = new FastMapEditor( session1, hname ); map2 = new FastMap( session2, hname ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { map1->Delete( NULL, 6 ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { map1->Delete( key, 0 ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { map1->Delete( key, 6 ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } /* * Additional stuff to check while the Delete() is uncommitted: * - cannot get access to the item from first session. * - can get access to the item from second session. * - cannot modify it from second session. */ try { map1->Get( key, 6, buffer, 20, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { map2->Get( key, 6, buffer, 20, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { map2->GetFirst( keyBuff, 20, buffer, 20, keyLength, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { rc = map1->GetFirst( keyBuff, 20, buffer, 20, keyLength, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( rc != PSO_IS_EMPTY ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } try { map1->Close(); session1.Commit(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // No refresh yet - still using the old hash map try { map2->Get( key, 6, buffer, 20, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { session2.Commit(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { map2->Get( key, 6, buffer, 20, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; DataDefinition * pDataDef; string name = "Default"; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // Session is not initialized try { pDataDef = new DataDefinition( session, name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session.Init(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Wrong arguments to tested function try { pDataDef = new DataDefinition( session, "" ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { pDataDef = new DataDefinition( session, "blah-blah-junk" ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // This call should work try { pDataDef = new DataDefinition( session, name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } delete pDataDef; return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; int errcode; string name = "/cpp_session_last_error"; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); // Is last error properly initialized? errcode = session.LastError(); if ( errcode != PSO_OK ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } // Our first "test call" session.CreateFolder( name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { errcode = session.LastError(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( errcode != PSO_OK ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } // Create the same object a second time and check that last error is // the one we expect. try { session.CreateFolder( name ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_OBJECT_ALREADY_PRESENT ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { errcode = session.LastError(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( errcode != PSO_OBJECT_ALREADY_PRESENT ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; DataDefinition dataDef; string name = "/cpp_datadefinition_close"; unsigned char byteData[50]; unsigned int dataLength = 50; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // DataDefinition is not initialized try { dataDef.Close(); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session.Init(); dataDef.Create( session, name, PSO_DEF_USER_DEFINED, byteData, dataLength ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { dataDef.Close(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session1, session2; Lifo queue1, queue2; string fname = "/cpp_queue_pop"; string qname = fname + "/test"; const char * data1 = "My Data1"; char buffer[50]; uint32_t length; int rc; psoObjectDefinition queueDef = { PSO_LIFO, 0, 0, 0 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session1.Init(); session2.Init(); session1.CreateFolder( fname ); DataDefinition dataDefObj( session1, "cpp_lifo_pop", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); session1.CreateQueue( qname, queueDef, dataDefObj ); queue1.Open( session1, qname ); queue1.Push( data1, strlen(data1) ); session1.Commit(); queue2.Open( session2, qname ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { queue1.Pop( NULL, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { queue1.Pop( buffer, 2, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { queue1.Pop( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( memcmp( buffer, data1, strlen(data1) ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } /* * Additional stuff to check while the Pop is uncommitted: * - cannot get access to the item from first session. * - can get access to the item from second session. * - cannot modify it from second session. */ try { queue1.GetFirst( buffer, 50, length ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_ITEM_IS_IN_USE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { queue2.GetFirst( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { rc = queue2.Pop( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( rc != PSO_ITEM_IS_IN_USE ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } /* * Additional stuff to check after the commit: * - cannot get access to the item from first session. * - cannot get access to the item from second session. * And that the error is PSO_EMPTY. * * Note to make sure that the deleted item is still in shared memory, * we first call GetFirst to get a pointer to the item from * session 2 (the failed call to Pop just above release that * internal pointer). */ try { queue2.GetFirst( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { session1.Commit(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { rc = queue1.GetFirst( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( rc != PSO_IS_EMPTY ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } try { rc = queue2.GetFirst( buffer, 50, length ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( rc != PSO_IS_EMPTY ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; HashMap hashmap; string fname = "/cpp_hashmap_getfirst"; string hname = fname + "/test"; const char * key = "My Key"; const char * data = "My Data"; char buffer[50]; char buffKey[50]; uint32_t dataLength, keyLength; psoObjectDefinition mapDef = { PSO_HASH_MAP, 0, 0, 0 }; psoKeyFieldDefinition keyDef = { "MyKey", PSO_KEY_VARBINARY, 20 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); session.CreateFolder( fname ); DataDefinition dataDefObj( session, "cpp_hashmap_getfirst", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); KeyDefinition keyDefObj( session, "cpp_hashmap_getfirst", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)&keyDef, sizeof(psoKeyFieldDefinition) ); session.CreateMap( hname, mapDef, dataDefObj, keyDefObj ); hashmap.Open( session, hname ); hashmap.Insert( key, 6, data, 7 ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { hashmap.GetFirst( NULL, 50, buffer, 50, keyLength, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap.GetFirst( buffKey, 2, buffer, 50, keyLength, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap.GetFirst( buffKey, 50, NULL, 50, keyLength, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { hashmap.GetFirst( buffKey, 50, buffer, 2, keyLength, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // End of invalid args. This call should succeed. try { hashmap.GetFirst( buffKey, 50, buffer, 50, keyLength, dataLength ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( memcmp( buffer, data, 7 ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; Queue * queue; string fname = "/cpp_queue_status"; string qname = fname + "/test"; const char * data1 = "My Data1"; const char * data2 = "My Data2"; const char * data3 = "My Data3"; psoObjStatus status; psoObjectDefinition queueDef = { PSO_QUEUE, 0, 0, 0 }; psoFieldDefinition fields[1] = { { "Field_1", PSO_VARCHAR, {10} } }; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); session.CreateFolder( fname ); DataDefinition dataDefObj( session, "cpp_queue_status", PSO_DEF_PHOTON_ODBC_SIMPLE, (unsigned char *)fields, sizeof(psoFieldDefinition) ); session.CreateQueue( qname, queueDef, dataDefObj ); queue = new Queue( session, qname ); queue->Push( data1, strlen(data1) ); queue->Push( data2, strlen(data2) ); queue->Push( data3, strlen(data3) ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // End of invalid args. This call should succeed. try { queue->Status( status ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( status.numDataItem != 3 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } if ( status.numBlocks != 1 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } if ( status.numBlockGroup != 1 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } if ( status.freeBytes == 0 || status.freeBytes >=PSON_BLOCK_SIZE ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session1, session2; Folder *folder1, *folder2; string name = "/cpp_folder_constructor"; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session1.Init(); session1.CreateFolder( name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Invalid arguments to tested function. try { folder1 = new Folder( session1, "" ); } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { folder2 = new Folder( session2, name ); } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } session2.Init(); // End of invalid args. This call should succeed. try { folder1 = new Folder( session1, name ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { folder2 = new Folder( session2, name ); } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_OBJECT_IS_IN_USE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; FastMap * map; string fname = "/cpp_fastmap_fielddefODBC"; string hname = fname + "/test"; size_t len; psoObjectDefinition mapDef = { PSO_FAST_MAP, 0, 0, 0 }; DataDefBuilderODBC fieldDef( 5 ); KeyDefBuilderODBC keyDef( 3 ); DataDefinition * returnedDataDef; KeyDefinition * returnedKeyDef; unsigned char * buffer; try { fieldDef.AddField( "field1", 6, PSO_TINYINT, 0, 0, 0 ); fieldDef.AddField( "field2", 6, PSO_INTEGER, 0, 0, 0 ); fieldDef.AddField( "field3", 6, PSO_CHAR, 30, 0, 0 ); fieldDef.AddField( "field4", 6, PSO_SMALLINT, 0, 0, 0 ); fieldDef.AddField( "field5", 6, PSO_LONGVARBINARY, 0, 0, 0 ); keyDef.AddKeyField( "keyfield1", 9, PSO_KEY_INTEGER, 0 ); keyDef.AddKeyField( "keyfield2", 9, PSO_KEY_CHAR, 30 ); keyDef.AddKeyField( "keyfield3", 9, PSO_KEY_LONGVARBINARY, 0 ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } try { session.Init(); session.CreateFolder( fname ); DataDefinition dataDefObj( session, "cpp_fastmap_datadef_odbc", PSO_DEF_PHOTON_ODBC_SIMPLE, fieldDef.GetDefinition(), fieldDef.GetDefLength() ); KeyDefinition keyDefObj( session, "cpp_fastmap_datadef_odbc", PSO_DEF_PHOTON_ODBC_SIMPLE, keyDef.GetDefinition(), keyDef.GetDefLength() ); session.CreateMap( hname, mapDef, dataDefObj, keyDefObj ); map = new FastMap( session, hname ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { returnedDataDef = map->GetDataDefinition(); returnedKeyDef = map->GetKeyDefinition(); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } try { len = 5 * sizeof(psoFieldDefinition); buffer = new unsigned char [len]; if ( len != returnedDataDef->GetLength() ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } returnedDataDef->GetDefinition( buffer, len ); if ( memcmp( fieldDef.GetDefinition(), buffer, len ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } delete [] buffer; len = 3 * sizeof(psoKeyFieldDefinition); buffer = new unsigned char [len]; if ( len != returnedKeyDef->GetLength() ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } returnedKeyDef->GetDefinition( buffer, len ); if ( memcmp( keyDef.GetDefinition(), buffer, len ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; DataDefinition dataDef; string name = "/cpp_datadefinition_get_definition"; unsigned char byteData[50], returnedData[50]; unsigned int dataLength = 50; for ( int i = 0; i < 50; ++i ) { byteData[i] = i*2 + 1; } try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // DataDefinition is not initialized try { dataDef.GetDefinition( returnedData, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session.Init(); dataDef.Create( session, name, PSO_DEF_USER_DEFINED, byteData, dataLength ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // Wrong arguments to tested function try { dataDef.GetDefinition( NULL, dataLength ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_POINTER ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { dataDef.GetDefinition( returnedData, 0 ); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } // This call should work try { dataDef.GetDefinition( returnedData, dataLength ); } catch( pso::Exception exc ) { cerr << exc.ErrorCode() << endl; cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } if ( memcmp( byteData, returnedData, dataLength ) != 0 ) { cerr << "Test failed - line " << __LINE__ << endl; return 1; } dataDef.Close(); return 0; }
int main( int argc, char * argv[] ) { Process process; Session session; DataDefinition dataDef; string name = "/cpp_datadefinition_get_definition"; unsigned char byteData[50]; unsigned int dataLength = 50; string fieldDescription; memcpy( &byteData[0], "Field 1 ", 9 ); memcpy( &byteData[10], "Field 2 ", 9 ); memcpy( &byteData[20], "Field 3 ", 9 ); memcpy( &byteData[30], "Field 4 ", 9 ); memcpy( &byteData[40], "Field 5 ", 9 ); byteData[9] = 0; byteData[19] = 0; byteData[29] = 0; byteData[39] = 0; byteData[49] = 0; try { if ( argc > 1 ) { process.Init( argv[1], argv[0] ); } else { process.Init( "10701", argv[0] ); } } catch( pso::Exception exc ) { cerr << "Test failed in init phase, error = " << exc.Message() << endl; cerr << "Is the server running?" << endl; return 1; } // DataDefinition is not initialized try { fieldDescription = dataDef.GetNext(); // Should never come here cerr << "Test failed - line " << __LINE__ << endl; return 1; } catch( pso::Exception exc ) { if ( exc.ErrorCode() != PSO_NULL_HANDLE ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } } try { session.Init(); dataDef.Create( session, name, PSO_DEF_USER_DEFINED, byteData, dataLength ); } catch( pso::Exception exc ) { cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } // This call should work try { do { fieldDescription = dataDef.GetNext(); cout << fieldDescription << endl; } while ( fieldDescription.length() > 0 ); } catch( pso::Exception exc ) { cerr << exc.ErrorCode() << endl; cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl; return 1; } dataDef.Close(); return 0; }