1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef JUnitLogger_HH2
9 #define JUnitLogger_HH2
11 namespace TitanLoggerApi { class TitanLogEvent; }
13 #ifndef TITAN_RUNTIME_2
14 #include "RT1/TitanLoggerApi.hh"
16 #include "RT2/TitanLoggerApi.hh"
19 #include "ILoggerPlugin.hh"
36 std::string module_name;
38 std::string dte_reason;
39 std::string stack_trace;
43 TestCase():tc_name(""), module_name(""), reason(""), dte_reason(""), stack_trace(""), tc_start(0), time(0.0){}
45 void writeTestCase(FILE* file_stream_) const;
46 void setTCVerdict(const TitanLoggerApi::TitanLogEvent& event);
47 void addStackTrace(const TitanLoggerApi::TitanLogEvent& event);
61 typedef std::vector<TestCase*> TestCases;
63 // TitanLoggerApi::TimestampType timestamp; TODO
74 TestSuite():ts_name(""), all(0), skipped(0), failed(0), error(0), inconc(0) {}
77 void addTestCase(const TestCase& element);
78 void write(FILE* file_stream_);
82 class JUnitLogger2: public ILoggerPlugin
86 virtual ~JUnitLogger2();
87 inline bool is_static() { return false; }
88 void init(const char *options = 0);
91 void log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered,
92 bool separate_file, bool use_emergency_mask);
93 void set_parameter(const char *parameter_name, const char *parameter_value);
94 // do not implement ILoggerPlugin::set_file_name();
95 // it gets a filename skeleton and can't expand it.
97 virtual void open_file(bool /*is_first*/);
98 virtual void close_file();
100 enum xml_escape_char_t { LT=0x01, GT=0x02, QUOT=0x04, APOS=0x08, AMP=0x10 };
101 CHARSTRING escape_xml(const CHARSTRING& xml_str, int escape_chars);
102 CHARSTRING escape_xml_attribute(const CHARSTRING& attr_str) { return escape_xml(attr_str, QUOT|AMP); }
103 CHARSTRING escape_xml_element(const CHARSTRING& elem_str) { return escape_xml(elem_str, LT|AMP); }
104 CHARSTRING escape_xml_comment(const CHARSTRING& comm_str) { return escape_xml(comm_str, AMP); /* FIXME: --> should be escaped too */ }
108 char *filename_stem_;
109 char *testsuite_name_;
114 std::string dte_reason;
119 #endif // JUnitLogger_HH2