Пример #1
0
void AgentThread::processCMDSTART_REQUEST(int socketHandle)
{				
  try {
	ConsoleServer::debugMsg(1,"Processing CMDSTART_REQUEST\n");
	// read the serialized TestObject which we will execute
	TestObject *test = new TestObject();
	test->readTestObject(socketHandle);
			
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
			
	// execute the test
	ExecProcess *startedProcess = addProcess(new ExecProcess(test,
															debugLevel,
															showOutput));
	
	startedProcess->run();
	ConsoleServer::debugMsg(1,
							"Added pid %d to process pool (total %d processes)\n",
							startedProcess->getPid(),
							getProcessCount());
			
	// now send a signal indicating we have finished
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);			
  }
  catch (char *message) {
	ConsoleServer::debugMsg(1,"Error processing CMDSTART_REQUEST execute request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
};	
Пример #2
0
TEST(test_large_visibe_char_1, DISKQUEUE_MULTI_READ_ONE_WRITE) {
    DiskQueue<TestObject> disk_queue("queue/zhangsan", 1, 1024*1024*10, serializer, deserializer);

    ASSERT_EQ(1, disk_queue.empty());
    ASSERT_STREQ("queue/zhangsan", disk_queue.getQueueName());
    ASSERT_EQ(1, disk_queue.getMode());
    ASSERT_EQ(1024*1024*10, disk_queue.getMaxFileSize());

    int i;
    std::queue<TestObject*> TestObjectQueue;
    for(i = 0; i < 1024*10*10; i++) {//10M * 10
        TestObject* tmp = TestObject::createRandomOne(1024, 0);
        TestObject* tmp1 = tmp->copy();
        TestObjectQueue.push(tmp1);
        ASSERT_EQ(1, disk_queue.push(tmp));
    }

    while(!TestObjectQueue.empty()) {
        TestObject* tmp = TestObjectQueue.front();
        TestObjectQueue.pop();
        TestObject* tmp2 = NULL;
        ASSERT_EQ(0, disk_queue.empty());
        ASSERT_EQ(1, disk_queue.pop(&tmp2));
        ASSERT_STREQ(tmp->getData(), tmp2->getData());
        delete tmp;
        delete tmp2;
    }
    
    ASSERT_EQ(1, disk_queue.empty());
}   
void tst_qqmlexpression::scriptString()
{
    qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");

    QQmlEngine engine;
    QQmlComponent c(&engine, testFileUrl("scriptString.qml"));
    TestObject *testObj = qobject_cast<TestObject*>(c.create());
    QVERIFY(testObj != 0);

    QQmlScriptString script = testObj->scriptString();
    QVERIFY(!script.isEmpty());

    QQmlExpression expression(script);
    QVariant value = expression.evaluate();
    QCOMPARE(value.toInt(), 15);

    QQmlScriptString scriptError = testObj->scriptStringError();
    QVERIFY(!scriptError.isEmpty());

    //verify that the expression has the correct error location information
    QQmlExpression expressionError(scriptError);
    QVariant valueError = expressionError.evaluate();
    QVERIFY(!valueError.isValid());
    QVERIFY(expressionError.hasError());
    QQmlError error = expressionError.error();
    QCOMPARE(error.url(), c.url());
    QCOMPARE(error.line(), 8);
}
Пример #4
0
TEST(test_simple_1, DISKQUEUE_ONE_READ_ONE_WRITE) {
    DiskQueue<TestObject> disk_queue(NULL, 0, 0, serializer, deserializer);
    
    ASSERT_EQ(1, disk_queue.empty());
    ASSERT_STREQ(".queue.list", disk_queue.getQueueName());
    ASSERT_EQ(0, disk_queue.getMode());
    ASSERT_EQ(1024*1024*256, disk_queue.getMaxFileSize());

    int i;
    std::queue<TestObject*> TestObjectQueue;
    for(i = 0; i < 100; i++) {
        TestObject* tmp = TestObject::createRandomOne(1024, 0);
        TestObject* tmp1 = tmp->copy();
        TestObjectQueue.push(tmp1);
        ASSERT_EQ(1, disk_queue.push(tmp));
    }

    while(!TestObjectQueue.empty()) {
        TestObject* tmp = TestObjectQueue.front();
        TestObjectQueue.pop();
        TestObject* tmp2 = NULL;
        ASSERT_EQ(0, disk_queue.empty());
        ASSERT_EQ(1, disk_queue.pop(&tmp2));
        ASSERT_STREQ(tmp->getData(), tmp2->getData()); 
        delete tmp;
        delete tmp2;
    }

    ASSERT_EQ(1, disk_queue.empty());
}
Пример #5
0
void JavaClassUtilsTest::makeNameForSignatureWithArrayOfObjects(JNIEnv *env, jobject javaThis) {
  std::string result;
  TestObject testObject;
  JavaClassUtils::makeNameForSignature(result, kTypeObjectArray(MAKE_CANONICAL_NAME(PACKAGE, TestObject)));
  std::stringstream expected;
  expected << "[L" << testObject.getCanonicalName() << ";";
  JUNIT_ASSERT_EQUALS_STRING(expected.str().c_str(), result);
}
Пример #6
0
void JavaClassUtilsTest::makeNameForSignatureWithJniSignature(JNIEnv *env, jobject javaThis) {
  std::string result;
  TestObject testObject;
  std::stringstream signature;
  signature << "L" << testObject.getCanonicalName() << ";";
  JavaClassUtils::makeNameForSignature(result, signature.str().c_str());
  JUNIT_ASSERT_EQUALS_STRING(signature.str().c_str(), result);
}
Пример #7
0
void ExperimentSingle(TestSetting ts) {
	if (ts.getConfigBool("autoTestName")==true) {
		ts.testName.insert(0,"v_single_");
		cout << "(auto) testName: " << ts.testName << endl;
	}
	
	TestObject *expTest = new TestObject(ts);
	expTest->runStaticTest();
	delete expTest;
}
Пример #8
0
void ObjectTest::TestAddDestroyListener()
{
  TestObject* obj = new TestObject();

  ObjectListener objectListener;

  obj->AddDestroyListener(berry::MessageDelegate<ObjectListener>(
      &objectListener, &ObjectListener::DestroyListener));
  delete obj;
  assertEqual(true, objectListener.m_ObjectDeleted);
}
Пример #9
0
  TEUCHOS_UNIT_TEST(global_data, accessor_default_impl)
  {
    Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();
    
    TestObject t;
    t.setGlobalData(gd);

    TestObject2 t2(gd);

    TEST_EQUALITY(gd.get(), t2.getGlobalData().get());

  }
Пример #10
0
bool serializer(TestObject* data, tbnet::DataBuffer** dataBuffer) {
    TestObject* node = (TestObject*)data;
    char* t_value = node->getData();
    int t_value_len = node->getDataLen();

    tbnet::DataBuffer* buffer = new tbnet::DataBuffer();
    buffer->writeInt32(t_value_len);
    buffer->writeBytes(t_value,t_value_len);

    (*dataBuffer) = buffer;
    return true;
}
Пример #11
0
int main(int argc, char* argv[])
{
	/* get the NetAddr of the server */
	NetAddr netAddr(argv[1]);

	/* get netaddr to the proxy */
	NetAddr proxy(argv[2]);

	/* get size of objects */
	int objectSize;
	istringstream ss(argv[3]);
	ss >> objectSize;

	/* Initialize Server with our NetAddr */
	Ginnungagap::Initialize(SERVER, 50, netAddr, netAddr);

	/* Start necessary threads */
	Ginnungagap::Instance()->startDataSenderThread();
	Ginnungagap::Instance()->startDataAndConnectionReceiverThread();
	Ginnungagap::Instance()->startMessageHandlerThread();

	/* set terminal in ``any key''-mode */
	struct termios oldT, newT;
	ioctl(0, TCGETS, &oldT);
	newT = oldT;
	newT.c_lflag &= ~ECHO;
	newT.c_lflag &= ~ICANON;
	ioctl(0, TCSETS, &newT);

	cout << "Press any key once proxy is connected" << endl;
	cin.get();
	cout << "Migrating objects..." << endl;


	TestObject* test;
	for (int i = 0; i != 10000; ++i)
	{
		test = new TestObject(objectSize);
		Ginnungagap::Instance()->nameService()->bind(*test);
		Ginnungagap::Instance()->migrationService()->migrateObject(test->objectId(), proxy);
		usleep(30000);
	}

	cout << "Done migrating objects, press any key to exit" << endl;
	cin.get();

	/* restore original terminal mode */
	ioctl(0, TCSETS, &oldT);
	return 1;
}
Пример #12
0
void main()
{
    // using a bit of random here.
    srand(time(nullptr)); //initialize random seed based on time

    // Where will this object live? Is this a good choice? Why or why not?
    TestObject anObject = TestObject(30);

    // Name differences between pointers and references
    TestObject *anotherObject =  new TestObject(2); //error: new returns a pointer-> '*'

    // When should we use pointers, references and values? why?
    TestObject &referenceToAnObject = anObject;  //error: no &

    TestObject &referenceToAnotherObject = *anotherObject;  //error  original adress called with '*'

    TestObject* pointerToAnObject = &anObject;	//error: for pointer,adress of obj. is needed with &

    TestObject* pointerToAnotherObject = &referenceToAnotherObject; // error fix: for pointer, adress of Obj. is needed with '&'
    

    // Testing if the correct strings are being printed.
    referenceToAnotherObject.printAllStrings();
    std::cout << "The Following should be the same as above: " << std::endl;
    pointerToAnotherObject->printAllStrings();

    std::cout << std::endl << "total number of strings:" << std::endl;
   
    int& TotalElementNumber = sumTheElements(referenceToAnObject.elementCount(), referenceToAnotherObject.elementCount());
    std::cout << TotalElementNumber << std::endl;
    std::cout << "Do calculations in another scope and display the same value again inside that scope: " << std::endl; 
    { 
        //this isn't really doing anything, just for testing purposes
        int ignoreMe = 20; 
        ignoreMe *= TotalElementNumber;
        std::cout << TotalElementNumber << std::endl;
    }

    std::cout << "And again outside the scope: " << std::endl;
    std::cout << TotalElementNumber << std::endl;


    delete anotherObject;
	//cant delete objects with stack
    //delete pointerToAnObject;
    //delete pointerToAnotherObject;


}
Пример #13
0
void AgentThread::processDAEMONCLEAN_REQUEST(int socketHandle)
{
  try {
	ConsoleServer::debugMsg(1,"Processing DAEMONCLEAN_REQUEST\n");
	
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
	
	//clean the files now
	for (int i = getProcessCount()-1; i >=0; i--) {
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();		  
	  if (getProcess(i)->isDaemon()) {
		ConsoleServer::debugMsg(1,"Cleaning daemon %d\n",i);
		// clean up the trace files
		ConsoleServer::debugMsg(1,
								"Cleaning environment file :%s\n",
								curr->getEnvFileName().c_str());
		if (Utils::delete_file(curr->getEnvFileName())!=0)
		  ConsoleServer::debugMsg(1,"No environment file was found :%s\n",
								  curr->getEnvFileName().c_str());
		ConsoleServer::debugMsg(1,"Cleaning stdout file :%s\n",
								curr->getStdOutFileName().c_str());
		if (Utils::delete_file(curr->getStdOutFileName())!=0)
		  ConsoleServer::debugMsg(1,"No stdout file was found :%s\n",
								  curr->getStdOutFileName().c_str());
		ConsoleServer::debugMsg(1,"Cleaning stderr file :%s\n",
								curr->getStdErrFileName().c_str());
		if (Utils::delete_file(curr->getStdErrFileName())!=0)
		  ConsoleServer::debugMsg(1,"No stderr file was found :%s\n",
								  curr->getStdErrFileName().c_str());
		
		// remove from our list of test objects
		ConsoleServer::debugMsg(1,"Removing process from process pool\n");
		
		delProcess(i);							
	  }
	}
	
	// now send a signal indicating we have finished
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
  }
  catch (char * message) {
	ConsoleServer::debugMsg(1,"Error processing DAEMONCLEAN_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
};
Пример #14
0
void ExperimentVaryRange(TestSetting ts) {
	if (ts.getConfigBool("autoTestName")==true) {
		ts.testName.insert(0,"v_range_");
		cout << "(auto) testName: " << ts.testName << endl;
	}

	int lowRange = ts.getConfigInt("lowRange");
	int highRange = ts.getConfigInt("highRange");

	for (int range = lowRange; range <= highRange ; range*=2) {
		ts.range = range;
		cout << "*** Now using ts.range = " << ts.range << endl;

		TestObject *expTest = new TestObject(ts);
		expTest->runStaticTest();
		delete expTest;
	}
}
Пример #15
0
void ExperimentVaryCacheSize(TestSetting ts) {
	if (ts.getConfigBool("autoTestName")==true) {
		ts.testName.insert(0,"v_cachesize_");
		cout << "(auto) testName: " << ts.testName << endl;
	}
	
	unsigned long lowCacheSize = ts.getConfigLong("lowCacheSize");
	unsigned long highCacheSize = ts.getConfigLong("highCacheSize");
	
	for (unsigned long csize = lowCacheSize; csize <= highCacheSize ; csize*=2) {
		ts.cacheSize = csize;
		cout << "*** Now using ts.cacheSize = " << ts.cacheSize << endl;
		
		TestObject *expTest = new TestObject(ts);
		expTest->runStaticTest();
		delete expTest;
	}
}
Пример #16
0
void ExperimentVarySplit(TestSetting ts) {
	if (ts.getConfigBool("autoTestName")==true) {
		ts.testName.insert(0,"v_split_");
		cout << "(auto) testName: " << ts.testName << endl;
	}
	
	int lowSplit = ts.getConfigInt("lowSplit");
	int highSplit = ts.getConfigInt("highSplit");
	
	for (int splits = lowSplit; splits <= highSplit ; splits+=2) {	
		ts.splits = splits;
		cout << "*** Now using ts.splits = " << ts.splits << endl;

		TestObject *expTest = new TestObject(ts);
		expTest->runStaticTest();
		delete expTest;
	}
}
Пример #17
0
int main(int argc, char *argv[])
{
    try {

        qlua::LuaContext ctx;
        
        TestObject myobj;
        myobj.setObjectName( "MyObject" );

        //only add a single method to the Lua table
        ctx.AddQObject( &myobj, "myobj", false,
                        qlua::LuaContext::QOBJ_NO_DELETE, qlua::LuaDefaultSignatureMapper(),
                        QStringList() << "emitSignal" );
        ctx.Eval( "qlua.connect( myobj, 'aSignal(QString)', "
                    "function(msg) print( 'Lua callback called with data: ' .. msg ); end );"
                  "print( 'object name: ' .. myobj.objectName );"
                  "qlua.connect( myobj, 'aSignal(QString)', myobj, 'aSlot(QString)' );"
                  "myobj.emitSignal('hello')" );
        
        TestObject* myobj2 = new TestObject;
        QPointer< TestObject > pMyObject2 = myobj2;
        myobj2->setObjectName( "MyObject2" );
        ctx.AddQObject( myobj2, "myobj2", false, qlua::LuaContext::QOBJ_IMMEDIATE_DELETE );
        ctx.Eval( "print( 'object 2 name: '..myobj2.objectName )" );
        ctx.Eval( "myobj2=nil;collectgarbage('collect')");
        if( pMyObject2.isNull() ) std::cout << "Object 2 garbage collected by Lua" << std::endl;
        else std::cerr << "Object 2 not garbage collected!" << std::endl;         
        
        TestObject myobj3;
        ctx.AddQObject( &myobj3, "myobj3", false, qlua::LuaContext::QOBJ_NO_DELETE );
        ctx.Eval( "print( myobj3.copyString( 'hi' ) );"
                  "vm = myobj3.copyVariantMap( {key1=1,key2='hello'} );" 
                  "print( vm['key1'] .. ' ' .. vm['key2'] );"
                  "print( myobj3.createObject().objectName );" );

        ctx.Eval( "fl = myobj3.copyShortList( {1,2,3} );\n" 
                  "print( fl[1] .. ' ' .. fl[ 3 ] );\n" );
         
    } catch( const std::exception& e ) {
        std::cerr << e.what() << std::endl;
    }
    return 0;
}
Пример #18
0
TEST(test_large_unvisibe_char_2_test_file_refresh, DISKQUEUE_MULTI_READ_MULTI_WRITE) {
    DiskQueue<TestObject> disk_queue("queue/lisi", 1, 1024*1024*10, serializer, deserializer);

    ASSERT_EQ(1, disk_queue.empty());
    ASSERT_STREQ("queue/lisi", disk_queue.getQueueName());
    ASSERT_EQ(1, disk_queue.getMode());
    ASSERT_EQ(1024*1024*10, disk_queue.getMaxFileSize());

    int i;
    std::queue<TestObject*> TestObjectQueue;
    for(i = 0; i < 1024*10; i++) {//10M * 10
        TestObject* tmp = TestObject::createRandomOne(1024, 1);
        TestObject* tmp1 = tmp->copy();
        TestObjectQueue.push(tmp1);
        ASSERT_EQ(1, disk_queue.push(tmp));
    }

    int index = 0;
    while(!TestObjectQueue.empty()) {
        TestObject* tmp = TestObjectQueue.front();
        TestObjectQueue.pop();
        TestObject* tmp2 = NULL;
        ASSERT_EQ(0, disk_queue.empty());
        ASSERT_EQ(1, disk_queue.pop(&tmp2));
        
        int data_len = tmp->getDataLen();
        char* adata = tmp->getData();
        char* bdata = tmp2->getData();
        for(i = 0; i < data_len; i++) {
            ASSERT_EQ(adata[i], bdata[i]);
        }

        delete tmp;
        delete tmp2;
        
        index++;
    }
}
Пример #19
0
void ObjectTest::TestReferenceCount()
{
  TestObject* obj = new TestObject();
  assertEqual(obj->GetReferenceCount(), 0);

  obj->Register();
  assertEqual(obj->GetReferenceCount(), 1);

  obj->SetReferenceCount(3);
  assertEqual(obj->GetReferenceCount(), 3);

  obj->SetReferenceCount(0);
}
Пример #20
0
void AgentThread::processCMDGETTRACE_REQUEST(int socketHandle)
{
  try {
	ConsoleServer::debugMsg(1,"Processing CMDGETTRACE_REQUEST\n");
	// read the serialized TestObject which we want the exit code of
	TestObject test;
	
	test.readTestObject(socketHandle);
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
	int wasRun = FALSE;			
	for (int i = 0; i < getProcessCount(); i++) {
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();		  
	  if (curr->getTestID().compare(test.getTestID())==0) {
		wasRun = true;
		// ---- send the env, stdout and stderr files --------------------
		sendFile(curr->getEnvFileName(), socketHandle);
		sendFile(curr->getStdOutFileName(), socketHandle);
		sendFile(curr->getStdErrFileName(), socketHandle);	
		// ----------------------------------
		break;
	  }
	}
	
	if (!wasRun) {
	  // the process was never started, so assume it failed
	  ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str());			
	  Utils::writeInt(socketHandle,FAILED);
	}
	else {
	  // now send a signal indicating we have finished
	  Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
	}
	
  }
  catch (char *message) {
	ConsoleServer::debugMsg(1,"Error processing CMDGETTRACE_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
}	
Пример #21
0
void AgentThread::processCMDSTOP_REQUEST(int socketHandle)
{
  try {
	ConsoleServer::debugMsg(1,"Processing CMDSTOP_REQUEST\n");
	// read the serialized TestObject which we will stop
	TestObject test;
	
	test.readTestObject(socketHandle);
	
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
	// find the exit code, blocking for requested timeout if neccesary
	int wasRunning = FALSE;
	int status;
	
	for (int i = 0; i < getProcessCount(); i++) {
	  
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();
	  if (curr==NULL) {		
		printf("Error: Null process found on process list");
		return;		
	  }
	  
	  if (curr->getTestID().compare(test.getTestID())==0) {
		ConsoleServer::debugMsg(5,"Stopping process\n");
		wasRunning = TRUE;
		status = getProcess(i)->checkExitValue();
		// flush and close it's output streams
		getProcess(i)->interrupt();
		Utils::sendSignal(socketHandle,status);
		break;
	  }		  
	}
	
	if (!wasRunning) {
	  // the process was never started, so assume it failed
	  ConsoleServer::debugMsg(1,"Process was not running :%s\n",test.getTestID().c_str());			
	}
	else {	  
	  // now send a signal indicating we have finished
	  Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
	}

  }
  catch (char * message) {
	ConsoleServer::debugMsg(1,"Error processing CMDSTOP_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
};
Пример #22
0
void ActiveObjectTest::startTest()
{
    TestObject test;
    test.start();
    QVERIFY( test.isStarted() );

    // Wait for a while (it takes some time for a thread to start).
    std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
    while (std::chrono::system_clock::now() - start < std::chrono::milliseconds(100) );

    test.stop();
    QVERIFY( !test.isStarted() );
    QVERIFY( test.actionCalled() );
}
Пример #23
0
//------------------------------------------------------------------------------
// onUpdateObject() - bring our test object in and fill our data.
//------------------------------------------------------------------------------
bool ObjectHandler::onUpdateObject(const TestObject* const x)
{
    if (x != nullptr) {
        TestObject* obj = const_cast<TestObject*>(x);
        bool boolVal = obj->getBoolean();
        send("objboolean", UPDATE_VALUE, boolVal, boolSD);
        int intVal = obj->getInteger();
        send("objinteger", UPDATE_VALUE, intVal, intSD);
        float floatVal = obj->getFloat();
        send("objfloat", UPDATE_VALUE, floatVal, floatSD);
        double doubleVal = obj->getDouble();
        send("objdouble", UPDATE_VALUE, doubleVal, doubleSD);
        double realVal = obj->getReal();
        send("objreal", UPDATE_VALUE, realVal, realSD);
        const char* myChar = obj->getChar();
        send("objascii", UPDATE_VALUE, myChar, charSD);
    }

    return true;
}
Пример #24
0
void AgentThread::processCMDSTATUS_REQUEST(int socketHandle)
{	
  TestObject test;
  
  try {
	ConsoleServer::debugMsg(1,"Processing CMDSTATUS_REQUEST\n");
	// read the serialized TestObject which we will stop
	test.readTestObject(socketHandle);
	// now send a signal indicating we are processing the request
	Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);			
			
	// find the exit code, blocking if neccesary
	int wasRunning = FALSE;
	for (int i = 0; i < getProcessCount(); i++) {
	  // check for any instance of test running with the same id
	  TestObject *curr = getProcess(i)->getTestObject();		  
	  if (curr->getTestID().compare(test.getTestID())==0) {
		ConsoleServer::debugMsg(8,"Found started process :%s\n",test.getTestID().c_str());
		int status = getProcess(i)->getExitValue();				
		ConsoleServer::debugMsg(5,"Returning CMDSTATUS value :%d\n",status);
		Utils::writeInt(socketHandle,status);
		wasRunning = TRUE;
		break;
	  }
	}
	if (!wasRunning) {
	  // the process was never started, so assume it failed
	  ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str());
	  Utils::writeInt(socketHandle,FAILED);
	}
	else {	  
	  // now send a signal indicating we have finished
	  Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
	}
  }
  catch (char * message) {
	ConsoleServer::debugMsg(1,"Error processing CMDSTATUS_REQUEST request:%s\n",message);
	Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
  }
  
}
Пример #25
0
void test002() {
  IStaticServiceHandler* handler;
  TestObject* test;
  IObject* obj;
  ITestInterface *itest;

  handler = new StaticServiceHandler;
  ASSERT(handler != 0, "could not instantiate static service handler");

  test = new TestObject;
  ASSERT(test != 0, "could not instantiate test object");

  VERIFY(test->getRefCount() == 1, "the test object has an incorrect refcount");

  handler->addObject(TestObject_CID, test);
  VERIFY(test->getRefCount() == 2, "static service handler did not addRef the test component");

  obj = handler->getObject(TestObject_CID);
  ASSERT(obj != 0, "could not get test component from static service handler");

  itest = mutate<ITestInterface>(obj);
  ASSERT(itest != 0, "test component does not have the expected interface");

  VERIFY(test->getRefCount() == 3, "the test object has an incorrect refcount");
  itest->setRefCount(10);
  itest->addRef();
  VERIFY(itest->getRefCount() == 11, "test component has unexpected behavior");
  itest->setRefCount(3);

  VERIFY(itest->release() == 2, "test component has incorrect refcount");

  handler->removeObject(TestObject_CID);
  VERIFY(test->getRefCount() == 1, "static service handler did not release the test component");

  obj = handler->getObject(TestObject_CID);
  VERIFY(!obj, "static service handler did not remove the test component");
  if(obj)
    obj->release();

  VERIFY(handler->release() == 0, "static service handler has non-zero refcount after release");

  VERIFY(test->release() == 0, "test object has non-zero refcount after release");

  xplcdelete test;
}
Пример #26
0
void TestWebChannel::testDeregisterObjects()
{
    QWebChannel channel;
    TestObject testObject;
    testObject.setObjectName("myTestObject");


    channel.registerObject(testObject.objectName(), &testObject);

    channel.connectTo(m_dummyTransport);
    channel.d_func()->publisher->initializeClient(m_dummyTransport);

    QJsonObject connectMessage =
            QJsonDocument::fromJson(("{\"type\": 7,"
                                    "\"object\": \"myTestObject\","
                                    "\"signal\": " + QString::number(testObject.metaObject()->indexOfSignal("sig1()"))
                                    + "}").toLatin1()).object();
    channel.d_func()->publisher->handleMessage(connectMessage, m_dummyTransport);

    emit testObject.sig1();
    channel.deregisterObject(&testObject);
    emit testObject.sig1();
}
Пример #27
0
void main()
{
    // using a bit of random here.
    srand(time(nullptr)); //initialize random seed based on time

    // Where will this object live? Is this a good choice? Why or why not?
	 // This Object will be on the Stack. Not so good, because we have a pointer to it later
	 // its not so bad here, but normally it is bad to have a pointer to something on the stack 
	 // because if the scope ends and the pointer continues to exist, it can point to something useless
    TestObject anObject = TestObject(30);

    // Name differences between pointers and references
	 // Pointer can be changed, references not after initialization. pointer can be null, refer. not. References can be used like the object and need no dereference
    TestObject* anotherObject = new TestObject(2);

    // When should we use pointers, references and values? why?
	 // pointers for optional parameters
	 // references for any none-elemental datatypes
	 // values for small (32/64Bit) datatype and no change

	//reference is initialized with variable name, not adress
    TestObject& referenceToAnObject = anObject;

	// same here, so we have to dereference the pointer "anotherObject" first
    TestObject& referenceToAnotherObject = *anotherObject;

	// pointer is initialized with adress, so we have to get ADRESS from "anObject"
    TestObject* pointerToAnObject = &anObject;

	// same here, although referenceToAnotherObject is a reference(basically a adress too) 
	// it is used like the object itself, so we need to GET the ADRESS here too
    TestObject* pointerToAnotherObject = &referenceToAnotherObject;
    

    // Testing if the correct strings are being printed.
    referenceToAnotherObject.printAllStrings();
    std::cout << "The Following should be the same as above: " << std::endl;
    pointerToAnotherObject->printAllStrings();

    std::cout << std::endl << "total number of strings:" << std::endl;
   
    int& TotalElementNumber = sumTheElements(referenceToAnObject.elementCount(), referenceToAnotherObject.elementCount());
    std::cout << TotalElementNumber << std::endl;
    std::cout << "Do calculations in another scope and display the same value again inside that scope: " << std::endl; 
    { 
        //this isn't really doing anything, just for testing purposes
        int ignoreMe = 20; 
        ignoreMe *= TotalElementNumber;
        std::cout << TotalElementNumber << std::endl;
    }

    std::cout << "And again outside the scope: " << std::endl;
    std::cout << TotalElementNumber << std::endl;


    delete anotherObject;
	// these pointers have not been initialized with new, so cannot be deleted
    //delete pointerToAnObject;
    //delete pointerToAnotherObject;


}
Пример #28
0
void ActiveObjectTest::constructorTest()
{
    TestObject test;
    QVERIFY2 (!test.isStarted(),
              "Constructed object is started at construction");
}
Пример #29
0
void TestWebChannel::testInfoForObject()
{
    TestObject obj;
    obj.setObjectName("myTestObject");

    QWebChannel channel;
    const QJsonObject info = channel.d_func()->publisher->classInfoForObject(&obj, m_dummyTransport);

    QCOMPARE(info.keys(), QStringList() << "enums" << "methods" << "properties" << "signals");

    { // enums
        QJsonObject fooEnum;
        fooEnum["Asdf"] = TestObject::Asdf;
        fooEnum["Bar"] = TestObject::Bar;
        QJsonObject expected;
        expected["Foo"] = fooEnum;
        QCOMPARE(info["enums"].toObject(), expected);
    }

    { // methods & slots
        QJsonArray expected;
        {
            QJsonArray method;
            method.append(QStringLiteral("deleteLater"));
            method.append(obj.metaObject()->indexOfMethod("deleteLater()"));
            expected.append(method);
        }
        {
            QJsonArray method;
            method.append(QStringLiteral("slot1"));
            method.append(obj.metaObject()->indexOfMethod("slot1()"));
            expected.append(method);
        }
        {
            QJsonArray method;
            method.append(QStringLiteral("slot2"));
            method.append(obj.metaObject()->indexOfMethod("slot2(QString)"));
            expected.append(method);
        }
        {
            QJsonArray method;
            method.append(QStringLiteral("method1"));
            method.append(obj.metaObject()->indexOfMethod("method1()"));
            expected.append(method);
        }
        QCOMPARE(info["methods"].toArray(), expected);
    }

    { // signals
        QJsonArray expected;
        {
            QJsonArray signal;
            signal.append(QStringLiteral("destroyed"));
            signal.append(obj.metaObject()->indexOfMethod("destroyed(QObject*)"));
            expected.append(signal);
        }
        {
            QJsonArray signal;
            signal.append(QStringLiteral("sig1"));
            signal.append(obj.metaObject()->indexOfMethod("sig1()"));
            expected.append(signal);
        }
        {
            QJsonArray signal;
            signal.append(QStringLiteral("sig2"));
            signal.append(obj.metaObject()->indexOfMethod("sig2(QString)"));
            expected.append(signal);
        }
        QCOMPARE(info["signals"].toArray(), expected);
    }

    { // properties
        QJsonArray expected;
        {
            QJsonArray property;
            property.append(obj.metaObject()->indexOfProperty("objectName"));
            property.append(QStringLiteral("objectName"));
            {
                QJsonArray signal;
                signal.append(1);
                signal.append(obj.metaObject()->indexOfMethod("objectNameChanged(QString)"));
                property.append(signal);
            }
            property.append(obj.objectName());
            expected.append(property);
        }
        {
            QJsonArray property;
            property.append(obj.metaObject()->indexOfProperty("foo"));
            property.append(QStringLiteral("foo"));
            {
                QJsonArray signal;
                property.append(signal);
            }
            property.append(obj.foo());
            expected.append(property);
        }
        {
            QJsonArray property;
            property.append(obj.metaObject()->indexOfProperty("asdf"));
            property.append(QStringLiteral("asdf"));
            {
                QJsonArray signal;
                signal.append(1);
                signal.append(obj.metaObject()->indexOfMethod("asdfChanged()"));
                property.append(signal);
            }
            property.append(obj.asdf());
            expected.append(property);
        }
        {
            QJsonArray property;
            property.append(obj.metaObject()->indexOfProperty("bar"));
            property.append(QStringLiteral("bar"));
            {
                QJsonArray signal;
                signal.append(QStringLiteral("theBarHasChanged"));
                signal.append(obj.metaObject()->indexOfMethod("theBarHasChanged()"));
                property.append(signal);
            }
            property.append(obj.bar());
            expected.append(property);
        }
        QCOMPARE(info["properties"].toArray(), expected);
    }
}
void testRoutine() {
    TestObject one;
    
    void (^b)(void) = ^{ printf("my const copy of one is %d\n", one.version()); };
}