
Sure, by definition *unit* tests should not depend on any external resource like databases. All my tests are /integration/ ones, testing the whole stack from logging to reading back from MongoDB. We should probably split them and write mocked tests as well (I like Mockito, but it is just a matter of preference). On 14.06.2012 19:54, Christian Trutz wrote:
Hi Tomasz,
The only issue I see is integration testing: at least my tests require running MongoDB instance somewhere. This is a major drawback for both continuous integration of Lobgack extensions and for all developers, not necessarily interested in this particular extension.
I think we should not require for unit test a mongodb instance. I have very good experience with jmockit http://code.google.com/p/jmockit/ what do you think about?
Christian
2012/6/14 Tomasz Nurkiewicz <nurkiewicz@gmail.com <mailto:nurkiewicz@gmail.com>>
Here is precisely what I created so far:
* base abstract appender handling MongoDB connectivity [1] * standard appender [2] + tests [3] * access appender (tested with Tomcat) [4] + tests [5] * configuration examples [6]
By quick googling I found several other community implementations: [7], [8], [9]. Looks like my implementation is the only one capable of storing access logs as well, e.g.:
{ "_id" : ObjectId("__4d98cc4f7abb95e59279e183"), "timeStamp" : ISODate("2011-04-03T19:36:47.__339Z"), "server" : "localhost", "remote" : { "host" : "0:0:0:0:0:0:0:1", "user" : "tomcat", "addr" : "0:0:0:0:0:0:0:1" }, "request" : { "uri" : "/manager/images/tomcat.gif", "protocol" : "HTTP/1.1", "method" : "GET", "sessionId" : "__1C6357816D9EEFD31F6D9D154D8730__8A", "userAgent" : "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.10 (maverick) Firefox/3.6.16", "referer" : "http://localhost:8080/__manager/html <http://localhost:8080/manager/html>" }, "response" : { "contentLength" : NumberLong(1934), "statusCode" : 200 } }
We should now revise all available implementations and build final one based on best ideas from all of them. The only issue I see is integration testing: at least my tests require running MongoDB instance somewhere. This is a major drawback for both continuous integration of Lobgack extensions and for all developers, not necessarily interested in this particular extension.
Christian Trutz - thanks for creating the project structure.
[1]: https://github.com/nurkiewicz/__logback/blob/mongodb-appender/__logback-core... <https://github.com/nurkiewicz/logback/blob/mongodb-appender/logback-core/src/main/java/ch/qos/logback/core/db/mongo/MongoDBAppenderBase.java>
[2]: https://github.com/nurkiewicz/__logback/blob/mongodb-appender/__logback-clas... <https://github.com/nurkiewicz/logback/blob/mongodb-appender/logback-classic/src/main/java/ch/qos/logback/classic/db/mongo/MongoDBAppender.java>
[3]: https://github.com/nurkiewicz/__logback/blob/mongodb-appender/__logback-clas... <https://github.com/nurkiewicz/logback/blob/mongodb-appender/logback-classic/src/test/java/ch/qos/logback/classic/db/mongo/MongoDBAppenderTest.java>
[4]: https://github.com/nurkiewicz/__logback/blob/mongodb-appender/__logback-acce... <https://github.com/nurkiewicz/logback/blob/mongodb-appender/logback-access/src/main/java/ch/qos/logback/access/db/mongo/MongoDBAppender.java>
[5]: https://github.com/nurkiewicz/__logback/blob/mongodb-appender/__logback-acce... <https://github.com/nurkiewicz/logback/blob/mongodb-appender/logback-access/src/test/java/ch/qos/logback/access/db/mongo/MongoDBAppenderTest.java>
[6]: https://github.com/nurkiewicz/__logback/tree/mongodb-appender/__logback-clas... <https://github.com/nurkiewicz/logback/tree/mongodb-appender/logback-classic/src/test/input/joran/mongodb>
[7]: https://github.com/kofemann/__mongo-appender-for-logback <https://github.com/kofemann/mongo-appender-for-logback>
[8]: https://github.com/smilebase/__logback-mongodb <https://github.com/smilebase/logback-mongodb>
[9]: https://github.com/uded/__logback-mongodb-appender <https://github.com/uded/logback-mongodb-appender>
On 14.06.2012 14:24, ceki wrote:
Hi Christian,
Tomasz created a jira issue for implementing MongoDBAppender [2]. His implementation can be found at [3, 4, 5].
I think his impl is worth a look. He seprated connection functionality into MongoDBAppenderBase (part of logback-core) and ILoggingEvent specific code into MongoDBAppender (in logback-classic). Moreover, his code comes with 100% test coverage!
I guess the code could be easily extended to cater for AccessEvent (in logback-access).
Anyway, let me know what I can do to move this work forward.
[1] https://github.com/qos-ch/__logback-extensions <https://github.com/qos-ch/logback-extensions> [2] http://jira.qos.ch/browse/__LOGBACK-522 <http://jira.qos.ch/browse/LOGBACK-522> [3] https://github.com/nurkiewicz/__logback/tree/mongodb-appender <https://github.com/nurkiewicz/logback/tree/mongodb-appender> [4] https://github.com/nurkiewicz/__logback/commit/858aceb9af74d0 <https://github.com/nurkiewicz/logback/commit/858aceb9af74d0> [5] https://github.com/nurkiewicz/__logback/commit/f5bff8e43 <https://github.com/nurkiewicz/logback/commit/f5bff8e43>
pozdrowienia
-- Tomasz Nurkiewicz http://nurkiewicz.blogspot.com _________________________________________________ logback-dev mailing list logback-dev@qos.ch <mailto:logback-dev@qos.ch> http://mailman.qos.ch/mailman/__listinfo/logback-dev <http://mailman.qos.ch/mailman/listinfo/logback-dev>
-- Christian Trutz Von-Flotow-Straße 24 D-45772 Marl
Festnetz (privat): +49 (0)2365 3840327 E-Mail: christian.trutz@gmail.com <mailto:christian.trutz@gmail.com>
_______________________________________________ logback-dev mailing list logback-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-dev
pozdrowienia -- Tomasz Nurkiewicz http://nurkiewicz.blogspot.com