Data Structure
Clean Code
Refactoring
Effective Java
Pragmatic Programmer
Thinking in Java
Monday, May 16, 2011
testing links
http://martinfowler.com/ articles/mocksArentStubs.html
http://misko.hevery.com/code- reviewers-guide/
http://misko.hevery.com/code- reviewers-guide/flaw- constructor-does-real-work/
http://java.dzone.com/ articles/static-methods-are- death-testa
http://www.codeproject.com/KB/ cs/autp1.aspx#WorkOrder44
http://misko.hevery.com/2008/ 07/08/how-to-think-about-the- new-operator/
http://misko.hevery.com/code-
http://misko.hevery.com/code-
http://java.dzone.com/
http://www.codeproject.com/KB/
http://misko.hevery.com/2008/
Lessons learned in testing
1. define for almost everything an interface. Everything, means
everything that the other classes probabaly need (factories, services,
and alike). You should use interfaces, otherwise you can't create
mocks.
2. Inject everything a class need (its dependencies), for exmaple
using its constructor.
3. during testing, you create mocks for these dependencies, and give
them to your class. This way you are sure you are testing you class in
isolation.
Remark 1: A mock is infact the means by which you break up this chain
of dependencies, so that you can test you class in isolation; and not
testing 10 other classes as you are "unit" testing your class. Imagine
the example of testing AssignmentFactory.
createAssignment() method. In
order to create an assignement, AssignementFactory needs a
MailingFactory needs an ImageFactory needs .... . By injecting the
factories in constructors and using interfaces, you have the
possibility to mock them and isolate for example AssignmentFactory
implementation from implementation of MailingFactory using
MailingFactoryMock.
Remark 2: As a rule of thum, your code most consist of classes who do
work, and classes that create the object graph by creating new
objects. Hence the classes who do work, should not contain "new"
statements.
everything that the other classes probabaly need (factories, services,
and alike). You should use interfaces, otherwise you can't create
mocks.
2. Inject everything a class need (its dependencies), for exmaple
using its constructor.
3. during testing, you create mocks for these dependencies, and give
them to your class. This way you are sure you are testing you class in
isolation.
Remark 1: A mock is infact the means by which you break up this chain
of dependencies, so that you can test you class in isolation; and not
testing 10 other classes as you are "unit" testing your class. Imagine
the example of testing AssignmentFactory.
order to create an assignement, AssignementFactory needs a
MailingFactory needs an ImageFactory needs .... . By injecting the
factories in constructors and using interfaces, you have the
possibility to mock them and isolate for example AssignmentFactory
implementation from implementation of MailingFactory using
MailingFactoryMock.
Remark 2: As a rule of thum, your code most consist of classes who do
work, and classes that create the object graph by creating new
objects. Hence the classes who do work, should not contain "new"
statements.
Saturday, September 25, 2010
Tuesday, March 16, 2010
RichFaces modal panel containing a form causes problem
1. put a rich:modalPanel inside a form. Every time that panel was closed (e.g usign X button on top, or OK or Cancel buttons) the form got refreshed. Actually not refreshed but I think a GET happened. I'm not sure. The effect was that, I back and forward the same form so much as I had opened the modal pannel. Or if I refreshed the page, it wanted to send form data again to the server.
2. I put modal panle outside the form, but thought that I must have a form so that buttons function. Hence I put a h:form arround the buttons. But it caused again the same behavior.
3. I put the modal panel outside of form, and there was also no form in it (arround buttons). It worked.
2. I put modal panle outside the form, but thought that I must have a form so that buttons function. Hence I put a h:form arround the buttons. But it caused again the same behavior.
3. I put the modal panel outside of form, and there was also no form in it (arround buttons). It worked.
Tuesday, February 23, 2010
Integrating ActiveMQ with JBoss AS
1. extract ActiveMQ.rar in deployment folder of JBoss
2. edit META-INF/ra.xml (set connector proocol (tcp or jvm), and config file (brocker-config.xml))
3. edit brocker-config.xml (add brockerName attribute, set persistance dataDir, set transport connector name attribute)
4. configure JBoss to start ActiveMQ on startup (add activmq-ds.xml to deployment directory of JBoss)
for details see:
http://activemq.apache.org/integrating-apache-activemq-with-jboss.html
2. edit META-INF/ra.xml (set connector proocol (tcp or jvm), and config file (brocker-config.xml))
3. edit brocker-config.xml (add brockerName attribute, set persistance dataDir, set transport connector name attribute)
4. configure JBoss to start ActiveMQ on startup (add activmq-ds.xml to deployment directory of JBoss)
for details see:
http://activemq.apache.org/integrating-apache-activemq-with-jboss.html
Subscribe to:
Posts (Atom)