Wednesday, March 28, 2012

Master/Slave database - Replication Database

What is Master/Slave database?

Syncronized data between two database is set to be maste/Slave configuration.

When to consider Master/Slave database approach?
It is helpful in Batch Reporting Application.
In usual realtime there will be two application one as portal application and another is batch reporting application. Portal application can use the Master DB and Batch process can use Slave DB. Slave DB get the replicated data from Master DB. This replication usually taken care by DBA. So dev team concentrate on business logic.

What is the advantage of Master/Slave database approach?
Performance :)
Because Portal can keep using the Master and there is no hindrance in database by huge sql activity in slave DB. Batch can continue using the slave DB as and when required.

Wednesday, March 21, 2012

JUnit Mockitto - Void Method Testing

To test the void method using Junit and Mockitto use below approach
Concider someMethod s a void method inside  SomeClass

Use the below approach:

SomeClass classObjMock = (Mock)SomeClas;
doNothing().doThrow(new RuntimeException()).when(classObjMock).someMethod ();

JUnit Code Coverage - EClemma

EClemma  works pretty well to know the JUnit code coverage from eclipse
It displays green shade for the files which is covered and red for the lines which are not code covered.

Junit class file -> Right click -> Coverege As -> Junit

http://www.eclemma.org/installation.html


Unzip the archive into dropins folder of your Eclipse installation and restart Eclipse:
/
+- dropins/
   +- eclemma-x.y.z/
      +- plugins/
      |  +- ...
      +- feature/
         +- ...