From f92dd279a1e26dad7507d5d6944567c23834d440 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 27 May 2010 09:45:12 +0000 Subject: A lot of session handling. A lot of new unit tests. Add of a more structured commit/discard handling. Fix of some wierd line break bugs in journalwriter --- server/src/artefact.cc | 59 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'server/src/artefact.cc') diff --git a/server/src/artefact.cc b/server/src/artefact.cc index 24114f9..f3e739d 100644 --- a/server/src/artefact.cc +++ b/server/src/artefact.cc @@ -34,10 +34,10 @@ Artefact::Artefact() { -#ifndef WITHOUT_PENTOMINOS +#ifndef WITHOUT_ARTEFACT + PRACRO_DEBUG(artefact, "Creating artefact connection %s : %d\n", Conf::artefact_addr.c_str(), Conf::artefact_port); -#endif/*WITHOUT_PENTOMINOS*/ atfh = atf_init(); if(!atfh) PRACRO_ERR(artefact, "Out of memory!\n"); @@ -46,19 +46,26 @@ Artefact::Artefact() Conf::artefact_addr.c_str(), Conf::artefact_port, Conf::artefact_use_ssl); + +#endif/*WITHOUT_ARTEFACT*/ } Artefact::~Artefact() { +#ifndef WITHOUT_ARTEFACT + atf_disconnect(conn); atf_close(atfh); + +#endif/*WITHOUT_ARTEFACT*/ } +#ifndef WITHOUT_ARTEFACT static QueryResult node2result(atf_result_node_t *node, time_t timestamp) { QueryResult rnode; rnode.timestamp = timestamp; - rnode.source = "pentominos"; + rnode.source = "artefact"; if(!node) return rnode; @@ -74,11 +81,18 @@ static QueryResult node2result(atf_result_node_t *node, time_t timestamp) return rnode; } +#endif/*WITHOUT_ARTEFACT*/ QueryResult Artefact::exec(Query &query, std::string patientid, std::string user) { + QueryResult rroot; + rroot.timestamp = 0; + rroot.source = "pentominos"; + +#ifndef WITHOUT_ARTEFACT + atf_transaction_t* atft = NULL; atf_reply_t *reply = NULL; atf_result_t *result = NULL; @@ -87,10 +101,6 @@ QueryResult Artefact::exec(Query &query, time_t timestamp; atf_id id; - QueryResult rroot; - rroot.timestamp = 0; - rroot.source = "pentominos"; - if(query.attributes.find("class") == query.attributes.end()) { PRACRO_ERR(artefact, "Missing 'class' attribute!\n"); goto aaarg; @@ -135,22 +145,43 @@ QueryResult Artefact::exec(Query &query, if(reply) atf_free_reply(reply); if(atft) atf_free_transaction(atft); +#endif/*WITHOUT_ARTEFACT*/ + return rroot; } #ifdef TEST_ARTEFACT -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: +//deps: configuration.cc debug.cc +//cflags: $(ATF_CFLAGS) -I.. +//libs: $(ATF_LIBS) #include "test.h" TEST_BEGIN; -// TODO: Put some testcode here (see test.h for usable macros). +pracro_debug_init(); +pracro_debug_parse("+all"); + +{ + Artefact atf; + Query q; + q.attributes["class"] = "echo"; + QueryResult res = atf.exec(q, "1505050505", "me"); + + res.print(); +} + +{ + Conf::artefact_addr = "nowhere_at_all.com"; + Conf::artefact_port = 10000; + + Artefact atf; + Query q; + q.attributes["class"] = "echo"; + QueryResult res = atf.exec(q, "1505050505", "me"); + + res.print(); +} TEST_END; -- cgit v1.2.3