Exemplo n.º 1
0
bool testEvents1() {
	LOG(INFO) << "---- testEvent1 ";
	Interpreter* interpreter = Interpreter::fromURI(path + "/eventdata-01.xml");
	interpreter->start();
	interpreter->waitForStabilization();
	assert(interpreter->getConfiguration().size() == 1);
	assert(Interpreter::isMember(interpreter->getState("state1"), interpreter->getConfiguration()));

	Event eventFoo;
	eventFoo.name = "event.foo";
	eventFoo.atom = "3";
	interpreter->receive(eventFoo);
	interpreter->waitForStabilization();
	assert(interpreter->getConfiguration().size() == 1);
	assert(Interpreter::isMember(interpreter->getState("state3"), interpreter->getConfiguration()));

	Event eventBar;
	eventBar.name = "event.bar";
	eventBar.atom = "6";
	interpreter->receive(eventBar);
	interpreter->waitForStabilization();
	assert(interpreter->getConfiguration().size() == 1);
	assert(Interpreter::isMember(interpreter->getState("state6"), interpreter->getConfiguration()));

	Event eventBaz;
	eventBaz.name = "event.baz";
	eventBaz.atom = "7";
	interpreter->receive(eventBaz);

	delete interpreter;
	return true;
}
Exemplo n.º 2
0
bool testEvents2() {
	LOG(INFO) << "---- testEvent2 ";
	Interpreter* interpreter = Interpreter::fromURI(path + "/eventdata-02.xml");
	interpreter->start();
	interpreter->waitForStabilization();
	assert(interpreter->getConfiguration().size() == 1);
	assert(Interpreter::isMember(interpreter->getState("state0"), interpreter->getConfiguration()));

	Event eventConnAlert;
	eventConnAlert.name = "connection.alerting";
	eventConnAlert.atom = "'line2'";
	interpreter->receive(eventConnAlert);
	interpreter->waitForStabilization();
	assert(interpreter->getConfiguration().size() == 1);
	assert(Interpreter::isMember(interpreter->getState("state2"), interpreter->getConfiguration()));

	Event eventConnAlert2;
	eventConnAlert2.name = "connection.alerting";
	eventConnAlert2.compound["line"] = Data(std::string("4"));
	interpreter->receive(eventConnAlert2);

	delete interpreter;
	return true;
}