PILLUTLAAVINASH / google-enterprise-connector-manager

Automatically exported from code.google.com/p/google-enterprise-connector-manager
0 stars 0 forks source link

com.google.enterprise.connector.pusher.DocPusherTest.testFeedLogging() is language sensitive #174

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the unit tests with a default locale of French. (It should also work
with other languages. See below for explanations.)

What is the expected output? What do you see instead?

Unit tests fails.

What version of the product are you using? On what operating system?

V 2.0, Windows XP

Please provide any additional information below.

The source of the problem is line 898: 
assertEquals(xmlLine, logLine.substring(7));

The author expected to remove "FINEST:" (7 characters) from the log line.
In French, it's "LE PLUS:" (8 characters). 

A custom formatter can be replace the (language sensitive) SimpleFormatter
used : 

Formatter formatter = new Formatter() {
  @Override
  public String format(LogRecord record) {
    return record.getMessage();
  }
};
fh.setFormatter(formatter);

And then we can replace former line 898 with the cleaner : 

assertEquals(xmlLine, logLine);

See attached file for example. 

Regards, 

Nicolas Bélisle
Constellio team

Original issue reported on code.google.com by nicolas....@gtempaccount.com on 4 Aug 2009 at 7:01

Attachments:

GoogleCodeExporter commented 8 years ago
I've encountered this same problem before while testing issue 117. I know I've 
changed the code to fix it, but I 
never checked it in, and I can't find it sitting around. I like replacing the 
formatter in the sense that it makes the 
log output more predictable, but I'm mildly nervous about setting it globally, 
even if we set it back in a finally 
clause or tearDown method. I had changed the code to scan for the first colon 
(":") instead of counting 
characters.

Original comment by jl1615@gmail.com on 7 Aug 2009 at 7:04

GoogleCodeExporter commented 8 years ago
Hi, 

I fully agree that messing with the logger is not clean.
Note that the code still replaces the FileHandler for the logger. As well, as 
it log
level.

getFeedLogger() in com.google.enterprise.connector.pusher.DocPusher is 
sensitive to
run-time modifications because it is public. DocPusherTest seems the only class 
that
uses this method. 

It seems a bit tricky to test logging behavior with exposing your Logger. A 
colleague
suggested that code could changer the logging configuration during your unit 
tests
using java.util.logging.LogManager and then reset the configuration back. 
Cleaner (no
public logger), but more complex.

Regards, 

Nicolas Bélisle
Constellio team

Original comment by nicolas....@gtempaccount.com on 7 Aug 2009 at 3:13

GoogleCodeExporter commented 8 years ago
I inadvertently fixed this in conjunction with the Issue 106 changes.  The 
format of the feed logs changed 
slightly.  Specifically, the XML feed record no longer starts on the first log 
message line (the line with the LEVEL).
This change is already in the 2.0.x branch and released in 2.0.2.  See r2229

The change will be added to the trunk shortly.

Original comment by Brett.Mi...@gmail.com on 9 Sep 2009 at 8:46

GoogleCodeExporter commented 8 years ago

Original comment by Brett.Mi...@gmail.com on 9 Sep 2009 at 8:47

GoogleCodeExporter commented 8 years ago
Fixed 01 October 2009 in revision r2257

Original comment by Brett.Mi...@gmail.com on 6 Oct 2009 at 9:21

GoogleCodeExporter commented 8 years ago

Original comment by jla...@google.com on 9 Dec 2010 at 10:28