/* **************************************************************************** * * main - */ int main(int argC, char** argV) { paConfig("usage and exit on any warning", (void*) true); paConfig("log to screen", (void*) "only errors"); paConfig("log file line format", (void*) "TYPE:DATE:EXEC-AUX/FILE[LINE](p.PID)(t.TID) FUNC: TEXT"); paConfig("screen line format", (void*) "TYPE@TIME EXEC: TEXT"); paConfig("log to file", (void*) true); paConfig("default value", "-logDir", (void*) "/tmp"); paConfig("man author", "Fermín Galán and Ken Zangelin"); if (argC > 1) { if (strcmp(argV[1], "-t") == 0) paParse(paArgs, 3, argV, 3, false); else paParse(paArgs, 1, argV, 1, false); } else paParse(paArgs, 1, argV, 1, false); LM_M(("Init tests")); orionInit(exitFunction, orionUnitTestVersion, SemReadWriteOp, false); setupDatabase(); LM_M(("Run all tests")); ::testing::InitGoogleMock(&argC, argV); return RUN_ALL_TESTS(); }
/* **************************************************************************** * * prepareDatabase - */ static void prepareDatabase(std::string id, std::string type) { /* Set database */ setupDatabase(); DBClientConnection* connection = getMongoConnection(); /* We create one entity: * * - 'id', 'type' with four attributes * A1: X * A1: Y * A2: Z * A3: W */ BSONObj en1 = BSON("_id" << BSON("id" << id << "type" << type) << "attrs" << BSON_ARRAY( BSON("name" << "A1" << "type" << "TA1" << "value" << "X") << BSON("name" << "A1" << "type" << "TA1bis" << "value" << "Y") << BSON("name" << "A2" << "type" << "TA2" << "value" << "Z") << BSON("name" << "A3" << "type" << "TA3" << "value" << "W") ) ); connection->insert(ENTITIES_COLL, en1); }
/* **************************************************************************** * * prepareDatabase - * * This function is called before every test, to populate some information in the * entities collection. */ static void prepareDatabase(void) { /* Set database */ setupDatabase(); DBClientBase* connection = getMongoConnection(); BSONObj en1 = BSON("_id" << BSON("id" << "E1" << "type" << "T1") << "attrNames" << BSON_ARRAY("A1") << "attrs" << BSON( "A1" << BSON("type" << "TA1" << "value" << "val1") ) ); BSONObj en2 = BSON("_id" << BSON("id" << "E1") << "attrNames" << BSON_ARRAY("A1") << "attrs" << BSON( "A1" << BSON("type" << "TA1" << "value" << "val1b") ) ); connection->insert(ENTITIES_COLL, en1); connection->insert(ENTITIES_COLL, en2); }
/*! Add new tests, they can be the same model, but in a different state. The name of the model is passed to createModel If readOnly is true the remove tests will be skipped. Example: QDirModel is disabled. If createModel returns an empty model. Example: QDirModel does not */ ModelsToTest::ModelsToTest() { setupDatabase(); tests.append(test("QDirModel", ReadOnly, HasData)); tests.append(test("QStringListModel", ReadWrite, HasData)); tests.append(test("QStringListModelEmpty", ReadWrite, Empty)); tests.append(test("QStandardItemModel", ReadWrite, HasData)); tests.append(test("QStandardItemModelEmpty", ReadWrite, Empty)); // QSortFilterProxyModel test uses QStandardItemModel so test it first tests.append(test("QSortFilterProxyModel", ReadWrite, HasData)); tests.append(test("QSortFilterProxyModelEmpty", ReadWrite, Empty)); tests.append(test("QSortFilterProxyModelRegExp", ReadWrite, HasData)); tests.append(test("QListModel", ReadWrite, HasData)); tests.append(test("QListModelEmpty", ReadWrite, Empty)); tests.append(test("QTableModel", ReadWrite, HasData)); tests.append(test("QTableModelEmpty", ReadWrite, Empty)); tests.append(test("QTreeModel", ReadWrite, HasData)); tests.append(test("QTreeModelEmpty", ReadWrite, Empty)); tests.append(test("QSqlQueryModel", ReadOnly, HasData)); tests.append(test("QSqlQueryModelEmpty", ReadOnly, Empty)); // Fails on remove tests.append(test("QSqlTableModel", ReadOnly, HasData)); }
void MainWindow::setupTapahtuma() { if (ui->tabWidget->count() > 0) { INFO(this, _("Sulje kaikki tabit ennen tapahtuman vaihtamista.")); return; } TapahtumaDialog d(this); d.setWindowTitle(d.windowTitle() + " - " VERSION); if (d.exec() != QDialog::Accepted) { return; } setupDatabase(); this->setWindowTitle(_("Tulospalvelu - %1 - %2") .arg(Tapahtuma::tapahtuma()->nimi()) .arg(VERSION)); m_serialStatus->setText("Lukulaite: Yhteys katkaistu"); statusBar()->addPermanentWidget(m_serialStatus); statusBar()->addPermanentWidget(m_tuloksiaLabel); updateStatus(); }
int main(int argc, char **argv) { if(argc != 2) { fprintf(stderr, "Usage: %s /dev/<ssp-port>\n", argv[0]); return 1; } signal(SIGPIPE, SIG_IGN); signal(SIGINT, interrupt); fprintf(stderr, "eSSP starting up (port %s)...\n", argv[1]); if(!sspConnectToValidator(argv[1])) { return 3; } eventBase = event_base_new(); atexit(cleanup); setupDatabase(); redisLibeventAttach(db, eventBase); redisAsyncSetConnectCallback(db, connectCallback); redisAsyncSetDisconnectCallback(db, disconnectCallback); event_base_dispatch(eventBase); return 0; }
void Database::init() { boost::mutex::scoped_lock lock(dbMutex); this->currentList = &dataA; this->recordsWritten = 0; this->running = true; logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("Database")); setupDatabase(); prepareStatements(); workerThread = new boost::thread(&Database::doWork, this); }
TEST_F(EnableShardingTest, succeedsWhenTheDatabaseIsAlreadySharded) { ShardType shard; shard.setName("shard0"); shard.setHost("shard0:12"); ASSERT_OK(setupShards(vector<ShardType>{shard})); setupDatabase("db5", shard.getName(), true); auto status = ShardingCatalogManager::get(operationContext())->enableSharding(operationContext(), "db5"); ASSERT_OK(status); }
/* **************************************************************************** * * utInit - unit test init * */ void utInit(void) { #ifdef UT_DEBUG ++noOfInits; printf("**************** IN utInit (%d inits, %d exits)\n", noOfInits, noOfExits); #endif notifierMock = new NotifierMock(); if (notifierMock == NULL) { fprintf(stderr, "error allocating NotifierMock: %s\n", strerror(errno)); exit(1); } setNotifier(notifierMock); timerMock = new TimerMock(); if (timerMock == NULL) { fprintf(stderr, "error allocating TimerMock: %s\n", strerror(errno)); exit(1); } ON_CALL(*timerMock, getCurrentTime()).WillByDefault(Return(1360232700)); setTimer(timerMock); startTime = getCurrentTime(); statisticsTime = getCurrentTime(); setupDatabase(); #ifdef UT_DEBUG printf("**************** FROM utInit (%d inits, %d exits)\n", noOfInits, noOfExits); #endif // // URI parameters used for unit testing // Default mime type for notifications: application/xml // uriParams[URI_PARAM_NOTIFY_FORMAT] = "XML"; uriParams[URI_PARAM_PAGINATION_OFFSET] = DEFAULT_PAGINATION_OFFSET; uriParams[URI_PARAM_PAGINATION_LIMIT] = DEFAULT_PAGINATION_LIMIT; uriParams[URI_PARAM_PAGINATION_DETAILS] = DEFAULT_PAGINATION_DETAILS; uriParams[URI_PARAM_NOT_EXIST] = ""; // FIXME P7: we need this to implement "restriction-based" filters // // Resetting servicePathVector // servicePathVector.clear(); // Init subs cache (this initialization is overriden in test that use csubs) mongoSubCacheInit(); }
DataManager::DataManager() { triggeredColumns << "id" << "urb_id" << "bus" << "device" << "endpoint" << "time" << "status"; packets.setColumnCount(triggeredColumns.size()); QStringList headers; headers << "#" << "URB #" << "Bus" << "Device" << "Endpoint" << "Time" << "Status"; packets.setHorizontalHeaderLabels(headers); setupDatabase(); QObject::connect(&bridge, SIGNAL(rowInserted(QList<QVariant>)), this, SLOT(onRowInserted(QList<QVariant>)), Qt::DirectConnection); QObject::connect(this, SIGNAL(processPacket(const mon_bin_get*)), this, SLOT(onProcessPacket(const mon_bin_get*)), Qt::QueuedConnection); }
int main( int argc, char** argv ) { QApplication app( argc, argv ); Config* config = new Config( &app ); // If we can't process the command-line or set up the database // there's no point continuing if ( !processCommandLine() || !setupDatabase() ) return 0; QDeclarativeView view; view.connect( view.engine(), SIGNAL(quit()), SLOT(close()) ); view.setResizeMode( QDeclarativeView::SizeRootObjectToView ); // Register custom types for access to certail enums from QML qmlRegisterType< SoundEngine >( "net.randalflagg.llamaui", 1, 0, "SoundEngine" ); qmlRegisterType< KeyboardMap >( "net.randalflagg.llamaui", 1, 0, "KeyboardMap" ); qmlRegisterType< SystemProcess >( "net.randalflagg.llamaui", 1, 0, "SystemProcess" ); QDeclarativeContext* rootContext = view.rootContext(); // Initalise the keyboard key/action mapper if ( !initKeyboardMap( rootContext ) ) return 0; rootContext->setContextProperty( "config", config ); initSoundEngine( rootContext ); initGameMenu( rootContext ); initEmulatorMenu( rootContext ); initSystemMenu( rootContext ); initGameLauncher( rootContext ); // Create the interface QDir dir( Config::instance()->value( "paths", "qmlDir" ).toString() ); view.setSource( QUrl::fromLocalFile( dir.absoluteFilePath( "main.qml" ) ) ); view.showFullScreen(); // Hide the mouse cursor app.setOverrideCursor( QCursor( Qt::BlankCursor ) ); return app.exec(); }
Hourglass::Hourglass(int &argc, char **argv) : QApplication(argc, argv) { connect(this, SIGNAL(aboutToQuit()), SLOT(stopActivities())); setOrganizationName("vubiostat"); setOrganizationDomain("biostat.mc.vanderbilt.edu"); setApplicationName("hourglass"); if (setupDatabase()) { m_mainwindow = new MainWindow(); setQuitOnLastWindowClosed(!m_mainwindow->isTrayIconShown()); connect(m_mainwindow, SIGNAL(trayIconHidden()), SLOT(trayIconHidden())); connect(m_mainwindow, SIGNAL(trayIconShown()), SLOT(trayIconShown())); m_mainwindow->show(); } else { quit(); } }
void Database::setDatabaseName(const QString & name) { QString dbname = setupDatabase(name); mSqlDatabase.setDatabaseName(dbname); mSqlDatabase.open(); }
/* **************************************************************************** * * prepareDatabase - * * This function is called before every test, to populate some information in the * registrations collection. */ static void prepareDatabase(void) { /* Set database */ setupDatabase(); DBClientBase* connection = getMongoConnection(); /* We create the following registrations: * * - Reg1: CR: (E1,E2,E3) (A1,A2,A3) * CR: (E1) (A1,A4) * - Reg2: CR: (E2) (A2, A3) * - Reg3: CR: (E1*) (A1*) * - Reg4: CR: (E1**) (A1) * * (*) same name but different types. This is included to check that type is taken into account, * so Reg3 is not returned never (except noPatternNoType). You can try to change types in Reg3 * to make them equal to the ones in Reg1 and Reg2 and check that some tests are failing. * (**)same name but without type */ BSONObj cr1 = BSON("providingApplication" << "http://cr1.com" << "entities" << BSON_ARRAY( BSON("id" << "E1" << "type" << "T1") << BSON("id" << "E2" << "type" << "T2") << BSON("id" << "E3" << "type" << "T3") ) << "attrs" << BSON_ARRAY( BSON("name" << "A1" << "type" << "TA1" << "isDomain" << "true") << BSON("name" << "A2" << "type" << "TA2" << "isDomain" << "false") << BSON("name" << "A3" << "type" << "TA3" << "isDomain" << "true") ) ); BSONObj cr2 = BSON("providingApplication" << "http://cr2.com" << "entities" << BSON_ARRAY( BSON("id" << "E1" << "type" << "T1") ) << "attrs" << BSON_ARRAY( BSON("name" << "A1" << "type" << "TA1" << "isDomain" << "true") << BSON("name" << "A4" << "type" << "TA4" << "isDomain" << "false") ) ); BSONObj cr3 = BSON("providingApplication" << "http://cr3.com" << "entities" << BSON_ARRAY( BSON("id" << "E2" << "type" << "T2") ) << "attrs" << BSON_ARRAY( BSON("name" << "A2" << "type" << "TA2" << "isDomain" << "false") << BSON("name" << "A3" << "type" << "TA3" << "isDomain" << "true") ) ); BSONObj cr4 = BSON("providingApplication" << "http://cr4.com" << "entities" << BSON_ARRAY( BSON("id" << "E1" << "type" << "T1bis") ) << "attrs" << BSON_ARRAY( BSON("name" << "A1" << "type" << "TA1bis" << "isDomain" << "false") ) ); BSONObj cr5 = BSON("providingApplication" << "http://cr5.com" << "entities" << BSON_ARRAY( BSON("id" << "E1") ) << "attrs" << BSON_ARRAY( BSON("name" << "A1" << "type" << "TA1" << "isDomain" << "true") ) ); /* 1879048191 corresponds to year 2029 so we avoid any expiration problem in the next 16 years :) */ BSONObj reg1 = BSON( "_id" << OID("51307b66f481db11bf860001") << "expiration" << 1879048191 << "contextRegistration" << BSON_ARRAY(cr1 << cr2) ); BSONObj reg2 = BSON( "_id" << OID("51307b66f481db11bf860002") << "expiration" << 1879048191 << "contextRegistration" << BSON_ARRAY(cr3) ); BSONObj reg3 = BSON( "_id" << OID("51307b66f481db11bf860003") << "expiration" << 1879048191 << "contextRegistration" << BSON_ARRAY(cr4) ); BSONObj reg4 = BSON( "_id" << OID("51307b66f481db11bf860004") << "expiration" << 1879048191 << "contextRegistration" << BSON_ARRAY(cr5) ); connection->insert(REGISTRATIONS_COLL, reg1); connection->insert(REGISTRATIONS_COLL, reg2); connection->insert(REGISTRATIONS_COLL, reg3); connection->insert(REGISTRATIONS_COLL, reg4); }
/* **************************************************************************** * * prepareDatabase - * * This function is called before every test, to populate some information in the * entities collection. */ static void prepareDatabase(bool extraEntities = false) { /* Set database */ setupDatabase(); DBClientBase* connection = getMongoConnection(); /* We create the following entities: * * - E1 * S: "running" * N: 26.5 * D: ISODate("2017-06-17T07:12:25.823Z") * - E2 * S: "running" * N: 27 * D: ISODate("2017-06-17T07:21:24.238Z") * - E3 * S: "shutdown" * N: 31 * D: ISODate("2017-06-17T08:19:12.231Z") * - E4 * S: "error" * N: 17.8 * D: ISODate("2017-06-17T07:22:43.112Z") * - E5 * S: "shutdown" * N: 24 * D: ISODate("2017-06-17T07:10:12.328Z") * - C1 * colour=black,white * - C2 * colour=red,blue * - C3 * colour=red, blue */ // FIXME: D will be set with dates once https://github.com/telefonicaid/fiware-orion/issues/1039 implementation // gets addressed BSONObj en1 = BSON("_id" << BSON("id" << "E1" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N" << "D") << "attrs" << BSON( "S" << BSON("type" << "T" << "value" << "running") << "N" << BSON("type" << "T" << "value" << 26.5) << "D" << BSON("type" << "T" << "value" << "") ) ); BSONObj en2 = BSON("_id" << BSON("id" << "E2" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N" << "D") << "attrs" << BSON( "S" << BSON("type" << "T" << "value" << "running") << "N" << BSON("type" << "T" << "value" << 27) << "D" << BSON("type" << "T" << "value" << "") ) ); BSONObj en3 = BSON("_id" << BSON("id" << "E3" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N" << "D") << "attrs" << BSON( "S" << BSON("type" << "T" << "value" << "shutdown") << "N" << BSON("type" << "T" << "value" << 31) << "D" << BSON("type" << "T" << "value" << "") ) ); BSONObj en4 = BSON("_id" << BSON("id" << "E4" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N" << "D") << "attrs" << BSON( "S" << BSON("type" << "T" << "value" << "error") << "N" << BSON("type" << "T" << "value" << 17.8) << "D" << BSON("type" << "T" << "value" << "") ) ); BSONObj en5 = BSON("_id" << BSON("id" << "E5" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N" << "D") << "attrs" << BSON( "S" << BSON("type" << "T" << "value" << "shutdown") << "N" << BSON("type" << "T" << "value" << 24) << "D" << BSON("type" << "T" << "value" << "") ) ); BSONObj c1 = BSON("_id" << BSON("id" << "C1" << "type" << "T") << "attrNames" << BSON_ARRAY("colour") << "attrs" << BSON( "colour" << BSON("type" << "T" << "value" << "black,white") ) ); BSONObj c2 = BSON("_id" << BSON("id" << "C2" << "type" << "T") << "attrNames" << BSON_ARRAY("colour") << "attrs" << BSON( "colour" << BSON("type" << "T" << "value" << "red,blue") ) ); BSONObj c3 = BSON("_id" << BSON("id" << "C3" << "type" << "T") << "attrNames" << BSON_ARRAY("colour") << "attrs" << BSON( "colour" << BSON("type" << "T" << "value" << "black, white") ) ); connection->insert(ENTITIES_COLL, en1); connection->insert(ENTITIES_COLL, en2); connection->insert(ENTITIES_COLL, en3); connection->insert(ENTITIES_COLL, en4); connection->insert(ENTITIES_COLL, en5); connection->insert(ENTITIES_COLL, c1); connection->insert(ENTITIES_COLL, c2); connection->insert(ENTITIES_COLL, c3); if (extraEntities) { /* Adding additional entities, used in some tests * - E6 * N: 26.5 * - E7 (no type, "") * N: 27 * - E8 (no type, <none>) * N: 27 */ // FIXME: D will be set with dates once https://github.com/telefonicaid/fiware-orion/issues/1039 implementation // gets addressed BSONObj en6 = BSON("_id" << BSON("id" << "E6" << "type" << "T") << "attrNames" << BSON_ARRAY("S" << "N") << "attrs" << BSON( "N" << BSON("type" << "T" << "value" << 26.5) ) ); BSONObj en7 = BSON("_id" << BSON("id" << "E7" << "type" << "") << "attrNames" << BSON_ARRAY("S" << "N") << "attrs" << BSON( "N" << BSON("type" << "T" << "value" << 27) ) ); BSONObj en8 = BSON("_id" << BSON("id" << "E8") << "attrNames" << BSON_ARRAY("S" << "N") << "attrs" << BSON( "N" << BSON("type" << "T" << "value" << 27) ) ); connection->insert(ENTITIES_COLL, en6); connection->insert(ENTITIES_COLL, en7); connection->insert(ENTITIES_COLL, en8); } }