Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Test and Performance Tools Platform (TPTP) » How can I perform logging from within a HyadesTestCase?
How can I perform logging from within a HyadesTestCase? [message #9357] Tue, 08 March 2005 13:07 Go to next message
Eclipse UserFriend
Originally posted by: jan.nicklisch.entimo.de

Sorry Folks,

if that is a stupid question ... given that there are apparently zillions of
dedicated classes within the Hyades source that seem to adapt various
logging systems (e.g. java14) ...

However, I feel unable to write a test that logs some output to either the
console or a file (sample below) using Log4J.

My intention is that I do not want to rewrite all my existing JUnit test
when migrating to Hyades. Yes, I first need to create JUnit Test Suite
definitions, then generate the test class body, then cut'n'paste my legacy
test code into there (which is kind of enough hazzle, already) ... but then
I would rather not want to be required to further edit those code chunks.

Any help would be greatly appreciated.

Thank you in advance,

Jan Nicklisch

---

import org.apache.log4j.Logger;

public class SomeTests extends HyadesTestCase {

private static Logger _log = Logger.getLogger(SomeTests.class);

[..]

public void c_s1_create() throws Exception {
_log.debug("create");
assertEquals("order columns differ", Arrays.asList(_oc),
_ocs.getCols());
assertEquals("initial order clause is wrong", "",
_ocs.getOrderClause());
}
}
Re: How can I perform logging from within a HyadesTestCase? [message #11320 is a reply to message #9357] Mon, 21 March 2005 15:17 Go to previous message
Paul Slauenwhite is currently offline Paul SlauenwhiteFriend
Messages: 970
Registered: July 2009
Senior Member
Hi Jan,
Good news! There is no need to migrate any logging code to fully
leverage Hyades/TPTP. Hyades/TPTP does not provide a logging facility, as
such. We provide Common Base Event and Logging Agent support for three
popular open-source logging facilities - Apache Commons, Apache Log4J and
Java Logging. Common Base Event support is often required for logging
Common Base Events in logging facilities that have proprietary log records
(e.g. java.util.logging.LogRecord). Often, this Common Base Event support
is not required since logging facilities, such as Apache Commons and Log4J,
permit generic (e.g. java.lang.Object) log data. Logging Agent support
entails monitoring loggers or Logging Agents in real-time by configuring a
logging facility to write or output to a special type of outputter, handler,
appender that writes to a Logging Agent. For more information, see File >
New > Examples > Haydes Logging.

For your scenario, I would recommend using your existing Log4J code and
configure Log4J to write to a LoggingAgentAppender by adding the following
the entry to the <log4j:configuration> element in the log4j.xml properties
file:

<!-- LoggingAgentAppender -->
<!-- Outputs events to a Logging Agent using possible filter(s). Layout is
performed implicitly. -->
<appender name="LoggingAgent"
class="org.eclipse.hyades.logging.log4j.LoggingAgentAppender " />

See the above mentioned sample.

Paul

"Jan Nicklisch" <jan.nicklisch@entimo.de> wrote in message
news:d0k83b$kf0$1@www.eclipse.org...
> Sorry Folks,
>
> if that is a stupid question ... given that there are apparently zillions
of
> dedicated classes within the Hyades source that seem to adapt various
> logging systems (e.g. java14) ...
>
> However, I feel unable to write a test that logs some output to either the
> console or a file (sample below) using Log4J.
>
> My intention is that I do not want to rewrite all my existing JUnit test
> when migrating to Hyades. Yes, I first need to create JUnit Test Suite
> definitions, then generate the test class body, then cut'n'paste my legacy
> test code into there (which is kind of enough hazzle, already) ... but
then
> I would rather not want to be required to further edit those code chunks.
>
> Any help would be greatly appreciated.
>
> Thank you in advance,
>
> Jan Nicklisch
>
> ---
>
> import org.apache.log4j.Logger;
>
> public class SomeTests extends HyadesTestCase {
>
> private static Logger _log = Logger.getLogger(SomeTests.class);
>
> [..]
>
> public void c_s1_create() throws Exception {
> _log.debug("create");
> assertEquals("order columns differ", Arrays.asList(_oc),
> _ocs.getCols());
> assertEquals("initial order clause is wrong", "",
> _ocs.getOrderClause());
> }
> }
>
>
Previous Topic:RAServer startup - Fileserver class not found
Next Topic:Getting Started... help
Goto Forum:
  


Current Time: Thu Nov 20 21:08:36 GMT 2014

Powered by FUDForum. Page generated in 0.04660 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software