Monday, May 16, 2011

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.

Saturday, September 25, 2010

and so you code ... :D

http://www.youtube.com/watch?v=Eq3CuMDXaPs

I lost something - I find something

idea for a web 2.0 lost porperty site

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.

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

    

Tuesday, February 16, 2010

integrating jobss seam manually without seam-gen

Well, actually my question was:
  1. Which dependencies do I need?
  2. What configurations sould I make to for example web.xml or faces-context.xml

1. Which dependencies do I need?
It depends on which features are you going to have in your project. For example  for a just simple porject with seam and hibernate (for beam validation) just copy all dependecies found in jboss-seam-2.2.0.GA\examples\jpa project:
  • first build it using ant tomcat6
  • then deploy the created .war file to tomcat, and after it is exploded (LoL) look at /WEB-INF/lib directory to find dependencies.
Remember that seam.2.2.0.GA might need older versions than what you may find in projects web sites. For example it needed version 3.1.0.GA of hibernate-validator.jar and could not work with the last version.

2. What configurations sould I make to for example web.xml or faces-context.xml?

look here: http://docs.jboss.com/seam/latest/reference/en-US/html/configuration.html#d0e24011



and don't forget to put an empty seam.properties file at your package  root
otherwise you get continously errors on the console stating that hibernate cannot do something with transactions

Tuesday, January 26, 2010

JBoss EL - Passing vlues from view to bean methods

  1. add jboss-el.jar to project build path
  2. add following configuration to web.xml
<!-- jboss el expressions allow method params -->
<context-param>
  <param-name>com.sun.faces.expressionFactory</param-name>
  <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>


http://www.ilikespam.com/blog/el-function-parameters-with-jboss-el